summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream/xmlstream.py
diff options
context:
space:
mode:
authorNathan Fritz <nathan@andyet.net>2010-05-26 18:32:28 -0700
committerNathan Fritz <nathan@andyet.net>2010-05-26 18:32:28 -0700
commit0bda5fd3f28da14478db87c98fb89f647994deaa (patch)
tree38ad212fb662cecc63edfd5e938b0f7c0f6460d3 /sleekxmpp/xmlstream/xmlstream.py
parent1e3a6e1b5f06d307295be6b4ccaf75bf2a48399d (diff)
downloadslixmpp-0bda5fd3f28da14478db87c98fb89f647994deaa.tar.gz
slixmpp-0bda5fd3f28da14478db87c98fb89f647994deaa.tar.bz2
slixmpp-0bda5fd3f28da14478db87c98fb89f647994deaa.tar.xz
slixmpp-0bda5fd3f28da14478db87c98fb89f647994deaa.zip
adding scheduler
Diffstat (limited to 'sleekxmpp/xmlstream/xmlstream.py')
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index 025884b7..96b47411 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -22,6 +22,7 @@ import time
import traceback
import types
import xml.sax.saxutils
+from . import scheduler
HANDLER_THREADS = 1
@@ -75,6 +76,7 @@ class XMLStream(object):
self.eventqueue = queue.Queue()
self.sendqueue = queue.Queue()
+ self.scheduler = scheduler.Scheduler()
self.namespace_map = {}
@@ -145,6 +147,7 @@ class XMLStream(object):
raise RestartStream()
def process(self, threaded=True):
+ self.scheduler.process(threaded=True)
for t in range(0, HANDLER_THREADS):
self.__thread['eventhandle%s' % t] = threading.Thread(name='eventhandle%s' % t, target=self._eventRunner)
self.__thread['eventhandle%s' % t].start()
@@ -156,8 +159,8 @@ class XMLStream(object):
else:
self._process()
- def schedule(self, seconds, handler, args=None):
- threading.Timer(seconds, handler, args).start()
+ def schedule(self, name, seconds, callback, args=None, kwargs=None, repeat=False):
+ self.scheduler.add(name, seconds, callback, args, kwargs, repeat, qpointer=self.eventqueue)
def _process(self):
"Start processing the socket."
@@ -334,7 +337,7 @@ class XMLStream(object):
except Exception as e:
traceback.print_exc()
args[0].exception(e)
- elif etype == 'sched':
+ elif etype == 'schedule':
try:
handler.run(*args)
except: