summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-11-21 01:37:36 +0100
committerVictor Stinner <victor.stinner@gmail.com>2014-11-21 01:37:36 +0100
commit77ca2876b20591dc450e5a3137804182d9fb0fd8 (patch)
treee29f2ae0405473d22be21f11703398e40ba6737e /tests
parent97a2f28ba38ec6231c21bb4f92758c27c39d1ee4 (diff)
downloadaioeventlet-77ca2876b20591dc450e5a3137804182d9fb0fd8.tar.gz
In debug mode, detect calls to call_soon() from greenthreads which are not
threadsafe (would not wake up the event loop).
Diffstat (limited to 'tests')
-rw-r--r--tests/test_eventlet.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/test_eventlet.py b/tests/test_eventlet.py
index d50c8ee..9e6b699 100644
--- a/tests/test_eventlet.py
+++ b/tests/test_eventlet.py
@@ -2,6 +2,30 @@ import eventlet
import tests
class EventletTests(tests.TestCase):
+ def test_stop(self):
+ def func():
+ eventlet.spawn(self.loop.call_soon_threadsafe, self.loop.stop)
+
+ def schedule_greenthread():
+ eventlet.spawn(func)
+
+ self.loop.call_soon(schedule_greenthread)
+ self.loop.run_forever()
+
+ def test_soon(self):
+ result = []
+
+ def func():
+ result.append("spawn")
+ self.loop.call_soon_threadsafe(self.loop.stop)
+
+ def schedule_greenthread():
+ eventlet.spawn(func)
+
+ self.loop.call_soon(schedule_greenthread)
+ self.loop.run_forever()
+ self.assertEqual(result, ["spawn"])
+
def test_soon_spawn(self):
result = []
@@ -14,7 +38,7 @@ class EventletTests(tests.TestCase):
def schedule_greenthread():
eventlet.spawn(func1)
- eventlet.spawn_after(0.001, func2)
+ eventlet.spawn_after(0.010, func2)
self.loop.call_soon(schedule_greenthread)
self.loop.run_forever()