From 3ac397a5e4619f4a008fad97a161c2677b096fda Mon Sep 17 00:00:00 2001 From: Ask Solem Date: Thu, 21 Oct 2010 15:43:48 +0200 Subject: [PATCH] kombu.pidbox: Fixed rst in docstrings --- kombu/pidbox.py | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/kombu/pidbox.py b/kombu/pidbox.py index c9cad488..0d9b7bf1 100644 --- a/kombu/pidbox.py +++ b/kombu/pidbox.py @@ -1,29 +1,40 @@ """ -Server -====== +Creating the applications Mailbox +================================= -mailbox = pidbox.Mailbox("celerybeat", ) +:: -@mailbox.handler -def reload_schedule(state, **kwargs): - state.beat.reload_schedule() - state["last_reload"] = time() + >>> mailbox = pidbox.Mailbox("celerybeat", type="direct") -@mailbox.handler -def connection_info(state, **kwargs): - return {"connection": state.connection.info()} + >>> @mailbox.handler + >>> def reload_schedule(state, **kwargs): + ... state["beat"].reload_schedule() + >>> @mailbox.handler + >>> def connection_info(state, **kwargs): + ... return {"connection": state["connection"].info()} -connection = kombu.BrokerConnection() -mailbox(connection).Node(hostname).consume() +Example Node +============ -Client -====== +:: + >>> connection = kombu.BrokerConnection() + >>> state = {"beat": beat, + "connection: connection} + >>> consumer = mailbox(connection).Node(hostname).listen() + >>> try: + ... while True: + ... connection.drain_events(timeout=1) + ... finally: + ... consumer.cancel() -celerybeat = pidbox.lookup("celerybeat") -celerybeat.cast("reload_schedule") -info = celerybeat.call("connection_info", timeout=1) +Example Client +============== + +:: + >>> mailbox.cast("reload_schedule") # cast is async. + >>> info = celerybeat.call("connection_info", timeout=1) """