From 0fbafa9fef1800569e2065d32429038a67691a27 Mon Sep 17 00:00:00 2001 From: Tony Young Date: Thu, 13 Feb 2014 18:32:45 +1300 Subject: [PATCH] Allow passing an IO loop instance into the constructor for EventLoop. --- pydle/async.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pydle/async.py b/pydle/async.py index 118df04..20b0109 100644 --- a/pydle/async.py +++ b/pydle/async.py @@ -13,8 +13,10 @@ class EventLoop: 'error': tornado.ioloop.IOLoop.ERROR } - def __init__(self): - self.io_loop = tornado.ioloop.IOLoop.current() + def __init__(self, io_loop=None): + if io_loop is None: + io_loop = tornado.ioloop.IOLoop.current() + self.io_loop = io_loop self.running = False self.handlers = {} self._context_future = None @@ -132,7 +134,7 @@ class EventLoop: handle = self._do_schedule_in(interval, callback, args, kwargs) if callback(*args, **kwargs) == False: self.io_loop.remove_timeout(handle) - + def run(self):