scheduler

Schedulers are the main source of concurrency in RxPython. Every action that happens either periodically, concurrently, or is timed for later execution should be scheduled by the correct Scheduler implementation. Some Schedulers as the Scheduler.currentThread allow for cooperative multitasking, others like the Scheduler.default are used for scheduling on different threads and the ThreadPool.

Instances for Schedulers should NEVER be created manually but instead the static properties on the Scheduler class should be used to get an instance.

class rx.scheduler.Scheduler

Provides a set of static properties to access commonly used Schedulers and implements all the scheduling methods that then use the overrides of the implementation.

now()

Returns the current time.

catchException(handler)

Returns a Scheduler that invokes the handler function if an exception gets raised. If the handler returns False the Exception is reraised.

Long running scheduling

isLongRunning

Returns True if the scheduler implementation supports long running scheduling via scheduleLongRunning() and scheduleLongRunningWithState()

scheduleLongRunning(action)

Schedules action as long running which in the current implementation runs the action on a separate Thread. The action gets as parameter its own rx.disposable.Cancelable on which it can check, if it got disposed.

Actions scheduled as long running are guaranteed to run even if the got canceled befor running.

scheduleLongRunningWithState(state, action)

Schedules action as long running which in the current implementation runs the action on a separate Thread. The action gets as parameter state and its own rx.disposable.Cancelable on which it can check, if it got disposed.

Actions scheduled as long running are guaranteed to run even if the got canceled befor running.

Periodic Scheduling

schedulePeriodicWithState(state, period, action)

Schedules action for periodic execution every period.

schedulePeriodicWithState(state, period, action)

Schedules action for periodic execution every period. The action gets as parameter state and should return the new state that is used on the next periodic invocation.

Immediate Scheduling

schedule(action)

Schedules action for immediate execution. action receives as parameter the scheduler.

scheduleWithState(state, action)

Schedules action for immediate execution. action receives as parameter the scheduler and state.

Relative time scheduling

scheduleWithRelative(dueTime, action)

Schedules action for execution after dueTime. action receives as parameter the scheduler.

scheduleWithRelativeAndState(state, dueTime, action)

Schedules action for execution after dueTime. action receives as parameter the scheduler and state.

Absolute time scheduling

scheduleWithAbsolute(dueTime, action)

Schedules action for execution at dueTime. action receives as parameter the scheduler.

scheduleWithAbsoluteAndState(state, dueTime, action)

Schedules action for execution at dueTime. action receives as parameter the scheduler and state.

Recursive scheduling

scheduleRecursive(action)

Schedules action immediately for recursive execution. action receives as parameter the continuation function to schedule itself recursively.

scheduleRecursiveWithState(state, action)

Schedules action immediately for recursive execution. action receives as parameter the state and the continuation function to schedule itself recursively. The parameter given to the continuation function is the state for the next invocation of action.

scheduleRecursiveWithRelative(dueTime, action)

Schedules action for recursive execution after dueTime. action receives as parameter the continuation function to schedule itself recursively.

scheduleRecursiveWithRelativeAndState(state, dueTime, action)

Schedules action for recursive execution after dueTime. action receives as parameter the state and the continuation function to schedule itself recursively. The parameter given to the continuation function is the state for the next invocation of action.

scheduleRecursiveWithAbsolute(dueTime, action)

Schedules action for recursive execution at dueTime. action receives as parameter the continuation function to schedule itself recursively.

scheduleRecursiveWithAbsoluteAndState(state, dueTime, action)

Schedules action for recursive execution at dueTime. action receives as parameter the state and the continuation function to schedule itself recursively. The parameter given to the continuation function is the state for the next invocation of action.

Static attributes of scheduler instances

immediate

A Scheduler that runs all scheduled actions immediately. It does not support long running and periodic scheduling.

currentThread

A Scheduler that keeps a queue of all scheduled actions. It does not support long running and periodic scheduling but allows for cooperative scheduling which means that for example a generator and a consumer could be scheduled at the same time and both would run concurrently.

default

A Scheduler that supports all scheduling operations. It is the default scheduler and should be used whenever no particular reason exists to use an other scheduler implementation.

Previous topic

observer

Next topic

subject

This Page