Previous topic

mmf.async

This Page

mmf.async.client

ISync() This is a high-level synchronization object that provides an interface to the underlying event loop.
TkSync([tk]) Sync object with Tk event loop.
register_plotter(plotter[, ridict]) Registers plotter to be called by the event loop.
run(plotter)

Inheritance diagram for mmf.async.client:

Inheritance diagram of mmf.async.client

This module implements a client that connects to a ComputationServer using twisted. The ComputationServer is presented through the RIDict interface which acts like a remote IDict (see server.py). Presently, however, one needs to explicitly call update.

The twisted reactor is run in a separate thread, so the user can use this at the python prompt. We add a hook to the GUI mainloop (this will be backend dependent, so right now we require TkAgg) to periodically get the data and plot the results. This hook looks for a callable in the main_callback_queue. These will be called from the main thread (all Tk interactions must be called from the main thread).

class mmf.async.client.ISync[source]

Bases: object

This is a high-level synchronization object that provides an interface to the underlying event loop. It is used to register callbacks that need to be called from the thread in which the event loop is running. The callbacks are called, either at a regular interval, or when update is called.

Methods

register(callback[, delay, wait, repeat]) Register callback to be called repeat times with a specified minimum delay.
update() Send an update notification.

The object should be constructed from the main thread.

Methods

register(callback[, delay, wait, repeat]) Register callback to be called repeat times with a specified minimum delay.
update() Send an update notification.
__init__()[source]

The object should be constructed from the main thread.

register(callback, delay=None, wait=True, repeat=None)[source]

Register callback to be called repeat times with a specified minimum delay. If wait is True, then only a call to update will trigger the callback. This should be threadsafe.

update()[source]

Send an update notification. Thus must be threadsafe.

class mmf.async.client.TkSync(tk=None)[source]

Bases: mmf.async.client.ISync

Sync object with Tk event loop.

Methods

register(callback[, delay, wait, repeat]) Register callback to be called repeat times with a specified minimum delay.
update() Send an update notification.

Must be called with a tk instance. Will use the figure returned by pylab.gcf() if needed.

Methods

register(callback[, delay, wait, repeat]) Register callback to be called repeat times with a specified minimum delay.
update() Send an update notification.
__init__(tk=None)[source]

Must be called with a tk instance. Will use the figure returned by pylab.gcf() if needed.

poll_delay = 100
register(callback, delay=None, wait=True, repeat=None)[source]

Register callback to be called repeat times with a specified minimum delay. If wait is True, then only a call to update will trigger the callback.

update()[source]

Send an update notification. This may be called from other threads.

mmf.async.client.register_plotter(plotter, ridict=None)[source]

Registers plotter to be called by the event loop.

Plotting works like this:

The function plotter(idict) should plots the data in idict.

mmf.async.client.run(plotter)[source]