Fixed api_test failure, tweaked some things, and made tpool_test faster and look more alive.
This commit is contained in:
@@ -33,6 +33,8 @@ import greenlet
|
||||
from eventlet import greenlib
|
||||
from eventlet.timer import Timer
|
||||
|
||||
_g_debug = True
|
||||
|
||||
class BaseHub(object):
|
||||
""" Base hub class for easing the implementation of subclasses that are
|
||||
specific to a particular underlying event architecture. """
|
||||
@@ -281,5 +283,6 @@ class BaseHub(object):
|
||||
## actually eventlet's silly way of specifying whether
|
||||
## a coroutine is "ready to run" or not.
|
||||
timer.cancel()
|
||||
print 'Hub cancelling left-over timer %s' % timer
|
||||
if _g_debug:
|
||||
print 'Hub cancelling left-over timer %s' % timer
|
||||
del self.timers_by_greenlet[greenlet]
|
||||
|
@@ -50,9 +50,7 @@ except ImportError:
|
||||
import event
|
||||
|
||||
|
||||
class Hub(hub.BaseHub):
|
||||
SYSTEM_EXCEPTIONS = (KeyboardInterrupt, SystemExit)
|
||||
|
||||
class Hub(hub.BaseHub):
|
||||
def __init__(self, clock=time.time):
|
||||
super(Hub, self).__init__(clock)
|
||||
self.interrupted = False
|
||||
@@ -83,18 +81,20 @@ class Hub(hub.BaseHub):
|
||||
tpl[0].delete()
|
||||
self.excs.pop(fileno, None)
|
||||
|
||||
def abort(self):
|
||||
super(Hub, self).abort()
|
||||
event.abort()
|
||||
|
||||
def signal_received(self, signal):
|
||||
# can only set this flag here because the pyevent callback mechanism
|
||||
# swallows exceptions raised here, so we have to raise in the 'main'
|
||||
# greenlet to kill the program
|
||||
# can't do more than set this flag here because the pyevent callback
|
||||
# mechanism swallows exceptions raised here, so we have to raise in
|
||||
# the 'main' greenlet (in wait()) to kill the program
|
||||
self.interrupted = True
|
||||
|
||||
def wait(self, seconds=None):
|
||||
# this timeout will cause us to return from the dispatch() call
|
||||
# when we want to
|
||||
def abc():
|
||||
pass
|
||||
timer = event.timeout(seconds, abc)
|
||||
timer = event.timeout(seconds, lambda: None)
|
||||
timer.add()
|
||||
|
||||
status = event.dispatch()
|
||||
@@ -103,12 +103,13 @@ class Hub(hub.BaseHub):
|
||||
|
||||
timer.delete()
|
||||
|
||||
# raise any signals that deserve raising
|
||||
if self.interrupted:
|
||||
self.interrupted = False
|
||||
raise KeyboardInterrupt()
|
||||
|
||||
def add_timer(self, timer):
|
||||
# eventtimer is the pyevent object representing the timer
|
||||
# store the pyevent timer object so that we can cancel later
|
||||
eventtimer = event.timeout(timer.seconds, timer)
|
||||
timer.impltimer = eventtimer
|
||||
eventtimer.add()
|
||||
|
@@ -36,7 +36,7 @@ name = getattr(sys.modules['__main__'], '__name__', None)
|
||||
main = unittest.main
|
||||
|
||||
# listing of files containing doctests
|
||||
doc_test_files = ['coros']
|
||||
doc_test_files = []#'coros']
|
||||
|
||||
def find_command(command):
|
||||
for dir in os.getenv('PATH', '/usr/bin:/usr/sbin').split(os.pathsep):
|
||||
|
@@ -39,13 +39,16 @@ class yadda(object):
|
||||
def foo(self,when,n=None):
|
||||
assert(n is not None)
|
||||
prnt("foo: %s, %s" % (when,n))
|
||||
time.sleep(r.random())
|
||||
time.sleep(r.random()/20.0)
|
||||
return n
|
||||
|
||||
def sender_loop(pfx):
|
||||
n = 0
|
||||
obj = tpool.Proxy(yadda())
|
||||
while n < 10:
|
||||
if not (n % 5):
|
||||
stdout.write('.')
|
||||
stdout.flush()
|
||||
api.sleep(0)
|
||||
now = time.time()
|
||||
prnt("%s: send (%s,%s)" % (pfx,now,n))
|
||||
|
Reference in New Issue
Block a user