summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-11-21 23:56:39 +0100
committerVictor Stinner <victor.stinner@gmail.com>2014-11-21 23:56:39 +0100
commitc6e3320ff02ae6a9e8bd767a094d6e77de735d07 (patch)
tree8c5f0e35ee45342c713f90143d52a4d42031b9ae
parent9060f9089e88ab0dfffa85b1c6c95051cc235561 (diff)
downloadaioeventlet-c6e3320ff02ae6a9e8bd767a094d6e77de735d07.tar.gz
Fix eventlet detection of blocking tasks: cancel the alarm when the aiogreen
event loop stops.
-rw-r--r--aiogreen.py14
-rw-r--r--doc/changelog.rst2
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
-----------------------