Added a test to the parent assignment in hub.switch because the constant ValueErrors were confusing me. Yields a slight performance improvement, the benchmark shows.
This commit is contained in:
@@ -3,6 +3,23 @@
|
|||||||
import eventlet
|
import eventlet
|
||||||
import benchmarks
|
import benchmarks
|
||||||
|
|
||||||
|
def cleanup():
|
||||||
|
eventlet.sleep(0.2)
|
||||||
|
|
||||||
|
iters = 10000
|
||||||
|
best = benchmarks.measure_best(5, iters,
|
||||||
|
'pass',
|
||||||
|
cleanup,
|
||||||
|
eventlet.sleep)
|
||||||
|
print "eventlet.sleep (main)", best[eventlet.sleep]
|
||||||
|
|
||||||
|
gt = eventlet.spawn(benchmarks.measure_best,5, iters,
|
||||||
|
'pass',
|
||||||
|
cleanup,
|
||||||
|
eventlet.sleep)
|
||||||
|
best = gt.wait()
|
||||||
|
print "eventlet.sleep (gt)", best[eventlet.sleep]
|
||||||
|
|
||||||
def dummy(i=None):
|
def dummy(i=None):
|
||||||
return i
|
return i
|
||||||
|
|
||||||
@@ -15,10 +32,7 @@ def run_spawn_n():
|
|||||||
def run_spawn_n_kw():
|
def run_spawn_n_kw():
|
||||||
eventlet.spawn_n(dummy, i=1)
|
eventlet.spawn_n(dummy, i=1)
|
||||||
|
|
||||||
def cleanup():
|
|
||||||
eventlet.sleep(0.2)
|
|
||||||
|
|
||||||
iters = 10000
|
|
||||||
best = benchmarks.measure_best(5, iters,
|
best = benchmarks.measure_best(5, iters,
|
||||||
'pass',
|
'pass',
|
||||||
cleanup,
|
cleanup,
|
||||||
|
@@ -112,9 +112,11 @@ class BaseHub(object):
|
|||||||
if self.greenlet.dead:
|
if self.greenlet.dead:
|
||||||
self.greenlet = greenlet.greenlet(self.run)
|
self.greenlet = greenlet.greenlet(self.run)
|
||||||
try:
|
try:
|
||||||
greenlet.getcurrent().parent = self.greenlet
|
current = greenlet.getcurrent()
|
||||||
|
if self.greenlet.parent is not current:
|
||||||
|
current.parent = self.greenlet
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass # gets raised if there is a greenlet parent cycle
|
||||||
return self.greenlet.switch()
|
return self.greenlet.switch()
|
||||||
|
|
||||||
def squelch_exception(self, fileno, exc_info):
|
def squelch_exception(self, fileno, exc_info):
|
||||||
|
Reference in New Issue
Block a user