{
    "mode": "pydoc",
    "parameter": "sched",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/sched/json",
    "generated": "2026-06-02T13:24:36Z",
    "sections": {
        "NAME": {
            "content": "sched - A generally useful event scheduler class.\n",
            "subsections": []
        },
        "MODULE REFERENCE": {
            "content": "https://docs.python.org/3.10/library/sched.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Each instance of this class manages its own queue.\nNo multi-threading is implied; you are supposed to hack that\nyourself, or use a single instance per application.\n\nEach instance is parametrized with two functions, one that is\nsupposed to return the current time, one that is supposed to\nimplement a delay.  You can implement real-time scheduling by\nsubstituting time and sleep from built-in module time, or you can\nimplement simulated time by writing your own functions.  This can\nalso be used to integrate scheduling with STDWIN events; the delay\nfunction is allowed to modify the queue.  Time can be expressed as\nintegers or floating point numbers, as long as it is consistent.\n\nEvents are specified by tuples (time, priority, action, argument, kwargs).\nAs in UNIX, lower priority numbers mean higher priority; in this\nway the queue can be maintained as a priority queue.  Execution of the\nevent means calling the action function, passing it the argument\nsequence in \"argument\" (remember that in Python, multiple function\narguments are be packed in a sequence) and keyword parameters in \"kwargs\".\nThe action function may be an instance method so it\nhas another way to reference private data (besides global variables).\n",
            "subsections": []
        },
        "CLASSES": {
            "content": "builtins.object\nscheduler\n",
            "subsections": [
                {
                    "name": "class scheduler",
                    "content": "|  scheduler(timefunc=<built-in function monotonic>, delayfunc=<built-in function sleep>)\n|\n|  Methods defined here:\n|\n|  init(self, timefunc=<built-in function monotonic>, delayfunc=<built-in function sleep>)\n|      Initialize a new instance, passing the time and delay\n|      functions\n|\n|  cancel(self, event)\n|      Remove an event from the queue.\n|\n|      This must be presented the ID as returned by enter().\n|      If the event is not in the queue, this raises ValueError.\n|\n|  empty(self)\n|      Check whether the queue is empty.\n|\n|  enter(self, delay, priority, action, argument=(), kwargs=<object object at 0x7f02bb6fca00>)\n|      A variant that specifies the time as a relative time.\n|\n|      This is actually the more commonly used interface.\n|\n|  enterabs(self, time, priority, action, argument=(), kwargs=<object object at 0x7f02bb6fca00>)\n|      Enter a new event in the queue at an absolute time.\n|\n|      Returns an ID for the event which can be used to remove it,\n|      if necessary.\n|\n|  run(self, blocking=True)\n|      Execute events until the queue is empty.\n|      If blocking is False executes the scheduled events due to\n|      expire soonest (if any) and then return the deadline of the\n|      next scheduled call in the scheduler.\n|\n|      When there is a positive delay until the first event, the\n|      delay function is called and the event is left in the queue;\n|      otherwise, the event is removed from the queue and executed\n|      (its action function is called, passing it the argument).  If\n|      the delay function returns prematurely, it is simply\n|      restarted.\n|\n|      It is legal for both the delay function and the action\n|      function to modify the queue or to raise an exception;\n|      exceptions are not caught but the scheduler's state remains\n|      well-defined so run() may be called again.\n|\n|      A questionable hack is added to allow other threads to run:\n|      just after an event is executed, a delay of 0 is executed, to\n|      avoid monopolizing the CPU when other threads are also\n|      runnable.\n|\n|  ----------------------------------------------------------------------\n|  Readonly properties defined here:\n|\n|  queue\n|      An ordered list of upcoming events.\n|\n|      Events are named tuples with fields for:\n|          time, priority, action, arguments, kwargs\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                }
            ]
        },
        "DATA": {
            "content": "all = ['scheduler']\n",
            "subsections": []
        },
        "FILE": {
            "content": "/usr/lib/python3.10/sched.py\n\n",
            "subsections": []
        }
    },
    "summary": "sched - A generally useful event scheduler class.",
    "flags": [],
    "examples": [],
    "see_also": []
}