-

scheduling#

+

scheduling#

Generic python scheduler.

-class Scheduler(name)[source]#
-

Bases: object

+class Scheduler(name)[source]# +

Bases: object

Schedule the execution of coroutines and keep track of them.

When instantiating a Scheduler, a name must be provided. This name is used to distinguish the instance’s log messages from other instances. Using the name of the class or module containing @@ -441,79 +445,79 @@ the same ID used to schedule it.

Any exception raised in a scheduled task is logged when the task is done.

-__contains__(task_id)[source]#
-

Return True if a task with the given task_id is currently scheduled.

+__contains__(task_id)[source]# +

Return True if a task with the given task_id is currently scheduled.

Parameters:
-

task_id (Hashable) – The task to look for.

+

task_id (Hashable) – The task to look for.

Return type:
-

bool

+

bool

Returns:
-

True if the task was found.

+

True if the task was found.

-__init__(name)[source]#
+__init__(name)[source]#

Initialize a new Scheduler instance.

Parameters:
-

name (str) – The name of the Scheduler. Used in logging, and namespacing.

+

name (str) – The name of the Scheduler. Used in logging, and namespacing.

-cancel(task_id)[source]#
+cancel(task_id)[source]#

Unschedule the task identified by task_id. Log a warning if the task doesn’t exist.

Parameters:
-

task_id (Hashable) – The task’s unique ID.

+

task_id (Hashable) – The task’s unique ID.

Return type:
-

None

+

None

-cancel_all()[source]#
+cancel_all()[source]#

Unschedule all known tasks.

Return type:
-

None

+

None

-schedule(task_id, coroutine)[source]#
+schedule(task_id, coroutine)[source]#

Schedule the execution of a coroutine.

If a task with task_id already exists, close coroutine instead of scheduling it. This prevents unawaited coroutine warnings. Don’t pass a coroutine that’ll be re-used elsewhere.

Parameters:
    -
  • task_id (Hashable) – A unique ID to create the task with.

  • -
  • coroutine (Coroutine) – The function to be called.

  • +
  • task_id (Hashable) – A unique ID to create the task with.

  • +
  • coroutine (Coroutine) – The function to be called.

Return type:
-

None

+

None

-schedule_at(time, task_id, coroutine)[source]#
+schedule_at(time, task_id, coroutine)[source]#

Schedule coroutine to be executed at the given time.

If time is timezone aware, then use that timezone to calculate now() when subtracting. If time is naïve, then use UTC.

@@ -523,33 +527,33 @@ prevents unawaited coroutine warnings. Don’t pass a coroutine that’ll be re-
Parameters:
    -
  • time (datetime) – The time to start the task.

  • -
  • task_id (Hashable) – A unique ID to create the task with.

  • -
  • coroutine (Coroutine) – The function to be called.

  • +
  • time (datetime) – The time to start the task.

  • +
  • task_id (Hashable) – A unique ID to create the task with.

  • +
  • coroutine (Coroutine) – The function to be called.

Return type:
-

None

+

None

-schedule_later(delay, task_id, coroutine)[source]#
+schedule_later(delay, task_id, coroutine)[source]#

Schedule coroutine to be executed after delay seconds.

If a task with task_id already exists, close coroutine instead of scheduling it. This prevents unawaited coroutine warnings. Don’t pass a coroutine that’ll be re-used elsewhere.

Parameters:
    -
  • delay (int | float) – How long to wait before starting the task.

  • -
  • task_id (Hashable) – A unique ID to create the task with.

  • -
  • coroutine (Coroutine) – The function to be called.

  • +
  • delay (int | float) – How long to wait before starting the task.

  • +
  • task_id (Hashable) – A unique ID to create the task with.

  • +
  • coroutine (Coroutine) – The function to be called.

Return type:
-

None

+

None

@@ -558,24 +562,24 @@ prevents unawaited coroutine warnings. Don’t pass a coroutine that’ll be re-
-create_task(coro, *, suppressed_exceptions=(), event_loop=None, **kwargs)[source]#
-

Wrapper for creating an asyncio.Task which logs exceptions raised in the task.

+create_task(coro, *, suppressed_exceptions=(), event_loop=None, **kwargs)[source]# +

Wrapper for creating an asyncio.Task which logs exceptions raised in the task.

If the event_loop kwarg is provided, the task is created from that event loop, otherwise the running loop is used.

Parameters:
Returns:

The wrapped task.

Return type:
-

asyncio.Task

+

asyncio.Task

@@ -660,10 +664,10 @@ otherwise the running loop is used.

- - - - - + + + + + \ No newline at end of file -- cgit v1.2.3