Adding assertion checking for negative pool size in tpool, per discussion with rtyler. Also a test because I am a test nerd.
This commit is contained in:
@@ -257,6 +257,7 @@ def setup():
|
|||||||
|
|
||||||
_reqq = Queue(maxsize=-1)
|
_reqq = Queue(maxsize=-1)
|
||||||
_rspq = Queue(maxsize=-1)
|
_rspq = Queue(maxsize=-1)
|
||||||
|
assert _nthreads >= 0, "Can't specify negative number of threads"
|
||||||
for i in range(0,_nthreads):
|
for i in range(0,_nthreads):
|
||||||
t = threading.Thread(target=tworker, name="tpool_thread_%s" % i)
|
t = threading.Thread(target=tworker, name="tpool_thread_%s" % i)
|
||||||
t.setDaemon(True)
|
t.setDaemon(True)
|
||||||
|
@@ -44,6 +44,27 @@ assert highwater[0] == expected, "%s != %s" % (highwater[0], expected)"""
|
|||||||
finally:
|
finally:
|
||||||
del os.environ['EVENTLET_THREADPOOL_SIZE']
|
del os.environ['EVENTLET_THREADPOOL_SIZE']
|
||||||
|
|
||||||
|
def test_tpool_negative(self):
|
||||||
|
new_mod = """from eventlet import tpool
|
||||||
|
import eventlet
|
||||||
|
import time
|
||||||
|
def do():
|
||||||
|
print "should not get here"
|
||||||
|
try:
|
||||||
|
tpool.execute(do)
|
||||||
|
except AssertionError:
|
||||||
|
print "success"
|
||||||
|
"""
|
||||||
|
os.environ['EVENTLET_THREADPOOL_SIZE'] = "-1"
|
||||||
|
try:
|
||||||
|
self.write_to_tempfile("newmod", new_mod)
|
||||||
|
output, lines = self.launch_subprocess('newmod.py')
|
||||||
|
self.assertEqual(len(lines), 2, lines)
|
||||||
|
self.assertEqual(lines[0], "success", output)
|
||||||
|
finally:
|
||||||
|
del os.environ['EVENTLET_THREADPOOL_SIZE']
|
||||||
|
|
||||||
|
|
||||||
class Hub(ProcessBase):
|
class Hub(ProcessBase):
|
||||||
def test_eventlet_hub(self):
|
def test_eventlet_hub(self):
|
||||||
new_mod = """from eventlet import hubs
|
new_mod = """from eventlet import hubs
|
||||||
|
Reference in New Issue
Block a user