diff options
| author | Thibaut Horel <thibaut.horel@gmail.com> | 2010-12-31 19:19:25 +0100 |
|---|---|---|
| committer | Thibaut Horel <thibaut.horel@gmail.com> | 2010-12-31 19:19:25 +0100 |
| commit | d90aec17e2201f256783a531c548dcc9857c889d (patch) | |
| tree | 56b6d0580ee1993c73e67c63d4a452a81bbaaf1e /sleekxmpp/xmlstream/handler/waiter.py | |
| parent | af76bcdf7a947702eaa19d39f5b9ecfcd7ec6fd2 (diff) | |
| download | alias-d90aec17e2201f256783a531c548dcc9857c889d.tar.gz | |
Cleanup of repository. Bases of webclient.
* remove sleekxmpp (install guideline in server/README)
* move server code to server directory
* webclient directory with basic strophejs example
Diffstat (limited to 'sleekxmpp/xmlstream/handler/waiter.py')
| -rw-r--r-- | sleekxmpp/xmlstream/handler/waiter.py | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/sleekxmpp/xmlstream/handler/waiter.py b/sleekxmpp/xmlstream/handler/waiter.py deleted file mode 100644 index a4bc354..0000000 --- a/sleekxmpp/xmlstream/handler/waiter.py +++ /dev/null @@ -1,101 +0,0 @@ -""" - SleekXMPP: The Sleek XMPP Library - Copyright (C) 2010 Nathanael C. Fritz - This file is part of SleekXMPP. - - See the file LICENSE for copying permission. -""" - -import logging -try: - import queue -except ImportError: - import Queue as queue - -from sleekxmpp.xmlstream import StanzaBase, RESPONSE_TIMEOUT -from sleekxmpp.xmlstream.handler.base import BaseHandler - - -log = logging.getLogger(__name__) - - -class Waiter(BaseHandler): - - """ - The Waiter handler allows an event handler to block - until a particular stanza has been received. The handler - will either be given the matched stanza, or False if the - waiter has timed out. - - Methods: - check_delete -- Overrides BaseHandler.check_delete - prerun -- Overrides BaseHandler.prerun - run -- Overrides BaseHandler.run - wait -- Wait for a stanza to arrive and return it to - an event handler. - """ - - def __init__(self, name, matcher, stream=None): - """ - Create a new Waiter. - - Arguments: - name -- The name of the waiter. - matcher -- A matcher object to detect the desired stanza. - stream -- Optional XMLStream instance to monitor. - """ - BaseHandler.__init__(self, name, matcher, stream=stream) - self._payload = queue.Queue() - - def prerun(self, payload): - """ - Store the matched stanza. - - Overrides BaseHandler.prerun - - Arguments: - payload -- The matched stanza object. - """ - self._payload.put(payload) - - def run(self, payload): - """ - Do not process this handler during the main event loop. - - Overrides BaseHandler.run - - Arguments: - payload -- The matched stanza object. - """ - pass - - def wait(self, timeout=RESPONSE_TIMEOUT): - """ - Block an event handler while waiting for a stanza to arrive. - - Be aware that this will impact performance if called from a - non-threaded event handler. - - Will return either the received stanza, or False if the waiter - timed out. - - Arguments: - timeout -- The number of seconds to wait for the stanza to - arrive. Defaults to the global default timeout - value sleekxmpp.xmlstream.RESPONSE_TIMEOUT. - """ - try: - stanza = self._payload.get(True, timeout) - except queue.Empty: - stanza = False - log.warning("Timed out waiting for %s" % self.name) - self.stream.removeHandler(self.name) - return stanza - - def check_delete(self): - """ - Always remove waiters after use. - - Overrides BaseHandler.check_delete - """ - return True |
