diff options
-rw-r--r-- | aiogreen.py | 14 | ||||
-rw-r--r-- | doc/changelog.rst | 2 |
2 files changed, 15 insertions, 1 deletions
diff --git a/aiogreen.py b/aiogreen.py index d3be7e7..43c9ff2 100644 --- a/aiogreen.py +++ b/aiogreen.py @@ -1,6 +1,7 @@ import eventlet.hubs.hub import greenlet import logging +import signal import sys socket = eventlet.patcher.original('socket') threading = eventlet.patcher.original('threading') @@ -228,7 +229,18 @@ class EventLoop(asyncio.SelectorEventLoop): # Detect blocking eventlet functions. The feature is implemented with # signal.alarm() which is is not available on Windows. self._hub.debug_blocking = debug and (sys.platform != 'win32') - self._hub.debug_blocking_resolution = 0.1 + if (self._hub.debug_blocking + and hasattr(self, 'slow_callback_duration')): + self._hub.debug_blocking_resolution = self.slow_callback_duration + + def run_forever(self): + try: + super(EventLoop, self).run_forever() + finally: + if self._hub.debug_blocking: + # eventlet event loop is still running: cancel the current + # detection of blocking tasks + signal.alarm(0) def time(self): return self._hub.clock() diff --git a/doc/changelog.rst b/doc/changelog.rst index 41343a2..e43da04 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -7,6 +7,8 @@ Version 0.3 (development version) * :func:`wrap_greenthread` now raises an exception if the greenthread is running or already finished. In debug mode, the exception is not more logged to sys.stderr for greenthreads. +* Fix eventlet detection of blocking tasks: cancel the alarm when the aiogreen + event loop stops. 2014-10-21: version 0.2 ----------------------- |