TwistedThread() | Python Thread that runs the twisted reactor. |
RIDict([host, port]) | Implements a remote IDict interface that connects to a |
callTwisted(*v, **kw) | Decorate a function to be called from twisted. |
run_reactor_as_thread() | |
run_reactor() | |
stop_reactor() |
Inheritance diagram for mmf.async.twisted_utils:
Some utilities to supplement twisted.
Bases: threading.Thread
Python Thread that runs the twisted reactor.
Methods
getName() | |
isAlive() | |
isDaemon() | |
is_alive() | |
join([timeout]) | |
run() | Run the reactor without signal handlers. |
setDaemon(daemonic) | |
setName(name) | |
start() | |
stop() | Stop the reactor and join the thread... |
Start the thread as a daemon (meaning that it will not block the closing of the process when the main thread executes.
Methods
getName() | |
isAlive() | |
isDaemon() | |
is_alive() | |
join([timeout]) | |
run() | Run the reactor without signal handlers. |
setDaemon(daemonic) | |
setName(name) | |
start() | |
stop() | Stop the reactor and join the thread... |
Bases: dict
Implements a remote IDict interface that connects to a specified server.
Methods
clear | D.clear() -> None. Remove all items from D. |
connect() | Try to connect to the specified host. |
copy | D.copy() -> a shallow copy of D |
fromkeys(...) | v defaults to None. |
get | D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None. |
has_key | D.has_key(k) -> True if D has a key k, else False |
items | D.items() -> list of D’s (key, value) pairs, as 2-tuples |
iteritems | D.iteritems() -> an iterator over the (key, value) items of D |
iterkeys | D.iterkeys() -> an iterator over the keys of D |
itervalues | D.itervalues() -> an iterator over the values of D |
keys | D.keys() -> list of D’s keys |
onConnect(protocol) | |
onFail(failure) | |
onUpdate(idict) | |
pop | D.pop(k[,d]) -> v, remove specified key and return the corresponding value. |
popitem | D.popitem() -> (k, v), remove and return some (key, value) pair as a |
setdefault | D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D |
subscribe(*v, **k) | Subscribe for update notification from the server. |
update | D.update(E, **F) -> None. Update D from dict/iterable E and F. |
values | D.values() -> list of D’s values |
viewitems | D.viewitems() -> a set-like object providing a view on D’s items |
viewkeys | D.viewkeys() -> a set-like object providing a view on D’s keys |
viewvalues | D.viewvalues() -> an object providing a view on D’s values |
wait_for_update([timeout]) | Block until an update is received. |
Decorate a function to be called from twisted. The function is expected to return a value, not a deferred.
The function will do several things: 1) If the twisted reactor is not running, it will register itself
to be run at the startup and then will return a deferred.
Parameters: delay: Delay the call (only if block is False and the reactor is
running).
If you are going to call something that the twisted reactor needs to deal with, you should decorate with this. This will ensure that if the current thread is not the reactor thread, then the function will be called with reactor.callFromThread. Examples include calls to: