Ensure threading._shutdown gets patched too
Since threading can get imported multiple times, ensure that the _shutdown symbol is patched so the _MainThread matches what is in _active. This patch fill fix the KeyError on exit under Python 2.7
This commit is contained in:
@@ -6,7 +6,7 @@ from eventlet.support import greenlets as greenlet
|
||||
|
||||
__patched__ = ['_start_new_thread', '_allocate_lock', '_get_ident', '_sleep',
|
||||
'local', 'stack_size', 'Lock', 'currentThread',
|
||||
'current_thread', '_after_fork']
|
||||
'current_thread', '_after_fork', '_shutdown']
|
||||
|
||||
__orig_threading = patcher.original('threading')
|
||||
__threadlocal = __orig_threading.local()
|
||||
|
||||
@@ -383,6 +383,14 @@ print len(threading._active)
|
||||
self.assert_(lines[0].startswith('<_GreenThread'), lines[0])
|
||||
self.assertEqual(lines[1], "1", lines[1])
|
||||
|
||||
def test_keyerror(self):
|
||||
new_mod = """import eventlet
|
||||
eventlet.monkey_patch()
|
||||
"""
|
||||
self.write_to_tempfile("newmod", new_mod)
|
||||
output, lines = self.launch_subprocess('newmod')
|
||||
self.assertEqual(len(lines), 1, "\n".join(lines))
|
||||
|
||||
|
||||
class GreenThreadWrapper(ProcessBase):
|
||||
prologue = """import eventlet
|
||||
|
||||
Reference in New Issue
Block a user