Removed undocumented stop() method from hub it's the same as abort(True). Fixed pyevent test failures and broken import that I somehow earlier missed.
This commit is contained in:
@@ -114,11 +114,6 @@ class BaseHub(object):
|
|||||||
self.secondaries[READ].pop(fileno, None)
|
self.secondaries[READ].pop(fileno, None)
|
||||||
self.secondaries[WRITE].pop(fileno, None)
|
self.secondaries[WRITE].pop(fileno, None)
|
||||||
|
|
||||||
def stop(self):
|
|
||||||
self.abort()
|
|
||||||
if self.greenlet is not greenlet.getcurrent():
|
|
||||||
self.switch()
|
|
||||||
|
|
||||||
def switch(self):
|
def switch(self):
|
||||||
cur = greenlet.getcurrent()
|
cur = greenlet.getcurrent()
|
||||||
assert cur is not self.greenlet, 'Cannot switch to MAINLOOP from MAINLOOP'
|
assert cur is not self.greenlet, 'Cannot switch to MAINLOOP from MAINLOOP'
|
||||||
@@ -202,6 +197,7 @@ class BaseHub(object):
|
|||||||
if self.running:
|
if self.running:
|
||||||
self.stopping = True
|
self.stopping = True
|
||||||
if wait:
|
if wait:
|
||||||
|
assert self.greenlet is not greenlet.getcurrent(), "Can't abort with wait from inside the hub's greenlet."
|
||||||
# schedule an immediate timer just so the hub doesn't sleep
|
# schedule an immediate timer just so the hub doesn't sleep
|
||||||
self.schedule_call_global(0, lambda: None)
|
self.schedule_call_global(0, lambda: None)
|
||||||
# switch to it; when done the hub will switch back to its parent,
|
# switch to it; when done the hub will switch back to its parent,
|
||||||
|
@@ -84,8 +84,11 @@ class Hub(BaseHub):
|
|||||||
else:
|
else:
|
||||||
self.squelch_timer_exception(None, sys.exc_info())
|
self.squelch_timer_exception(None, sys.exc_info())
|
||||||
|
|
||||||
def abort(self):
|
def abort(self, wait=True):
|
||||||
self.schedule_call_global(0, self.greenlet.throw, greenlet.GreenletExit)
|
self.schedule_call_global(0, self.greenlet.throw, greenlet.GreenletExit)
|
||||||
|
if wait:
|
||||||
|
assert self.greenlet is not greenlet.getcurrent(), "Can't abort with wait from inside the hub's greenlet."
|
||||||
|
self.switch()
|
||||||
|
|
||||||
def _getrunning(self):
|
def _getrunning(self):
|
||||||
return bool(self.greenlet)
|
return bool(self.greenlet)
|
||||||
|
@@ -3,7 +3,7 @@ import errno
|
|||||||
from eventlet import wsgi
|
from eventlet import wsgi
|
||||||
from eventlet import pools
|
from eventlet import pools
|
||||||
import eventlet
|
import eventlet
|
||||||
from eventlet.common import get_errno
|
from eventlet.support import get_errno
|
||||||
from eventlet.green import socket
|
from eventlet.green import socket
|
||||||
#from pprint import pformat
|
#from pprint import pformat
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
from tests import LimitedTestCase, main
|
from tests import LimitedTestCase, main, skip_with_pyevent
|
||||||
import time
|
import time
|
||||||
import eventlet
|
import eventlet
|
||||||
from eventlet import hubs
|
from eventlet import hubs
|
||||||
@@ -9,6 +9,7 @@ def noop():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
class TestTimerCleanup(LimitedTestCase):
|
class TestTimerCleanup(LimitedTestCase):
|
||||||
|
@skip_with_pyevent
|
||||||
def test_cancel_accumulated(self):
|
def test_cancel_accumulated(self):
|
||||||
hub = hubs.get_hub()
|
hub = hubs.get_hub()
|
||||||
stimers = hub.get_timers_count()
|
stimers = hub.get_timers_count()
|
||||||
@@ -25,6 +26,7 @@ class TestTimerCleanup(LimitedTestCase):
|
|||||||
self.assert_less_than_equal(hub.get_timers_count(), stimers + 1000)
|
self.assert_less_than_equal(hub.get_timers_count(), stimers + 1000)
|
||||||
self.assert_less_than_equal(hub.timers_canceled, 1000)
|
self.assert_less_than_equal(hub.timers_canceled, 1000)
|
||||||
|
|
||||||
|
@skip_with_pyevent
|
||||||
def test_cancel_proportion(self):
|
def test_cancel_proportion(self):
|
||||||
# if fewer than half the pending timers are canceled, it should
|
# if fewer than half the pending timers are canceled, it should
|
||||||
# not clean them out
|
# not clean them out
|
||||||
|
Reference in New Issue
Block a user