_emerge.PollScheduler module

class _emerge.PollScheduler.PollScheduler(main=False, event_loop=None)

Bases: object

_can_add_job()
_cleanup()

Cleanup any callbacks that have been registered with the global event loop.

_is_background()
_is_work_scheduled()
_keep_scheduling()
Return type

bool

Returns

True if there may be remaining tasks to schedule, False otherwise.

_loadavg_latency = None
_running_job_count()
_schedule()

Calls _schedule_tasks() and automatically returns early from any recursive calls to this method that the _schedule_tasks() call might trigger. This makes _schedule() safe to call from inside exit listeners. This method always returns True, so that it may be scheduled continuously via EventLoop.timeout_add().

_schedule_tasks()

This is called from inside the _schedule() method, which guarantees the following:

  1. It will not be called recursively.

  2. _terminate_tasks() will not be called while it is running.

  3. The state of the boolean _terminated_tasks variable will not change while it is running.

Unless this method is used to perform user interface updates, or something like that, the first thing it should do is check the state of _terminated_tasks and if that is True then it should return immediately (since there’s no need to schedule anything after _terminate_tasks() has been called).

_terminate_tasks()

Send signals to terminate all tasks. This is called once from _keep_scheduling() or _is_work_scheduled() in the event dispatching thread. It will not be called while the _schedule_tasks() implementation is running, in order to avoid potential interference. All tasks should be cleaned up at the earliest opportunity, but not necessarily before this method returns. Typically, this method will send kill signals and return without waiting for exit status. This allows basic cleanup to occur, such as flushing of buffered output to logs.

_termination_check(retry=False)

Calls _terminate_tasks() if appropriate. It’s guaranteed not to call it while _schedule_tasks() is being called. This method must only be called via the event loop thread.

Parameters

retry (bool) – If True then reschedule if scheduling state prevents immediate termination.

terminate()

Schedules asynchronous, graceful termination of the scheduler at the earliest opportunity.

This method is thread-safe (and safe for signal handlers).