{
  "id": "task_libraries:job-scheduler/python",
  "path": "/exapedia/python-job-scheduler-libraries",
  "template": {
    "id": "task_libraries",
    "version": 4
  },
  "title": "Python job scheduler libraries",
  "answer": [
    {
      "t": "text",
      "text": "Python job scheduler libraries run functions at set times or intervals and hand longer work to background workers. A task queue sends each job through a broker such as Redis to separate worker processes. These libraries let web apps and AI agents run recurring work such as reports and data syncs."
    }
  ],
  "breadcrumb": [
    {
      "label": "Tools"
    },
    {
      "label": "Python job scheduler libraries"
    }
  ],
  "sections": [
    {
      "id": "libraries_popularity",
      "anchor": "popularity",
      "heading": "Popularity",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Monthly downloads",
            "Stars",
            "Last release",
            "License"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#celery",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F128"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F129"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F135"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F132"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F130"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#apscheduler",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F143"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F144"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F150"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F147"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F145"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#huey",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F158"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F159"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F167"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F162"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F160"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#rq",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F171"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F172"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F178"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F175"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F173"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#schedule",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F186"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F187"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F193"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F190"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F188"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#arq",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F201"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F202"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F210"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F205"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F203"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#taskiq",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F218"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F219"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F227"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F222"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F220"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#dramatiq",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F235"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F236"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F244"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F239"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F237"
                }
              ]
            ]
          ],
          "variant": "pop",
          "caption": [
            {
              "t": "text",
              "text": "Downloads: "
            },
            {
              "t": "text",
              "text": "PyPI"
            },
            {
              "t": "text",
              "text": ", last thirty days. Stars and releases: GitHub. Amber: no release in over a year."
            }
          ]
        }
      ],
      "note": [
        {
          "t": "link",
          "href": "#celery",
          "label": [
            {
              "t": "text",
              "text": "Celery"
            }
          ]
        },
        {
          "t": "text",
          "text": " has the most monthly downloads in this comparison, at "
        },
        {
          "t": "fact",
          "fact": "F129"
        },
        {
          "t": "text",
          "text": "."
        }
      ]
    },
    {
      "id": "libraries_capabilities",
      "anchor": "capabilities",
      "heading": "Capabilities",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Recurring schedule support",
            "Separate task workers"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#celery",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F128"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F136"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F137"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#apscheduler",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F143"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F151"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F152"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#huey",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F158"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F168"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F169"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#rq",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F171"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F179"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F180"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#schedule",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F186"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F194"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F195"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#arq",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F201"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F211"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F212"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#taskiq",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F218"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F228"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F229"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#dramatiq",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F235"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F245"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F246"
                }
              ]
            ]
          ],
          "variant": "cap"
        }
      ]
    },
    {
      "id": "libraries_entries",
      "anchor": "libraries",
      "heading": "Libraries",
      "blocks": [
        {
          "b": "entry",
          "anchor": "celery",
          "name": [
            {
              "t": "fact",
              "fact": "F128"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/celery/celery"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/celery"
            },
            {
              "label": "Docs",
              "href": "https://docs.celeryq.dev/en/stable/userguide/periodic-tasks.html"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F12"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F129"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F135"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F131"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F130"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://docs.celeryq.dev/en/stable/userguide/periodic-tasks.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F128"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F13"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F14"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F15"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F16"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F17"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F18"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F19"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F20"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F141"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F142"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/readthedocs/readthedocs.org",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F141"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def finish_import_project(self, request, project):\n    \"\"\"\n    Perform last steps to import a project into Read the Docs.\n\n    - Add the user from request as maintainer\n    - Run extra tasks that are needed before building the project\n    - Trigger the initial build\n\n    Direct upload projects skip the last two steps:\n    Read the Docs never builds them, and the webhook and SSH key are not needed.\n\n    It requires the Project was already saved into the DB.\n\n    :param request: Django Request object\n    :param project: Project instance just imported (already saved)\n    \"\"\"\n    project.users.add(request.user)\n    log.info(\n        \"Project imported.\",\n        project_slug=project.slug,\n        user_username=request.user.username,\n    )\n\n    if project.is_direct_upload:\n        return None\n\n    update_docs, build = prepare_build(project)\n    if (update_docs, build) == (None, None):\n        return None\n\n    tasks = self._get_post_import_tasks(project, request.user)\n    # Build-isolated builds are dispatched by ``admit_queued_builds``,\n    # running ``update_docs`` too would build it twice on two builders.\n    if not project.has_feature(Feature.USE_BUILD_ISOLATED):\n        tasks.append(update_docs)\n    if tasks:\n        chain(*tasks).apply_async()\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/readthedocs/readthedocs.org/blob/38dd30b02babe5890d38d2bb488f08cfeb97cf3c/readthedocs/projects/views/mixins.py#L99-L135",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F140"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20celery%20for%20async%20scheduler%20cleanup%2C%20worker-pool%20startup%20and%20model-backed%20periodic%20due%20checks&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F128"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "# tasks.py\nfrom celery import Celery\n\napp = Celery(\"tasks\", broker=\"redis://localhost:6379/0\")\n\n@app.task\ndef add(x, y):\n    return x + y\n\n# producer.py\nimport tasks\n\nresult = tasks.add.delay(1, 2)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://docs.celeryq.dev/en/stable/getting-started/first-steps-with-celery.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "periodic-tasks.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F133"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "apscheduler",
          "name": [
            {
              "t": "fact",
              "fact": "F143"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/agronholm/apscheduler"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/APScheduler"
            },
            {
              "label": "Docs",
              "href": "https://apscheduler.readthedocs.io/en/3.x/userguide.html"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F38"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F144"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F150"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F146"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F145"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://apscheduler.readthedocs.io/en/3.x/userguide.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F143"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F39"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F40"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F41"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F42"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F43"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F44"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F45"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F46"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F156"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F157"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/python-telegram-bot/python-telegram-bot",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F156"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def __init__(self) -> None:\n    if not APS_AVAILABLE:\n        raise RuntimeError(\n            \"To use `JobQueue`, PTB must be installed via `pip install \"\n            '\"python-telegram-bot[job-queue]\"`.'\n        )\n\n    self._application: weakref.ReferenceType[Application] | None = None\n    self._executor = AsyncIOExecutor()\n    self.scheduler: \"AsyncIOScheduler\" = AsyncIOScheduler(  # noqa: UP037\n        **self.scheduler_configuration\n    )\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/python-telegram-bot/python-telegram-bot/blob/41e3633bd1b4e51693ee57059828a59a9773618a/src/telegram/ext/_jobqueue.py#L116-L127",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F155"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20APScheduler%20for%20async%20scheduler%20cleanup%2C%20worker-pool%20startup%20and%20model-backed%20periodic%20due%20checks&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F143"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from apscheduler.schedulers.blocking import BlockingScheduler\n\ndef tick():\n    print(\"tick\")\n\nscheduler = BlockingScheduler()\nscheduler.add_job(tick, \"interval\", seconds=60)\nscheduler.start()\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://apscheduler.readthedocs.io/en/3.x/userguide.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "background.py"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F148"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "huey",
          "name": [
            {
              "t": "fact",
              "fact": "F158"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/coleifer/huey"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/huey"
            },
            {
              "label": "Docs",
              "href": "https://huey.readthedocs.io/en/latest/guide.html"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F165"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F159"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F167"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F161"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F160"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://huey.readthedocs.io/en/latest/guide.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F158"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "# tasks.py\nfrom huey import SqliteHuey\n\nhuey = SqliteHuey(\"demo\", filename=\"huey.db\")\n\n@huey.task()\ndef add(x, y):\n    return x + y\n\n# producer.py\nimport tasks\n\nresult = tasks.add(1, 2)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://huey.readthedocs.io/en/latest/guide.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "guide.html"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=huey%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "Find projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F158"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F163"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "rq",
          "name": [
            {
              "t": "fact",
              "fact": "F171"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/rq/rq"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/rq"
            },
            {
              "label": "Docs",
              "href": "https://python-rq.org/docs/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F63"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F172"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F178"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F174"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F173"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://python-rq.org/docs/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F171"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F64"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F65"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F66"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F67"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F68"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F69"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F70"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F71"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F184"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F185"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/frappe/frappe",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F184"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def start_worker_pool(\n\tqueue: str | None = None,\n\tnum_workers: int = 1,\n\tquiet: bool = False,\n\tburst: bool = False,\n) -> NoReturn:\n\t\"\"\"Start worker pool with specified number of workers.\n\n\tWARNING: This feature is considered \"EXPERIMENTAL\".\n\t\"\"\"\n\t_start_sentry()\n\n\t# If gc.freeze is done then importing modules before forking allows us to share the memory\n\timport filelock  # monitor.flush() takes a filelock inside the forked work horse\n\n\timport frappe.database.query  # sqlparse and indirect imports\n\timport frappe.query_builder  # pypika\n\timport frappe.utils  # common utils\n\timport frappe.utils.safe_exec\n\timport frappe.utils.scheduler\n\timport frappe.utils.typing_validations  # any whitelisted method uses this\n\timport frappe.website.path_resolver  # all the page types and resolver\n\t# end: module pre-loading\n\n\tredis_connection = get_redis_conn()\n\n\tif queue:\n\t\tqueue = [q.strip() for q in queue.split(\",\")]\n\tqueues = get_queue_list(queue, build_queue_name=True)\n\n\tif os.environ.get(\"CI\"):\n\t\tsetup_loghandlers(\"ERROR\")\n\n\tset_niceness()\n\tlogging_level = \"INFO\"\n\tif quiet:\n\t\tlogging_level = \"WARNING\"\n\n\t# TODO: Make this true by default eventually. It's limited to RQ WorkerPool\n\tif sbool(os.environ.get(\"FRAPPE_BACKGROUND_WORKERS_NOFORK\", False)):\n\t\tworker_klass = FrappeWorkerNoFork\n\telse:\n\t\timport multiprocessing\n\n\t\tmultiprocessing.set_start_method(\"fork\", force=True)\n\t\tworker_klass = FrappeWorker\n\n\tpool = WorkerPool(\n\t\tqueues=queues,\n\t\tconnection=redis_connection,\n\t\tnum_workers=num_workers,\n\t\tworker_class=worker_klass,\n\t)\n\tpool.start(logging_level=logging_level, burst=burst)\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/frappe/frappe/blob/151dc461cc90409b0fb75b36b34a619bdaa95f45/frappe/utils/background_jobs.py#L523-L576",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F183"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20rq%20for%20async%20scheduler%20cleanup%2C%20worker-pool%20startup%20and%20model-backed%20periodic%20due%20checks&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F171"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from redis import Redis\nfrom rq import Queue\n\nqueue = Queue(connection=Redis())\njob = queue.enqueue(\"math.floor\", 2.7)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://python-rq.org/docs/",
                  "label": [
                    {
                      "t": "text",
                      "text": "docs.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F176"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "schedule",
          "name": [
            {
              "t": "fact",
              "fact": "F186"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/dbader/schedule"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/schedule"
            },
            {
              "label": "Docs",
              "href": "https://schedule.readthedocs.io/en/stable/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F88"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F187"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F193"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F189"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F188"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://schedule.readthedocs.io/en/stable/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F186"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F89"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F90"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F91"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F92"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F93"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F94"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F95"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F96"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F199"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F200"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/freqtrade/freqtrade",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F199"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def __init__(self, config: Config) -> None:\n    \"\"\"\n    Init all variables and objects the bot needs to work\n    :param config: configuration dict, you can use Configuration.get_config()\n    to get the config dict.\n    \"\"\"\n    self.active_pair_whitelist: list[str] = []\n\n    # Init bot state\n    self.state = State.STOPPED\n\n    # Init objects\n    self.config = config\n    exchange_config: ExchangeConfig = deepcopy(config[\"exchange\"])\n    # Remove credentials from original exchange config to avoid accidental credential exposure\n    remove_exchange_credentials(config[\"exchange\"], True)\n\n    self.exchange = ExchangeResolver.load_exchange(\n        self.config, exchange_config=exchange_config, load_leverage_tiers=True\n    )\n\n    self.strategy: IStrategy = StrategyResolver.load_strategy(self.config)\n\n    # Check config consistency here since strategies can set certain options\n    validate_config_consistency(config)\n    # Re-validate exchange compatibility\n    self.exchange.validate_config(self.config)\n\n    init_db(self.config[\"db_url\"])\n\n    self.wallets = Wallets(self.config, self.exchange)\n\n    PairLocks.timeframe = self.config[\"timeframe\"]\n\n    self.trading_mode: TradingMode = self.config.get(\"trading_mode\", TradingMode.SPOT)\n    self.margin_mode: MarginMode = self.config.get(\"margin_mode\", MarginMode.NONE)\n    self.last_process: datetime | None = None\n\n    # RPC runs in separate threads, can start handling external commands just after\n    # initialization, even before Freqtradebot has a chance to start its throttling,\n    # so anything in the Freqtradebot instance should be ready (initialized), including\n    # the initial state of the bot.\n    # Keep this at the end of this initialization method.\n    self.rpc: RPCManager = RPCManager(self)\n\n    self.dataprovider = DataProvider(self.config, self.exchange, rpc=self.rpc)\n    self.pairlists = PairListManager(self.exchange, self.config, self.dataprovider)\n\n    self.dataprovider.add_pairlisthandler(self.pairlists)\n\n    # Attach Dataprovider to strategy instance\n    self.strategy.dp = self.dataprovider\n    # Attach Wallets to strategy instance\n    self.strategy.wallets = self.wallets\n\n    # Init ExternalMessageConsumer if enabled\n    self.emc = (\n        ExternalMessageConsumer(self.config, self.dataprovider)\n        if self.config.get(\"external_message_consumer\", {}).get(\"enabled\", False)\n        else None\n    )\n\n    logger.info(\"Starting initial pairlist refresh\")\n    with MeasureTime(\n        lambda duration, _: logger.info(f\"Initial Pairlist refresh took {duration:.2f}s\"), 0\n    ):\n        self.active_pair_whitelist = self._refresh_active_whitelist()\n\n    # Set initial bot state from config\n    initial_state = self.config.get(\"initial_state\")\n    self.state = State[initial_state.upper()] if initial_state else State.STOPPED\n\n    # Protect exit-logic from forcesell and vice versa\n    self._exit_lock = Lock()\n    timeframe_secs = timeframe_to_seconds(self.strategy.timeframe)\n    self._exit_reason_cache = PeriodicCache(100, ttl=timeframe_secs)\n    LoggingMixin.__init__(self, logger, timeframe_secs)\n\n    self._schedule = Scheduler()\n\n    if self.trading_mode == TradingMode.FUTURES:\n\n        def update():\n            self.update_funding_fees()\n            self.update_all_liquidation_prices()\n            self.wallets.update()\n\n        # This would be more efficient if scheduled in utc time, and performed at each\n        # funding interval, specified by funding_fee_times on the exchange classes\n        # However, this reduces the precision - and might therefore lead to problems.\n        for time_slot in range(0, 24):\n            for minutes in [1, 31]:\n                t = str(time(time_slot, minutes, 2))\n                self._schedule.every().day.at(t).do(update)\n\n    self._schedule.every().day.at(\"00:02\").do(self.exchange.ws_connection_reset)\n\n    self.strategy.ft_bot_start()\n    # Initialize protections AFTER bot start - otherwise parameters are not loaded.\n    self.protections = ProtectionManager(self.config, self.strategy.protections)\n\n    def log_took_too_long(duration: float, time_limit: float):\n        logger.warning(\n            f\"Strategy analysis took {duration:.2f}s, more than 25% of the timeframe \"\n            f\"({time_limit:.2f}s). This can lead to delayed orders and missed signals.\"\n            \"Consider either reducing the amount of work your strategy performs \"\n            \"or reduce the amount of pairs in the Pairlist.\"\n        )\n\n    self._measure_execution = MeasureTime(log_took_too_long, timeframe_secs * 0.25)\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/freqtrade/freqtrade/blob/797ea46bb3b62ba8d0ca39b038610d82eea5be28/freqtrade/freqtradebot.py",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F198"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20schedule%20for%20async%20scheduler%20cleanup%2C%20worker-pool%20startup%20and%20model-backed%20periodic%20due%20checks&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F186"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import time\nimport schedule\n\ndef tick():\n    print(\"tick\")\n\nschedule.every(10).seconds.do(tick)\nwhile True:\n    schedule.run_pending()\n    time.sleep(1)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://schedule.readthedocs.io/en/stable/",
                  "label": [
                    {
                      "t": "text",
                      "text": "stable.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F191"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "arq",
          "name": [
            {
              "t": "fact",
              "fact": "F201"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/python-arq/arq"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/arq"
            },
            {
              "label": "Docs",
              "href": "https://arq-docs.helpmanual.io/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F208"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F202"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F210"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F204"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F203"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://arq-docs.helpmanual.io/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F201"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F216"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F217"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/zylon-ai/private-gpt",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F216"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "async def _abort_job(*, job_id: str, queue_name: str, timeout: int) -> bool:\n    redis = await _get_pool()\n    job = Job(\n        job_id,\n        redis=redis,\n        _queue_name=queue_name,\n    )\n    try:\n        return await job.abort(timeout=timeout)\n    except TimeoutError:\n        logger.warning(\n            \"Timed out confirming abort for job_id=%s queue=%s\",\n            job_id,\n            queue_name,\n        )\n        return False\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/zylon-ai/private-gpt/blob/9d37a133f1d50e9b10ed527ce198ffd7ded1af70/private_gpt/arq/enqueue.py#L117-L132",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F215"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=arq%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F201"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import asyncio\nfrom arq import create_pool\nfrom arq.connections import RedisSettings\n\nasync def add(ctx, x, y):\n    return x + y\n\nclass WorkerSettings:\n    functions = [add]\n\nasync def main():\n    redis = await create_pool(RedisSettings())\n    try:\n        await redis.enqueue_job(\"add\", 1, 2)\n    finally:\n        await redis.aclose()\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://arq-docs.helpmanual.io/",
                  "label": [
                    {
                      "t": "text",
                      "text": "index.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F206"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "taskiq",
          "name": [
            {
              "t": "fact",
              "fact": "F218"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/taskiq-python/taskiq"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/taskiq"
            },
            {
              "label": "Docs",
              "href": "https://taskiq-python.github.io/guide/getting-started.html"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F225"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F219"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F227"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F221"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F220"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://taskiq-python.github.io/guide/getting-started.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F218"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F233"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F234"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/TeKrop/overfast-api",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F233"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "async def enqueue(\n        self,\n        task_name: str,\n        *,\n        job_id: str | None = None,\n    ) -> str:\n        \"\"\"Dispatch a job to the taskiq worker, skipping duplicates.\n\n        Uses ``SET NX`` to atomically claim the dedup slot before kicking the\n        task by name (``task_name`` must match a ``@broker.task(task_name=...)``\n        in ``app/worker.py``).  If the slot is already taken the call is a no-op.\n        The ``job_id`` is passed to the task as its first positional argument.\n        \"\"\"\n        effective_id = job_id or task_name\n\n        try:\n            claimed = await self._valkey.set(\n                f\"{JOB_KEY_PREFIX}{effective_id}\",\n                \"pending\",\n                nx=True,\n                ex=settings.worker_job_timeout,\n            )\n            if not claimed:\n                logger.debug(\"[ValkeyTaskQueue] Already queued: {}\", effective_id)\n                return effective_id\n\n            await AsyncKicker(task_name, broker, {}).kiq(effective_id)\n            if settings.prometheus_enabled:\n                background_refresh_triggered_total.labels(\n                    entity_type=task_name.removeprefix(\"refresh_\")\n                ).inc()\n            logger.debug(\n                \"[ValkeyTaskQueue] Enqueued {} (job_id={})\", task_name, effective_id\n            )\n        except Exception as exc:  # noqa: BLE001\n            logger.warning(\"[ValkeyTaskQueue] Failed to enqueue {}: {}\", task_name, exc)\n\n        return effective_id\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/TeKrop/overfast-api/blob/c9a632a5fe2b257a66eab7c0b3365d451e357a88/app/adapters/tasks/valkey_task_queue.py#L46-L83",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F232"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=taskiq%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F218"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import asyncio\nfrom taskiq import InMemoryBroker\n\nbroker = InMemoryBroker()\n\n@broker.task\nasync def add_one(value: int) -> int:\n    return value + 1\n\nasync def main():\n    await broker.startup()\n    try:\n        task = await add_one.kiq(1)\n        result = await task.wait_result(timeout=2)\n        print(result.return_value)\n    finally:\n        await broker.shutdown()\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://taskiq-python.github.io/guide/getting-started.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "getting-started.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F223"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "dramatiq",
          "name": [
            {
              "t": "fact",
              "fact": "F235"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/Bogdanp/dramatiq"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/dramatiq"
            },
            {
              "label": "Docs",
              "href": "https://dramatiq.io/guide.html"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F242"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F236"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F244"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F238"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F237"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://dramatiq.io/guide.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F235"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F250"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F251"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/polarsource/polar",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F250"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def get_broker(*, database: bool = True) -> dramatiq.Broker:\n    retry = Retry(default_backoff(), retries=50)\n    redis_pool = redis.ConnectionPool.from_url(\n        settings.redis_url,\n        client_name=f\"{settings.ENV.value}.worker.dramatiq\",\n        retry=retry,\n        retry_on_error=REDIS_RETRY_ON_ERRROR,\n        socket_timeout=10,\n        socket_connect_timeout=3,\n    )\n\n    result_backend = ResultsBackend(\n        encoder=JSONEncoder(),\n        client=SyncFailoverRedis(\n            connection_pool=redis.ConnectionPool.from_url(\n                settings.redis_url,\n                retry=retry,\n                retry_on_error=REDIS_RETRY_ON_ERRROR,\n                socket_timeout=10,\n                socket_connect_timeout=3,\n            )\n        ),\n    )\n    rate_limiter_backend = RateLimiterBackend(\n        client=SyncFailoverRedis(\n            connection_pool=redis.ConnectionPool.from_url(\n                settings.redis_url,\n                retry=retry,\n                retry_on_error=REDIS_RETRY_ON_ERRROR,\n                socket_timeout=10,\n                socket_connect_timeout=3,\n            )\n        )\n    )\n\n    middleware_list = [\n        # Infrastructure & async support\n        middleware.ShutdownNotifications(),\n        MonitoredAsyncIO(),\n        # Results backend for pipeline/group support\n        Results(backend=result_backend, result_ttl=60_000),\n        # Group completion callbacks for orchestrating task sequences\n        GroupCallbacks(rate_limiter_backend),\n        # Resource lifecycle (worker boot/shutdown)\n        *([SQLAlchemyMiddleware()] if database else []),\n        RedisMiddleware(),\n        HTTPXMiddleware(),\n        HealthMiddleware(database=database),\n        scheduler_middleware,\n        # Observability (outer layer for message processing)\n        LogContextMiddleware(),\n        LogfireMiddleware(),\n        PrometheusMiddleware(),\n        # Message flow control\n        DebounceMiddleware(redis_pool),\n        # Retry & execution control (MaxRetries must precede Retries)\n        OperationalErrorMiddleware(),\n        MaxRetriesMiddleware(),\n        middleware.Retries(\n            max_retries=settings.WORKER_MAX_RETRIES,\n            min_backoff=settings.WORKER_MIN_BACKOFF_MILLISECONDS,\n        ),\n        middleware.AgeLimit(),\n        middleware.TimeLimit(time_limit=TASK_TIME_LIMIT_DEFAULT_MS),\n        middleware.CurrentMessage(),\n    ]\n\n    broker = RoutingRedisBroker(\n        connection_pool=redis_pool,\n        client=SyncFailoverRedis(connection_pool=redis_pool),\n        middleware=middleware_list,\n        dead_message_ttl=3600 * 1000,  # 1 hour in milliseconds\n    )\n\n    return broker\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/polarsource/polar/blob/b5adc13284ed5aca994a1959543b08187ce2cabc/server/polar/worker/_broker.py#L213-L287",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F249"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=dramatiq%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F235"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "# tasks.py\nimport dramatiq\nfrom dramatiq.brokers.redis import RedisBroker\n\ndramatiq.set_broker(RedisBroker(url=\"redis://localhost:6379/0\"))\n\n@dramatiq.actor\ndef add(x, y):\n    return x + y\n\n# producer.py\nimport tasks\n\nmessage = tasks.add.send(1, 2)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://dramatiq.io/guide.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "guide.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F240"
            }
          ]
        }
      ]
    }
  ],
  "questions": [
    {
      "q": "Which Python job scheduler should I use?",
      "a": [
        {
          "t": "link",
          "href": "#apscheduler",
          "label": [
            {
              "t": "text",
              "text": "APScheduler"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits cron, interval, and one-off jobs inside a running application. "
        },
        {
          "t": "link",
          "href": "#celery",
          "label": [
            {
              "t": "text",
              "text": "Celery"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits periodic tasks that run on separate workers. "
        },
        {
          "t": "link",
          "href": "#schedule",
          "label": [
            {
              "t": "text",
              "text": "schedule"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits small scripts with an in-process polling loop."
        }
      ]
    },
    {
      "q": "What is APScheduler?",
      "a": [
        {
          "t": "link",
          "href": "#apscheduler",
          "label": [
            {
              "t": "text",
              "text": "APScheduler"
            }
          ]
        },
        {
          "t": "text",
          "text": " schedules Python jobs with date, interval, and cron triggers inside an application. Optional job stores keep jobs across restarts."
        }
      ]
    },
    {
      "q": "What is Celery beat?",
      "a": [
        {
          "t": "text",
          "text": "Celery beat is the scheduler that submits periodic tasks to "
        },
        {
          "t": "link",
          "href": "#celery",
          "label": [
            {
              "t": "text",
              "text": "Celery"
            }
          ]
        },
        {
          "t": "text",
          "text": " workers at set intervals or cron times."
        }
      ]
    },
    {
      "q": "What is Dramatiq?",
      "a": [
        {
          "t": "link",
          "href": "#dramatiq",
          "label": [
            {
              "t": "text",
              "text": "Dramatiq"
            }
          ]
        },
        {
          "t": "text",
          "text": " is a background task processing library that runs Python functions on workers through a message broker."
        }
      ]
    },
    {
      "q": "How do I run a cron job in Python?",
      "a": [
        {
          "t": "link",
          "href": "#apscheduler",
          "label": [
            {
              "t": "text",
              "text": "APScheduler"
            }
          ]
        },
        {
          "t": "text",
          "text": " runs cron-style triggers inside a Python process. "
        },
        {
          "t": "link",
          "href": "#celery",
          "label": [
            {
              "t": "text",
              "text": "Celery"
            }
          ]
        },
        {
          "t": "text",
          "text": " beat and the "
        },
        {
          "t": "link",
          "href": "#rq",
          "label": [
            {
              "t": "text",
              "text": "RQ"
            }
          ]
        },
        {
          "t": "text",
          "text": " CronScheduler run them for jobs that execute on separate workers."
        }
      ]
    }
  ],
  "facts": {
    "F1": {
      "label": "Library name, celery",
      "display": "Celery",
      "asOf": "2026-11-17"
    },
    "F2": {
      "label": "Monthly downloads, celery",
      "display": "50.7M",
      "asOf": "2026-11-16"
    },
    "F3": {
      "label": "License, celery",
      "display": "BSD-3-Clause",
      "asOf": "2026-11-17"
    },
    "F4": {
      "label": "Package release, celery",
      "display": "5.7.0, Nov 2026",
      "asOf": "2026-11-05"
    },
    "F5": {
      "label": "Package release date, celery",
      "display": "Nov 2026",
      "asOf": "2026-11-05"
    },
    "F6": {
      "label": "Repository stars, celery",
      "display": "29.2K",
      "asOf": "2026-11-17"
    },
    "F7": {
      "label": "Recurring jobs, celery",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F8": {
      "label": "Cron schedules, celery",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F9": {
      "label": "Persistent schedules, celery",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F10": {
      "label": "Background workers, celery",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F11": {
      "label": "Install, celery",
      "display": "pip install celery",
      "asOf": "2026-11-17"
    },
    "F12": {
      "label": "What it does, celery",
      "display": "Schedules periodic tasks with beat and executes them on worker nodes.",
      "asOf": "2026-11-17"
    },
    "F13": {
      "label": "strengths lead, celery",
      "display": "Separates scheduling from task execution",
      "asOf": "2026-11-17"
    },
    "F14": {
      "label": "strengths, celery",
      "display": "Let beat enqueue periodic tasks for worker nodes to execute.",
      "asOf": "2026-11-17"
    },
    "F15": {
      "label": "strengths lead, celery",
      "display": "Supports cron-style periodic schedules",
      "asOf": "2026-11-17"
    },
    "F16": {
      "label": "strengths, celery",
      "display": "Use crontab schedules for tasks that run at chosen calendar times.",
      "asOf": "2026-11-17"
    },
    "F17": {
      "label": "limitations lead, celery",
      "display": "Each schedule needs one beat",
      "asOf": "2026-11-17"
    },
    "F18": {
      "label": "limitations, celery",
      "display": "Run one scheduler for each schedule to avoid duplicate task submissions.",
      "asOf": "2026-11-17"
    },
    "F19": {
      "label": "limitations lead, celery",
      "display": "Periodic tasks can overlap",
      "asOf": "2026-11-17"
    },
    "F20": {
      "label": "limitations, celery",
      "display": "Use a lock when a periodic task can outlast its interval.",
      "asOf": "2026-11-17"
    },
    "F21": {
      "label": "Quickstart, celery",
      "display": "from celery import Celery\nfrom celery.schedules import crontab\n\napp = Celery()\n\n@app.on_after_configure.connect\ndef setup_periodic_tasks(sender: Celery, **kwargs):\n    # Calls test('hello') every 10 seconds.\n    sender.add_periodic_task(10.0, test.s('hello'), name='add every 10')\n\n    # Calls test('hello') every 30 seconds.\n    # It uses the same signature of previous task, an explicit name is\n    # defined to avoid this task replacing the previous one defined.\n    sender.add_periodic_task(30.0, test.s('hello'), name='add every 30')\n\n    # Calls test('world') every 30 seconds\n    sender.add_periodic_task(30.0, test.s('world'), expires=10)\n\n    # Executes every Monday morning at 7:30 a.m.\n    sender.add_periodic_task(\n        crontab(hour=7, minute=30, day_of_week=1),\n        test.s('Happy Mondays!'),\n    )\n\n@app.task\ndef test(arg):\n    print(arg)\n\n@app.task\ndef add(x, y):\n    z = x + y\n    print(z)\n\n",
      "asOf": "2026-11-17"
    },
    "F22": {
      "label": "Project function, celery",
      "display": "def is_due(self):\n    if not self.model.enabled:\n        # 5 second delay for re-enable.\n        return schedules.schedstate(False, 5.0)\n\n    # START DATE: only run after the `start_time`, if one exists.\n    if self.model.start_time is not None:\n        now = self._default_now()\n        if getattr(settings, 'DJANGO_CELERY_BEAT_TZ_AWARE', True):\n            now = maybe_make_aware(self._default_now())\n        if now < self.model.start_time:\n            # The datetime is before the start date - don't run.\n            # send a delay to retry on start_time\n            current_tz = now.tzinfo\n            start_time = self.model.due_start_time(current_tz)\n            time_remaining = start_time - now\n            delay = math.ceil(time_remaining.total_seconds())\n\n            return schedules.schedstate(False, delay)\n\n    # EXPIRED TASK: Disable task when expired\n    if self.model.expires is not None:\n        now = self._default_now()\n        if now >= self.model.expires:\n            self._disable(self.model)\n            # Don't recheck\n            return schedules.schedstate(False, NEVER_CHECK_TIMEOUT)\n\n    # ONE OFF TASK: Disable one off tasks after they've ran once\n    if self.model.one_off and self.model.enabled \\\n            and self.model.total_run_count > 0:\n        self.model.enabled = False\n        self.model.total_run_count = 0  # Reset\n        self.model.no_changes = False  # Mark the model entry as changed\n        # Persist only the fields this branch modifies; include last_run_at\n        # because PeriodicTask.save() clears it when enabled=False (see #1069).\n        self.model.save(update_fields=[\n            'enabled', 'total_run_count', 'last_run_at', 'date_changed',\n        ])\n        # Don't recheck\n        return schedules.schedstate(False, NEVER_CHECK_TIMEOUT)\n\n    # CAUTION: make_aware assumes settings.TIME_ZONE for naive datetimes,\n    # while maybe_make_aware assumes utc for naive datetimes\n    tz = self.app.timezone\n    last_run_at_in_tz = maybe_make_aware(self.last_run_at).astimezone(tz)\n    return self.schedule.is_due(last_run_at_in_tz)\n",
      "asOf": "2026-11-17"
    },
    "F23": {
      "label": "Project function reference, celery",
      "display": "schedulers.py · is_due()",
      "asOf": "2026-11-17"
    },
    "F24": {
      "label": "Project repository, celery",
      "display": "celery/django-celery-beat",
      "asOf": "2026-11-17"
    },
    "F25": {
      "label": "Project stars, celery/django-celery-beat",
      "display": "2.0K",
      "asOf": "2026-11-17"
    },
    "F26": {
      "label": "Project push date, celery/django-celery-beat",
      "display": "Nov 2026",
      "asOf": "2026-11-11"
    },
    "F27": {
      "label": "Library name, APScheduler",
      "display": "APScheduler",
      "asOf": "2026-11-17"
    },
    "F28": {
      "label": "Monthly downloads, APScheduler",
      "display": "43.2M",
      "asOf": "2026-11-16"
    },
    "F29": {
      "label": "License, APScheduler",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F30": {
      "label": "Package release, APScheduler",
      "display": "3.11.3, Jun 2026",
      "asOf": "2026-06-28"
    },
    "F31": {
      "label": "Package release date, APScheduler",
      "display": "Jun 2026",
      "asOf": "2026-06-28"
    },
    "F32": {
      "label": "Repository stars, APScheduler",
      "display": "7.7K",
      "asOf": "2026-11-17"
    },
    "F33": {
      "label": "Recurring jobs, APScheduler",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F34": {
      "label": "Cron schedules, APScheduler",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F35": {
      "label": "Persistent schedules, APScheduler",
      "display": "Via plugin",
      "asOf": "2026-11-17"
    },
    "F36": {
      "label": "Background workers, APScheduler",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F37": {
      "label": "Install, APScheduler",
      "display": "pip install APScheduler",
      "asOf": "2026-11-17"
    },
    "F38": {
      "label": "What it does, APScheduler",
      "display": "Schedules Python jobs with date, interval, and cron triggers inside an application.",
      "asOf": "2026-11-17"
    },
    "F39": {
      "label": "strengths lead, APScheduler",
      "display": "Runs inside an existing application",
      "asOf": "2026-11-17"
    },
    "F40": {
      "label": "strengths, APScheduler",
      "display": "Use a background or asyncio scheduler within the application process.",
      "asOf": "2026-11-17"
    },
    "F41": {
      "label": "strengths lead, APScheduler",
      "display": "Exports jobs as JSON",
      "asOf": "2026-11-17"
    },
    "F42": {
      "label": "strengths, APScheduler",
      "display": "Move saved jobs between job stores through an exported JSON document.",
      "asOf": "2026-11-17"
    },
    "F43": {
      "label": "limitations lead, APScheduler",
      "display": "Job stores cannot be shared",
      "asOf": "2026-11-17"
    },
    "F44": {
      "label": "limitations, APScheduler",
      "display": "Give each scheduler its own job store rather than sharing it across processes.",
      "asOf": "2026-11-17"
    },
    "F45": {
      "label": "limitations lead, APScheduler",
      "display": "Persistent jobs need importable functions",
      "asOf": "2026-11-17"
    },
    "F46": {
      "label": "limitations, APScheduler",
      "display": "Use globally accessible callables and serializable arguments with persistent job stores.",
      "asOf": "2026-11-17"
    },
    "F47": {
      "label": "Quickstart, APScheduler",
      "display": "\"\"\"\nDemonstrates how to use the background scheduler to schedule a job that executes on 3 second\nintervals.\n\"\"\"\n\nimport os\nimport time\nfrom datetime import datetime\n\nfrom apscheduler.schedulers.background import BackgroundScheduler\n\n\ndef tick():\n    print(f\"Tick! The time is: {datetime.now()}\")\n\n\nif __name__ == \"__main__\":\n    scheduler = BackgroundScheduler()\n    scheduler.add_job(tick, \"interval\", seconds=3)\n    scheduler.start()\n    print(\"Press Ctrl+{} to exit\".format(\"Break\" if os.name == \"nt\" else \"C\"))\n\n    try:\n        # This is here to simulate application activity (which keeps the main thread alive).\n        while True:\n            time.sleep(2)\n    except (KeyboardInterrupt, SystemExit):\n        # Not strictly necessary if daemonic mode is enabled but should be done if possible\n        scheduler.shutdown()\n",
      "asOf": "2026-11-17"
    },
    "F48": {
      "label": "Project function, APScheduler",
      "display": "def __init__(self) -> None:\n    if not APS_AVAILABLE:\n        raise RuntimeError(\n            \"To use `JobQueue`, PTB must be installed via `pip install \"\n            '\"python-telegram-bot[job-queue]\"`.'\n        )\n\n    self._application: weakref.ReferenceType[Application] | None = None\n    self._executor = AsyncIOExecutor()\n    self.scheduler: \"AsyncIOScheduler\" = AsyncIOScheduler(  # noqa: UP037\n        **self.scheduler_configuration\n    )\n",
      "asOf": "2026-11-17"
    },
    "F49": {
      "label": "Project function reference, APScheduler",
      "display": "_jobqueue.py · __init__()",
      "asOf": "2026-11-17"
    },
    "F50": {
      "label": "Project repository, APScheduler",
      "display": "python-telegram-bot/python-telegram-bot",
      "asOf": "2026-11-17"
    },
    "F51": {
      "label": "Project stars, python-telegram-bot/python-telegram-bot",
      "display": "29.6K",
      "asOf": "2026-11-17"
    },
    "F52": {
      "label": "Project push date, python-telegram-bot/python-telegram-bot",
      "display": "Nov 2026",
      "asOf": "2026-11-15"
    },
    "F53": {
      "label": "Library name, rq",
      "display": "RQ",
      "asOf": "2026-11-17"
    },
    "F54": {
      "label": "Monthly downloads, rq",
      "display": "12.9M",
      "asOf": "2026-11-16"
    },
    "F55": {
      "label": "License, rq",
      "display": "BSD-2-Clause",
      "asOf": "2026-11-17"
    },
    "F56": {
      "label": "Package release, rq",
      "display": "3.0.0, Oct 2026",
      "asOf": "2026-10-28"
    },
    "F57": {
      "label": "Package release date, rq",
      "display": "Oct 2026",
      "asOf": "2026-10-28"
    },
    "F58": {
      "label": "Repository stars, rq",
      "display": "10.7K",
      "asOf": "2026-11-17"
    },
    "F59": {
      "label": "Recurring jobs, rq",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F60": {
      "label": "Cron schedules, rq",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F61": {
      "label": "Background workers, rq",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F62": {
      "label": "Install, rq",
      "display": "pip install rq",
      "asOf": "2026-11-17"
    },
    "F63": {
      "label": "What it does, rq",
      "display": "Queues jobs for background workers backed by Redis or Valkey.",
      "asOf": "2026-11-17"
    },
    "F64": {
      "label": "strengths lead, rq",
      "display": "Schedules jobs through queue APIs",
      "asOf": "2026-11-17"
    },
    "F65": {
      "label": "strengths, rq",
      "display": "Use enqueue_at or enqueue_in for execution at a later time.",
      "asOf": "2026-11-17"
    },
    "F66": {
      "label": "strengths lead, rq",
      "display": "Repeats successful background jobs",
      "asOf": "2026-11-17"
    },
    "F67": {
      "label": "strengths, rq",
      "display": "Configure repeat counts and intervals on queued jobs.",
      "asOf": "2026-11-17"
    },
    "F68": {
      "label": "limitations lead, rq",
      "display": "Failed jobs need retry configuration",
      "asOf": "2026-11-17"
    },
    "F69": {
      "label": "limitations, rq",
      "display": "Use retries separately when a failed repeating job should run again.",
      "asOf": "2026-11-17"
    },
    "F70": {
      "label": "limitations lead, rq",
      "display": "Cron scheduling is still beta",
      "asOf": "2026-11-17"
    },
    "F71": {
      "label": "limitations, rq",
      "display": "Treat CronScheduler as beta when choosing a recurring production scheduler.",
      "asOf": "2026-11-17"
    },
    "F72": {
      "label": "Quickstart, rq",
      "display": "from rq import cron\nfrom myapp import cleanup_temp_files, send_newsletter\n\n# Clean up temporary files every 30 minutes (interval-based)\ncron.register(\n    cleanup_temp_files,\n    queue_name='maintenance',\n    interval=1800  # 30 minutes in seconds\n)\n\n# Send newsletter every Tuesday at 10:30 AM (cron string)\ncron.register(\n    send_newsletter,\n    queue_name='email',\n    args=('weekly_digest',),\n    kwargs={'template': 'newsletter.html'},\n    cron='30 10 * * 2'\n)\n\n",
      "asOf": "2026-11-17"
    },
    "F73": {
      "label": "Project function, rq",
      "display": "def start_worker_pool(\n\tqueue: str | None = None,\n\tnum_workers: int = 1,\n\tquiet: bool = False,\n\tburst: bool = False,\n) -> NoReturn:\n\t# ...\n\t_start_sentry()\n\n\t# If gc.freeze is done then importing modules before forking allows us to share the memory\n\timport filelock  # monitor.flush() takes a filelock inside the forked work horse\n\n\timport frappe.database.query  # sqlparse and indirect imports\n\timport frappe.query_builder  # pypika\n\timport frappe.utils  # common utils\n\timport frappe.utils.safe_exec\n\timport frappe.utils.scheduler\n\timport frappe.utils.typing_validations  # any whitelisted method uses this\n\timport frappe.website.path_resolver  # all the page types and resolver\n\t# end: module pre-loading\n\n\tredis_connection = get_redis_conn()\n\n\tif queue:\n\t\tqueue = [q.strip() for q in queue.split(\",\")]\n\tqueues = get_queue_list(queue, build_queue_name=True)\n\n\tif os.environ.get(\"CI\"):\n\t\tsetup_loghandlers(\"ERROR\")\n\n\tset_niceness()\n\tlogging_level = \"INFO\"\n\tif quiet:\n\t\tlogging_level = \"WARNING\"\n\n\t# TODO: Make this true by default eventually. It's limited to RQ WorkerPool\n\tif sbool(os.environ.get(\"FRAPPE_BACKGROUND_WORKERS_NOFORK\", False)):\n\t\tworker_klass = FrappeWorkerNoFork\n\telse:\n\t\timport multiprocessing\n\n\t\tmultiprocessing.set_start_method(\"fork\", force=True)\n\t\tworker_klass = FrappeWorker\n\n\tpool = WorkerPool(\n\t\tqueues=queues,\n\t\tconnection=redis_connection,\n\t\tnum_workers=num_workers,\n\t\tworker_class=worker_klass,\n\t)\n\tpool.start(logging_level=logging_level, burst=burst)\n",
      "asOf": "2026-11-17"
    },
    "F74": {
      "label": "Project function reference, rq",
      "display": "background_jobs.py · start_worker_pool()",
      "asOf": "2026-11-17"
    },
    "F75": {
      "label": "Project repository, rq",
      "display": "frappe/frappe",
      "asOf": "2026-11-17"
    },
    "F76": {
      "label": "Project stars, frappe/frappe",
      "display": "11.1K",
      "asOf": "2026-11-17"
    },
    "F77": {
      "label": "Project push date, frappe/frappe",
      "display": "Nov 2026",
      "asOf": "2026-11-16"
    },
    "F78": {
      "label": "Library name, schedule",
      "display": "schedule",
      "asOf": "2026-11-17"
    },
    "F79": {
      "label": "Monthly downloads, schedule",
      "display": "6.7M",
      "asOf": "2026-11-16"
    },
    "F80": {
      "label": "License, schedule",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F81": {
      "label": "Package release, schedule",
      "display": "1.2.2, May 2024",
      "asOf": "2024-05-25"
    },
    "F82": {
      "label": "Package release date, schedule",
      "display": "May 2024",
      "asOf": "2024-05-25"
    },
    "F83": {
      "label": "Repository stars, schedule",
      "display": "12.3K",
      "asOf": "2026-11-17"
    },
    "F84": {
      "label": "Recurring jobs, schedule",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F85": {
      "label": "Persistent schedules, schedule",
      "display": "Unsupported",
      "asOf": "2026-11-17"
    },
    "F86": {
      "label": "Background workers, schedule",
      "display": "Unsupported",
      "asOf": "2026-11-17"
    },
    "F87": {
      "label": "Install, schedule",
      "display": "pip install schedule",
      "asOf": "2026-11-17"
    },
    "F88": {
      "label": "What it does, schedule",
      "display": "Runs Python callables periodically through an in-process scheduling loop.",
      "asOf": "2026-11-17"
    },
    "F89": {
      "label": "strengths lead, schedule",
      "display": "Schedules recurring Python callables",
      "asOf": "2026-11-17"
    },
    "F90": {
      "label": "strengths, schedule",
      "display": "Express periodic jobs through intervals, weekdays, and time-of-day helpers.",
      "asOf": "2026-11-17"
    },
    "F91": {
      "label": "strengths lead, schedule",
      "display": "Avoids extra scheduler processes",
      "asOf": "2026-11-17"
    },
    "F92": {
      "label": "strengths, schedule",
      "display": "Run the scheduling loop inside the application without external package dependencies.",
      "asOf": "2026-11-17"
    },
    "F93": {
      "label": "limitations lead, schedule",
      "display": "Schedules disappear after restart",
      "asOf": "2026-11-17"
    },
    "F94": {
      "label": "limitations, schedule",
      "display": "Register jobs again when the application starts.",
      "asOf": "2026-11-17"
    },
    "F95": {
      "label": "limitations lead, schedule",
      "display": "Long jobs delay the loop",
      "asOf": "2026-11-17"
    },
    "F96": {
      "label": "limitations, schedule",
      "display": "Move long-running work off the main scheduling thread.",
      "asOf": "2026-11-17"
    },
    "F97": {
      "label": "Quickstart, schedule",
      "display": "import schedule\nimport time\n\ndef job():\n    print(\"I'm working...\")\n\nschedule.every(10).minutes.do(job)\nschedule.every().hour.do(job)\nschedule.every().day.at(\"10:30\").do(job)\nschedule.every().monday.do(job)\nschedule.every().wednesday.at(\"13:15\").do(job)\nschedule.every().day.at(\"12:42\", \"Europe/Amsterdam\").do(job)\nschedule.every().minute.at(\":17\").do(job)\n\nwhile True:\n    schedule.run_pending()\n    time.sleep(1)\n\n",
      "asOf": "2026-11-17"
    },
    "F98": {
      "label": "Developer need",
      "display": "Scheduling inside an async application",
      "asOf": "2026-11-17"
    },
    "F99": {
      "label": "Why choose APScheduler",
      "display": "background and asyncio scheduler variants",
      "asOf": "2026-11-17"
    },
    "F100": {
      "label": "Developer need in introduction",
      "display": "scheduling inside an async application",
      "asOf": "2026-11-17"
    },
    "F101": {
      "label": "When to consider celery",
      "display": "scheduled work should execute on separate worker nodes",
      "asOf": "2026-11-17"
    },
    "F102": {
      "label": "Developer need",
      "display": "A simple in-process scheduling loop",
      "asOf": "2026-11-17"
    },
    "F103": {
      "label": "Why choose schedule",
      "display": "scheduling without extra processes",
      "asOf": "2026-11-17"
    },
    "F104": {
      "label": "Developer need in introduction",
      "display": "a simple in-process scheduling loop",
      "asOf": "2026-11-17"
    },
    "F105": {
      "label": "Developer need",
      "display": "Periodic jobs across worker nodes",
      "asOf": "2026-11-17"
    },
    "F106": {
      "label": "Why choose celery",
      "display": "separate scheduling and worker execution",
      "asOf": "2026-11-17"
    },
    "F107": {
      "label": "Developer need in introduction",
      "display": "periodic jobs across worker nodes",
      "asOf": "2026-11-17"
    },
    "F108": {
      "label": "Developer need",
      "display": "Delayed jobs in an RQ application",
      "asOf": "2026-11-17"
    },
    "F109": {
      "label": "Why choose rq",
      "display": "queue-based delayed execution APIs",
      "asOf": "2026-11-17"
    },
    "F110": {
      "label": "Developer need in introduction",
      "display": "delayed jobs in an RQ application",
      "asOf": "2026-11-17"
    },
    "F111": {
      "label": "When to consider APScheduler",
      "display": "work should stay within an application process",
      "asOf": "2026-11-17"
    },
    "F112": {
      "label": "Page introduction",
      "display": "Python job scheduler libraries let backend developers run application jobs at scheduled times.",
      "asOf": "2026-11-17"
    },
    "F113": {
      "label": "FAQ: What is the best Python job scheduler?",
      "display": "Use APScheduler for in-process background or asyncio scheduling.",
      "asOf": "2026-11-17"
    },
    "F114": {
      "label": "FAQ: What is the best Python job scheduler?",
      "display": "Schedule provides a lightweight in-process loop.",
      "asOf": "2026-11-17"
    },
    "F115": {
      "label": "FAQ: What is the best Python job scheduler?",
      "display": "Celery beat sends periodic work to worker nodes.",
      "asOf": "2026-11-17"
    },
    "F116": {
      "label": "FAQ: What is the best Python job scheduler?",
      "display": "RQ provides delayed execution and repeating-job APIs.",
      "asOf": "2026-11-17"
    },
    "F117": {
      "label": "FAQ: Do scheduled jobs survive application restarts?",
      "display": "Schedule explicitly excludes job persistence.",
      "asOf": "2026-11-17"
    },
    "F118": {
      "label": "FAQ: Do scheduled jobs survive application restarts?",
      "display": "APScheduler supports persistent job stores through configured database integrations.",
      "asOf": "2026-11-17"
    },
    "F119": {
      "label": "FAQ: Do scheduled jobs survive application restarts?",
      "display": "Celery beat has a default file-backed scheduler.",
      "asOf": "2026-11-17"
    },
    "F120": {
      "label": "FAQ: Why do long-running Schedule jobs delay later jobs?",
      "display": "Schedule does not account for job execution duration; move long work off its main scheduling thread.",
      "asOf": "2026-11-17"
    },
    "F121": {
      "label": "FAQ: Can Celery run the same periodic task twice?",
      "display": "Multiple schedulers for the same schedule can submit duplicates.",
      "asOf": "2026-11-17"
    },
    "F122": {
      "label": "FAQ: Can Celery run the same periodic task twice?",
      "display": "An earlier invocation can also overlap the next interval; use an appropriate locking strategy when overlap is unacceptable.",
      "asOf": "2026-11-17"
    },
    "F123": {
      "label": "FAQ: Does RQ Repeat repeat failed jobs?",
      "display": "Repeat applies only after successful completion; use the separate retry mechanism for failed jobs.",
      "asOf": "2026-11-17"
    },
    "F124": {
      "label": "FAQ: Does the RQ cron scheduler execute jobs itself?",
      "display": "CronScheduler enqueues work; separately running RQ workers execute it.",
      "asOf": "2026-11-17"
    },
    "F125": {
      "label": "FAQ: Does the RQ cron scheduler execute jobs itself?",
      "display": "Its current own guide marks CronScheduler as beta.",
      "asOf": "2026-11-17"
    },
    "F126": {
      "label": "FAQ: Can APScheduler instances share the same job store?",
      "display": "APScheduler stable job stores must not be shared between schedulers.",
      "asOf": "2026-11-17"
    },
    "F127": {
      "label": "FAQ: Can I migrate scheduled APScheduler jobs between stores?",
      "display": "Export jobs to a JSON document and import them into the destination scheduler.",
      "asOf": "2026-11-17"
    },
    "F128": {
      "label": "Library name, celery",
      "display": "Celery",
      "asOf": "2026-11-20"
    },
    "F129": {
      "label": "Monthly downloads, celery",
      "display": "53.6M",
      "asOf": "2026-11-20"
    },
    "F130": {
      "label": "License, celery",
      "display": "BSD-3-Clause",
      "asOf": "2026-11-20"
    },
    "F131": {
      "label": "Package release, celery",
      "display": "5.7.0",
      "asOf": "2026-11-20"
    },
    "F132": {
      "label": "Package release date, celery",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F133": {
      "label": "Install, celery",
      "display": "python -m pip install \"celery[redis]==5.7.0\"",
      "asOf": "2026-11-20"
    },
    "F134": {
      "label": "Quickstart, celery",
      "display": "# tasks.py\nfrom celery import Celery\n\napp = Celery(\"tasks\", broker=\"redis://localhost:6379/0\")\n\n@app.task\ndef add(x, y):\n    return x + y\n\n# producer.py\nimport tasks\n\nresult = tasks.add.delay(1, 2)\n",
      "asOf": "2026-11-20"
    },
    "F135": {
      "label": "Repository stars, celery",
      "display": "29.2K",
      "asOf": "2026-11-20"
    },
    "F136": {
      "label": "Recurring schedule support, celery",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F137": {
      "label": "Separate task workers, celery",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F138": {
      "label": "Execution model, celery",
      "display": "Distributed worker queue with built-in beat periodic submission and broker/back-end ecosystem.",
      "asOf": "2026-11-20"
    },
    "F139": {
      "label": "Project function, celery",
      "display": "def finish_import_project(self, request, project):\n    \"\"\"\n    Perform last steps to import a project into Read the Docs.\n\n    - Add the user from request as maintainer\n    - Run extra tasks that are needed before building the project\n    - Trigger the initial build\n\n    Direct upload projects skip the last two steps:\n    Read the Docs never builds them, and the webhook and SSH key are not needed.\n\n    It requires the Project was already saved into the DB.\n\n    :param request: Django Request object\n    :param project: Project instance just imported (already saved)\n    \"\"\"\n    project.users.add(request.user)\n    log.info(\n        \"Project imported.\",\n        project_slug=project.slug,\n        user_username=request.user.username,\n    )\n\n    if project.is_direct_upload:\n        return None\n\n    update_docs, build = prepare_build(project)\n    if (update_docs, build) == (None, None):\n        return None\n\n    tasks = self._get_post_import_tasks(project, request.user)\n    # Build-isolated builds are dispatched by ``admit_queued_builds``,\n    # running ``update_docs`` too would build it twice on two builders.\n    if not project.has_feature(Feature.USE_BUILD_ISOLATED):\n        tasks.append(update_docs)\n    if tasks:\n        chain(*tasks).apply_async()\n",
      "asOf": "2026-11-20"
    },
    "F140": {
      "label": "Project source file, celery",
      "display": "readthedocs/projects/views/mixins.py",
      "asOf": "2026-11-20"
    },
    "F141": {
      "label": "Project full_name, celery",
      "display": "readthedocs/readthedocs.org",
      "asOf": "2026-11-20"
    },
    "F142": {
      "label": "Project stargazers_count, celery",
      "display": "8.4K",
      "asOf": "2026-11-20"
    },
    "F143": {
      "label": "Library name, APScheduler",
      "display": "APScheduler",
      "asOf": "2026-11-20"
    },
    "F144": {
      "label": "Monthly downloads, APScheduler",
      "display": "44.5M",
      "asOf": "2026-11-20"
    },
    "F145": {
      "label": "License, APScheduler",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F146": {
      "label": "Package release, APScheduler",
      "display": "3.11.3",
      "asOf": "2026-11-20"
    },
    "F147": {
      "label": "Package release date, APScheduler",
      "display": "Jun 2026",
      "asOf": "2026-11-20"
    },
    "F148": {
      "label": "Install, APScheduler",
      "display": "python -m pip install APScheduler==3.11.3",
      "asOf": "2026-11-20"
    },
    "F149": {
      "label": "Quickstart, APScheduler",
      "display": "from apscheduler.schedulers.blocking import BlockingScheduler\n\ndef tick():\n    print(\"tick\")\n\nscheduler = BlockingScheduler()\nscheduler.add_job(tick, \"interval\", seconds=60)\nscheduler.start()\n",
      "asOf": "2026-11-20"
    },
    "F150": {
      "label": "Repository stars, APScheduler",
      "display": "7.7K",
      "asOf": "2026-11-20"
    },
    "F151": {
      "label": "Recurring schedule support, APScheduler",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F152": {
      "label": "Separate task workers, APScheduler",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F153": {
      "label": "Execution model, APScheduler",
      "display": "In-process cron/interval/date scheduling with optional persistent job stores and executors.",
      "asOf": "2026-11-20"
    },
    "F154": {
      "label": "Project function, APScheduler",
      "display": "def __init__(self) -> None:\n    if not APS_AVAILABLE:\n        raise RuntimeError(\n            \"To use `JobQueue`, PTB must be installed via `pip install \"\n            '\"python-telegram-bot[job-queue]\"`.'\n        )\n\n    self._application: weakref.ReferenceType[Application] | None = None\n    self._executor = AsyncIOExecutor()\n    self.scheduler: \"AsyncIOScheduler\" = AsyncIOScheduler(  # noqa: UP037\n        **self.scheduler_configuration\n    )\n",
      "asOf": "2026-11-20"
    },
    "F155": {
      "label": "Project source file, APScheduler",
      "display": "src/telegram/ext/_jobqueue.py",
      "asOf": "2026-11-20"
    },
    "F156": {
      "label": "Project full_name, APScheduler",
      "display": "python-telegram-bot/python-telegram-bot",
      "asOf": "2026-11-20"
    },
    "F157": {
      "label": "Project stargazers_count, APScheduler",
      "display": "29.6K",
      "asOf": "2026-11-20"
    },
    "F158": {
      "label": "Library name, huey",
      "display": "Huey",
      "asOf": "2026-11-20"
    },
    "F159": {
      "label": "Monthly downloads, huey",
      "display": "15.5M",
      "asOf": "2026-11-20"
    },
    "F160": {
      "label": "License, huey",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F161": {
      "label": "Package release, huey",
      "display": "3.5.4",
      "asOf": "2026-11-20"
    },
    "F162": {
      "label": "Package release date, huey",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F163": {
      "label": "Install, huey",
      "display": "python -m pip install huey==3.5.4",
      "asOf": "2026-11-20"
    },
    "F164": {
      "label": "Quickstart, huey",
      "display": "# tasks.py\nfrom huey import SqliteHuey\n\nhuey = SqliteHuey(\"demo\", filename=\"huey.db\")\n\n@huey.task()\ndef add(x, y):\n    return x + y\n\n# producer.py\nimport tasks\n\nresult = tasks.add(1, 2)\n",
      "asOf": "2026-11-20"
    },
    "F165": {
      "label": "Official description, huey",
      "display": "Runs a small task queue.",
      "asOf": "2026-11-20"
    },
    "F166": {
      "label": "Quickstart source file, huey",
      "display": "guide.html",
      "asOf": "2026-11-20"
    },
    "F167": {
      "label": "Repository stars, huey",
      "display": "6.1K",
      "asOf": "2026-11-20"
    },
    "F168": {
      "label": "Recurring schedule support, huey",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F169": {
      "label": "Separate task workers, huey",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F170": {
      "label": "Execution model, huey",
      "display": "Compact task queue and periodic consumer, with SQLite/Redis/filesystem backends and Django integration.",
      "asOf": "2026-11-20"
    },
    "F171": {
      "label": "Library name, rq",
      "display": "RQ",
      "asOf": "2026-11-20"
    },
    "F172": {
      "label": "Monthly downloads, rq",
      "display": "13.1M",
      "asOf": "2026-11-20"
    },
    "F173": {
      "label": "License, rq",
      "display": "BSD-2-Clause",
      "asOf": "2026-11-20"
    },
    "F174": {
      "label": "Package release, rq",
      "display": "3.0.0",
      "asOf": "2026-11-20"
    },
    "F175": {
      "label": "Package release date, rq",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F176": {
      "label": "Install, rq",
      "display": "python -m pip install rq==3.0.0",
      "asOf": "2026-11-20"
    },
    "F177": {
      "label": "Quickstart, rq",
      "display": "from redis import Redis\nfrom rq import Queue\n\nqueue = Queue(connection=Redis())\njob = queue.enqueue(\"math.floor\", 2.7)\n",
      "asOf": "2026-11-20"
    },
    "F178": {
      "label": "Repository stars, rq",
      "display": "10.7K",
      "asOf": "2026-11-20"
    },
    "F179": {
      "label": "Recurring schedule support, rq",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F180": {
      "label": "Separate task workers, rq",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F181": {
      "label": "Execution model, rq",
      "display": "Redis-backed function jobs, workers/pools, delayed/repeated jobs and a separate CronScheduler.",
      "asOf": "2026-11-20"
    },
    "F182": {
      "label": "Project function, rq",
      "display": "def start_worker_pool(\n\tqueue: str | None = None,\n\tnum_workers: int = 1,\n\tquiet: bool = False,\n\tburst: bool = False,\n) -> NoReturn:\n\t\"\"\"Start worker pool with specified number of workers.\n\n\tWARNING: This feature is considered \"EXPERIMENTAL\".\n\t\"\"\"\n\t_start_sentry()\n\n\t# If gc.freeze is done then importing modules before forking allows us to share the memory\n\timport filelock  # monitor.flush() takes a filelock inside the forked work horse\n\n\timport frappe.database.query  # sqlparse and indirect imports\n\timport frappe.query_builder  # pypika\n\timport frappe.utils  # common utils\n\timport frappe.utils.safe_exec\n\timport frappe.utils.scheduler\n\timport frappe.utils.typing_validations  # any whitelisted method uses this\n\timport frappe.website.path_resolver  # all the page types and resolver\n\t# end: module pre-loading\n\n\tredis_connection = get_redis_conn()\n\n\tif queue:\n\t\tqueue = [q.strip() for q in queue.split(\",\")]\n\tqueues = get_queue_list(queue, build_queue_name=True)\n\n\tif os.environ.get(\"CI\"):\n\t\tsetup_loghandlers(\"ERROR\")\n\n\tset_niceness()\n\tlogging_level = \"INFO\"\n\tif quiet:\n\t\tlogging_level = \"WARNING\"\n\n\t# TODO: Make this true by default eventually. It's limited to RQ WorkerPool\n\tif sbool(os.environ.get(\"FRAPPE_BACKGROUND_WORKERS_NOFORK\", False)):\n\t\tworker_klass = FrappeWorkerNoFork\n\telse:\n\t\timport multiprocessing\n\n\t\tmultiprocessing.set_start_method(\"fork\", force=True)\n\t\tworker_klass = FrappeWorker\n\n\tpool = WorkerPool(\n\t\tqueues=queues,\n\t\tconnection=redis_connection,\n\t\tnum_workers=num_workers,\n\t\tworker_class=worker_klass,\n\t)\n\tpool.start(logging_level=logging_level, burst=burst)\n",
      "asOf": "2026-11-20"
    },
    "F183": {
      "label": "Project source file, rq",
      "display": "frappe/utils/background_jobs.py",
      "asOf": "2026-11-20"
    },
    "F184": {
      "label": "Project full_name, rq",
      "display": "frappe/frappe",
      "asOf": "2026-11-20"
    },
    "F185": {
      "label": "Project stargazers_count, rq",
      "display": "11.1K",
      "asOf": "2026-11-20"
    },
    "F186": {
      "label": "Library name, schedule",
      "display": "schedule",
      "asOf": "2026-11-20"
    },
    "F187": {
      "label": "Monthly downloads, schedule",
      "display": "6.9M",
      "asOf": "2026-11-20"
    },
    "F188": {
      "label": "License, schedule",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F189": {
      "label": "Package release, schedule",
      "display": "1.2.2",
      "asOf": "2026-11-20"
    },
    "F190": {
      "label": "Package release date, schedule",
      "display": "May 2024",
      "asOf": "2026-11-20"
    },
    "F191": {
      "label": "Install, schedule",
      "display": "python -m pip install schedule==1.2.2",
      "asOf": "2026-11-20"
    },
    "F192": {
      "label": "Quickstart, schedule",
      "display": "import time\nimport schedule\n\ndef tick():\n    print(\"tick\")\n\nschedule.every(10).seconds.do(tick)\nwhile True:\n    schedule.run_pending()\n    time.sleep(1)\n",
      "asOf": "2026-11-20"
    },
    "F193": {
      "label": "Repository stars, schedule",
      "display": "12.3K",
      "asOf": "2026-11-20"
    },
    "F194": {
      "label": "Recurring schedule support, schedule",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F195": {
      "label": "Separate task workers, schedule",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F196": {
      "label": "Execution model, schedule",
      "display": "Small in-process recurring callbacks with an explicit polling loop; no durable worker system.",
      "asOf": "2026-11-20"
    },
    "F197": {
      "label": "Project function, schedule",
      "display": "def __init__(self, config: Config) -> None:\n    \"\"\"\n    Init all variables and objects the bot needs to work\n    :param config: configuration dict, you can use Configuration.get_config()\n    to get the config dict.\n    \"\"\"\n    self.active_pair_whitelist: list[str] = []\n\n    # Init bot state\n    self.state = State.STOPPED\n\n    # Init objects\n    self.config = config\n    exchange_config: ExchangeConfig = deepcopy(config[\"exchange\"])\n    # Remove credentials from original exchange config to avoid accidental credential exposure\n    remove_exchange_credentials(config[\"exchange\"], True)\n\n    self.exchange = ExchangeResolver.load_exchange(\n        self.config, exchange_config=exchange_config, load_leverage_tiers=True\n    )\n\n    self.strategy: IStrategy = StrategyResolver.load_strategy(self.config)\n\n    # Check config consistency here since strategies can set certain options\n    validate_config_consistency(config)\n    # Re-validate exchange compatibility\n    self.exchange.validate_config(self.config)\n\n    init_db(self.config[\"db_url\"])\n\n    self.wallets = Wallets(self.config, self.exchange)\n\n    PairLocks.timeframe = self.config[\"timeframe\"]\n\n    self.trading_mode: TradingMode = self.config.get(\"trading_mode\", TradingMode.SPOT)\n    self.margin_mode: MarginMode = self.config.get(\"margin_mode\", MarginMode.NONE)\n    self.last_process: datetime | None = None\n\n    # RPC runs in separate threads, can start handling external commands just after\n    # initialization, even before Freqtradebot has a chance to start its throttling,\n    # so anything in the Freqtradebot instance should be ready (initialized), including\n    # the initial state of the bot.\n    # Keep this at the end of this initialization method.\n    self.rpc: RPCManager = RPCManager(self)\n\n    self.dataprovider = DataProvider(self.config, self.exchange, rpc=self.rpc)\n    self.pairlists = PairListManager(self.exchange, self.config, self.dataprovider)\n\n    self.dataprovider.add_pairlisthandler(self.pairlists)\n\n    # Attach Dataprovider to strategy instance\n    self.strategy.dp = self.dataprovider\n    # Attach Wallets to strategy instance\n    self.strategy.wallets = self.wallets\n\n    # Init ExternalMessageConsumer if enabled\n    self.emc = (\n        ExternalMessageConsumer(self.config, self.dataprovider)\n        if self.config.get(\"external_message_consumer\", {}).get(\"enabled\", False)\n        else None\n    )\n\n    logger.info(\"Starting initial pairlist refresh\")\n    with MeasureTime(\n        lambda duration, _: logger.info(f\"Initial Pairlist refresh took {duration:.2f}s\"), 0\n    ):\n        self.active_pair_whitelist = self._refresh_active_whitelist()\n\n    # Set initial bot state from config\n    initial_state = self.config.get(\"initial_state\")\n    self.state = State[initial_state.upper()] if initial_state else State.STOPPED\n\n    # Protect exit-logic from forcesell and vice versa\n    self._exit_lock = Lock()\n    timeframe_secs = timeframe_to_seconds(self.strategy.timeframe)\n    self._exit_reason_cache = PeriodicCache(100, ttl=timeframe_secs)\n    LoggingMixin.__init__(self, logger, timeframe_secs)\n\n    self._schedule = Scheduler()\n\n    if self.trading_mode == TradingMode.FUTURES:\n\n        def update():\n            self.update_funding_fees()\n            self.update_all_liquidation_prices()\n            self.wallets.update()\n\n        # This would be more efficient if scheduled in utc time, and performed at each\n        # funding interval, specified by funding_fee_times on the exchange classes\n        # However, this reduces the precision - and might therefore lead to problems.\n        for time_slot in range(0, 24):\n            for minutes in [1, 31]:\n                t = str(time(time_slot, minutes, 2))\n                self._schedule.every().day.at(t).do(update)\n\n    self._schedule.every().day.at(\"00:02\").do(self.exchange.ws_connection_reset)\n\n    self.strategy.ft_bot_start()\n    # Initialize protections AFTER bot start - otherwise parameters are not loaded.\n    self.protections = ProtectionManager(self.config, self.strategy.protections)\n\n    def log_took_too_long(duration: float, time_limit: float):\n        logger.warning(\n            f\"Strategy analysis took {duration:.2f}s, more than 25% of the timeframe \"\n            f\"({time_limit:.2f}s). This can lead to delayed orders and missed signals.\"\n            \"Consider either reducing the amount of work your strategy performs \"\n            \"or reduce the amount of pairs in the Pairlist.\"\n        )\n\n    self._measure_execution = MeasureTime(log_took_too_long, timeframe_secs * 0.25)\n",
      "asOf": "2026-11-20"
    },
    "F198": {
      "label": "Project source file, schedule",
      "display": "freqtrade/freqtradebot.py",
      "asOf": "2026-11-20"
    },
    "F199": {
      "label": "Project full_name, schedule",
      "display": "freqtrade/freqtrade",
      "asOf": "2026-11-20"
    },
    "F200": {
      "label": "Project stargazers_count, schedule",
      "display": "57.0K",
      "asOf": "2026-11-20"
    },
    "F201": {
      "label": "Library name, arq",
      "display": "arq",
      "asOf": "2026-11-20"
    },
    "F202": {
      "label": "Monthly downloads, arq",
      "display": "5.6M",
      "asOf": "2026-11-20"
    },
    "F203": {
      "label": "License, arq",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F204": {
      "label": "Package release, arq",
      "display": "0.28.0",
      "asOf": "2026-11-20"
    },
    "F205": {
      "label": "Package release date, arq",
      "display": "Apr 2026",
      "asOf": "2026-11-20"
    },
    "F206": {
      "label": "Install, arq",
      "display": "python -m pip install arq==0.28.0 \"redis>=5.3,<6\"",
      "asOf": "2026-11-20"
    },
    "F207": {
      "label": "Quickstart, arq",
      "display": "import asyncio\nfrom arq import create_pool\nfrom arq.connections import RedisSettings\n\nasync def add(ctx, x, y):\n    return x + y\n\nclass WorkerSettings:\n    functions = [add]\n\nasync def main():\n    redis = await create_pool(RedisSettings())\n    try:\n        await redis.enqueue_job(\"add\", 1, 2)\n    finally:\n        await redis.aclose()\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n",
      "asOf": "2026-11-20"
    },
    "F208": {
      "label": "Official description, arq",
      "display": "Runs job queues in Python with asyncio and Redis.",
      "asOf": "2026-11-20"
    },
    "F209": {
      "label": "Quickstart source file, arq",
      "display": "index.html",
      "asOf": "2026-11-20"
    },
    "F210": {
      "label": "Repository stars, arq",
      "display": "3.0K",
      "asOf": "2026-11-20"
    },
    "F211": {
      "label": "Recurring schedule support, arq",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F212": {
      "label": "Separate task workers, arq",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F213": {
      "label": "Execution model, arq",
      "display": "Asyncio/Redis job workers with native deferred submission, cron configuration, and cooperative abort support.",
      "asOf": "2026-11-20"
    },
    "F214": {
      "label": "Project function, arq",
      "display": "async def _abort_job(*, job_id: str, queue_name: str, timeout: int) -> bool:\n    redis = await _get_pool()\n    job = Job(\n        job_id,\n        redis=redis,\n        _queue_name=queue_name,\n    )\n    try:\n        return await job.abort(timeout=timeout)\n    except TimeoutError:\n        logger.warning(\n            \"Timed out confirming abort for job_id=%s queue=%s\",\n            job_id,\n            queue_name,\n        )\n        return False\n",
      "asOf": "2026-11-20"
    },
    "F215": {
      "label": "Project source file, arq",
      "display": "private_gpt/arq/enqueue.py",
      "asOf": "2026-11-20"
    },
    "F216": {
      "label": "Project full_name, arq",
      "display": "zylon-ai/private-gpt",
      "asOf": "2026-11-20"
    },
    "F217": {
      "label": "Project stargazers_count, arq",
      "display": "57.6K",
      "asOf": "2026-11-20"
    },
    "F218": {
      "label": "Library name, taskiq",
      "display": "Taskiq",
      "asOf": "2026-11-20"
    },
    "F219": {
      "label": "Monthly downloads, taskiq",
      "display": "2.6M",
      "asOf": "2026-11-20"
    },
    "F220": {
      "label": "License, taskiq",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F221": {
      "label": "Package release, taskiq",
      "display": "0.13.0",
      "asOf": "2026-11-20"
    },
    "F222": {
      "label": "Package release date, taskiq",
      "display": "Sep 2026",
      "asOf": "2026-11-20"
    },
    "F223": {
      "label": "Install, taskiq",
      "display": "python -m pip install taskiq==0.13.0",
      "asOf": "2026-11-20"
    },
    "F224": {
      "label": "Quickstart, taskiq",
      "display": "import asyncio\nfrom taskiq import InMemoryBroker\n\nbroker = InMemoryBroker()\n\n@broker.task\nasync def add_one(value: int) -> int:\n    return value + 1\n\nasync def main():\n    await broker.startup()\n    try:\n        task = await add_one.kiq(1)\n        result = await task.wait_result(timeout=2)\n        print(result.return_value)\n    finally:\n        await broker.shutdown()\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n",
      "asOf": "2026-11-20"
    },
    "F225": {
      "label": "Official description, taskiq",
      "display": "Runs a distributed task queue with full async support.",
      "asOf": "2026-11-20"
    },
    "F226": {
      "label": "Quickstart source file, taskiq",
      "display": "getting-started.html",
      "asOf": "2026-11-20"
    },
    "F227": {
      "label": "Repository stars, taskiq",
      "display": "2.4K",
      "asOf": "2026-11-20"
    },
    "F228": {
      "label": "Recurring schedule support, taskiq",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F229": {
      "label": "Separate task workers, taskiq",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F230": {
      "label": "Execution model, taskiq",
      "display": "Async task broker abstraction with a core scheduler/schedule sources; production transports are integrations.",
      "asOf": "2026-11-20"
    },
    "F231": {
      "label": "Project function, taskiq",
      "display": "async def enqueue(\n        self,\n        task_name: str,\n        *,\n        job_id: str | None = None,\n    ) -> str:\n        \"\"\"Dispatch a job to the taskiq worker, skipping duplicates.\n\n        Uses ``SET NX`` to atomically claim the dedup slot before kicking the\n        task by name (``task_name`` must match a ``@broker.task(task_name=...)``\n        in ``app/worker.py``).  If the slot is already taken the call is a no-op.\n        The ``job_id`` is passed to the task as its first positional argument.\n        \"\"\"\n        effective_id = job_id or task_name\n\n        try:\n            claimed = await self._valkey.set(\n                f\"{JOB_KEY_PREFIX}{effective_id}\",\n                \"pending\",\n                nx=True,\n                ex=settings.worker_job_timeout,\n            )\n            if not claimed:\n                logger.debug(\"[ValkeyTaskQueue] Already queued: {}\", effective_id)\n                return effective_id\n\n            await AsyncKicker(task_name, broker, {}).kiq(effective_id)\n            if settings.prometheus_enabled:\n                background_refresh_triggered_total.labels(\n                    entity_type=task_name.removeprefix(\"refresh_\")\n                ).inc()\n            logger.debug(\n                \"[ValkeyTaskQueue] Enqueued {} (job_id={})\", task_name, effective_id\n            )\n        except Exception as exc:  # noqa: BLE001\n            logger.warning(\"[ValkeyTaskQueue] Failed to enqueue {}: {}\", task_name, exc)\n\n        return effective_id\n",
      "asOf": "2026-11-20"
    },
    "F232": {
      "label": "Project source file, taskiq",
      "display": "app/adapters/tasks/valkey_task_queue.py",
      "asOf": "2026-11-20"
    },
    "F233": {
      "label": "Project full_name, taskiq",
      "display": "TeKrop/overfast-api",
      "asOf": "2026-11-20"
    },
    "F234": {
      "label": "Project stargazers_count, taskiq",
      "display": "199",
      "asOf": "2026-11-20"
    },
    "F235": {
      "label": "Library name, dramatiq",
      "display": "Dramatiq",
      "asOf": "2026-11-20"
    },
    "F236": {
      "label": "Monthly downloads, dramatiq",
      "display": "2.5M",
      "asOf": "2026-11-20"
    },
    "F237": {
      "label": "License, dramatiq",
      "display": "LGPL-3.0-or-later",
      "asOf": "2026-11-20"
    },
    "F238": {
      "label": "Package release, dramatiq",
      "display": "2.2.1",
      "asOf": "2026-11-20"
    },
    "F239": {
      "label": "Package release date, dramatiq",
      "display": "Sep 2026",
      "asOf": "2026-11-20"
    },
    "F240": {
      "label": "Install, dramatiq",
      "display": "python -m pip install \"dramatiq[redis]==2.2.1\"",
      "asOf": "2026-11-20"
    },
    "F241": {
      "label": "Quickstart, dramatiq",
      "display": "# tasks.py\nimport dramatiq\nfrom dramatiq.brokers.redis import RedisBroker\n\ndramatiq.set_broker(RedisBroker(url=\"redis://localhost:6379/0\"))\n\n@dramatiq.actor\ndef add(x, y):\n    return x + y\n\n# producer.py\nimport tasks\n\nmessage = tasks.add.send(1, 2)\n",
      "asOf": "2026-11-20"
    },
    "F242": {
      "label": "Official description, dramatiq",
      "display": "Processes background tasks in Python.",
      "asOf": "2026-11-20"
    },
    "F243": {
      "label": "Quickstart source file, dramatiq",
      "display": "guide.html",
      "asOf": "2026-11-20"
    },
    "F244": {
      "label": "Repository stars, dramatiq",
      "display": "5.3K",
      "asOf": "2026-11-20"
    },
    "F245": {
      "label": "Recurring schedule support, dramatiq",
      "display": "Via plugin",
      "asOf": "2026-11-20"
    },
    "F246": {
      "label": "Separate task workers, dramatiq",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F247": {
      "label": "Execution model, dramatiq",
      "display": "Actor worker queue with delayed message delivery and middleware; recurring scheduling needs a companion.",
      "asOf": "2026-11-20"
    },
    "F248": {
      "label": "Project function, dramatiq",
      "display": "def get_broker(*, database: bool = True) -> dramatiq.Broker:\n    retry = Retry(default_backoff(), retries=50)\n    redis_pool = redis.ConnectionPool.from_url(\n        settings.redis_url,\n        client_name=f\"{settings.ENV.value}.worker.dramatiq\",\n        retry=retry,\n        retry_on_error=REDIS_RETRY_ON_ERRROR,\n        socket_timeout=10,\n        socket_connect_timeout=3,\n    )\n\n    result_backend = ResultsBackend(\n        encoder=JSONEncoder(),\n        client=SyncFailoverRedis(\n            connection_pool=redis.ConnectionPool.from_url(\n                settings.redis_url,\n                retry=retry,\n                retry_on_error=REDIS_RETRY_ON_ERRROR,\n                socket_timeout=10,\n                socket_connect_timeout=3,\n            )\n        ),\n    )\n    rate_limiter_backend = RateLimiterBackend(\n        client=SyncFailoverRedis(\n            connection_pool=redis.ConnectionPool.from_url(\n                settings.redis_url,\n                retry=retry,\n                retry_on_error=REDIS_RETRY_ON_ERRROR,\n                socket_timeout=10,\n                socket_connect_timeout=3,\n            )\n        )\n    )\n\n    middleware_list = [\n        # Infrastructure & async support\n        middleware.ShutdownNotifications(),\n        MonitoredAsyncIO(),\n        # Results backend for pipeline/group support\n        Results(backend=result_backend, result_ttl=60_000),\n        # Group completion callbacks for orchestrating task sequences\n        GroupCallbacks(rate_limiter_backend),\n        # Resource lifecycle (worker boot/shutdown)\n        *([SQLAlchemyMiddleware()] if database else []),\n        RedisMiddleware(),\n        HTTPXMiddleware(),\n        HealthMiddleware(database=database),\n        scheduler_middleware,\n        # Observability (outer layer for message processing)\n        LogContextMiddleware(),\n        LogfireMiddleware(),\n        PrometheusMiddleware(),\n        # Message flow control\n        DebounceMiddleware(redis_pool),\n        # Retry & execution control (MaxRetries must precede Retries)\n        OperationalErrorMiddleware(),\n        MaxRetriesMiddleware(),\n        middleware.Retries(\n            max_retries=settings.WORKER_MAX_RETRIES,\n            min_backoff=settings.WORKER_MIN_BACKOFF_MILLISECONDS,\n        ),\n        middleware.AgeLimit(),\n        middleware.TimeLimit(time_limit=TASK_TIME_LIMIT_DEFAULT_MS),\n        middleware.CurrentMessage(),\n    ]\n\n    broker = RoutingRedisBroker(\n        connection_pool=redis_pool,\n        client=SyncFailoverRedis(connection_pool=redis_pool),\n        middleware=middleware_list,\n        dead_message_ttl=3600 * 1000,  # 1 hour in milliseconds\n    )\n\n    return broker\n",
      "asOf": "2026-11-20"
    },
    "F249": {
      "label": "Project source file, dramatiq",
      "display": "server/polar/worker/_broker.py",
      "asOf": "2026-11-20"
    },
    "F250": {
      "label": "Project full_name, dramatiq",
      "display": "polarsource/polar",
      "asOf": "2026-11-20"
    },
    "F251": {
      "label": "Project stargazers_count, dramatiq",
      "display": "10.5K",
      "asOf": "2026-11-20"
    }
  },
  "dataCheckedAt": "2026-11-20",
  "agent": {
    "exaCall": {
      "endpoint": "/search",
      "body": {
        "query": "Best Python job scheduler libraries APScheduler schedule Celery RQ cron recurring jobs code examples",
        "numResults": 5
      },
      "docsUrl": "https://exa.ai/docs/reference/search"
    },
    "calls": []
  }
}
