Python twisted.internet.task.coiterate() Examples
The following are 3
code examples of twisted.internet.task.coiterate().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
twisted.internet.task
, or try the search function
.
Example #1
Source File: txpublisher.py From txamqp with Apache License 2.0 | 5 votes |
def gotConnection(conn, username, password, body, count=1): print("Connected to broker.") yield conn.authenticate(username, password) print("Authenticated. Ready to send messages") chan = yield conn.channel(1) yield chan.channel_open() def send_messages(): def message_iterator(): for i in range(count): content = body + "-%d" % i msg = Content(content) msg["delivery mode"] = 2 chan.basic_publish(exchange="chatservice", content=msg, routing_key="txamqp_chatroom") print("Sending message: %s" % content) yield None return task.coiterate(message_iterator()) yield send_messages() stopToken = "STOP" msg = Content(stopToken) msg["delivery mode"] = 2 chan.basic_publish(exchange="chatservice", content=msg, routing_key="txamqp_chatroom") print("Sending message: %s" % stopToken) yield chan.channel_close() chan0 = yield conn.channel(0) yield chan0.connection_close() reactor.stop()
Example #2
Source File: lease_socket_service.py From maas with GNU Affero General Public License v3.0 | 5 votes |
def processNotifications(self, clock=reactor): """Process all notifications.""" def gen_notifications(notifications): while len(notifications) != 0: yield notifications.popleft() return task.coiterate( self.processNotification(notification, clock=clock) for notification in gen_notifications(self.notifications) )
Example #3
Source File: listener.py From maas with GNU Affero General Public License v3.0 | 5 votes |
def handleNotifies(self, clock=reactor): """Process all notify message in the notifications set.""" def gen_notifications(notifications): while len(notifications) != 0: yield notifications.pop() return task.coiterate( self.handleNotify(notification, clock=clock) for notification in gen_notifications(self.notifications) )