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:
Ryan Williams
2010-09-12 17:42:12 -07:00
parent ed6a23780a
commit d5403dc963
2 changed files with 22 additions and 0 deletions

View File

@@ -257,6 +257,7 @@ def setup():
_reqq = Queue(maxsize=-1)
_rspq = Queue(maxsize=-1)
assert _nthreads >= 0, "Can't specify negative number of threads"
for i in range(0,_nthreads):
t = threading.Thread(target=tworker, name="tpool_thread_%s" % i)
t.setDaemon(True)

View File

@@ -44,6 +44,27 @@ assert highwater[0] == expected, "%s != %s" % (highwater[0], expected)"""
finally:
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):
def test_eventlet_hub(self):
new_mod = """from eventlet import hubs