summaryrefslogtreecommitdiff
path: root/tests/patcher_test_importlib_lock.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-11-20 12:25:47 +0100
committerSergey Shepelev <temotor@gmail.com>2014-12-21 17:45:37 +0300
commit5e392fea66953751985a0d64db5f561f4572a926 (patch)
treebe92b9f9ef8e47314369c5bf7573bf30a7d520a9 /tests/patcher_test_importlib_lock.py
parent7c21c8f92eed58c508f30defed133071c5728df7 (diff)
downloadeventlet-py3_importlib.tar.gz
Fix monkey_patch() on Python 3py3_importlib
The importlib module must use real thread locks, not eventlet.Semaphore.
Diffstat (limited to 'tests/patcher_test_importlib_lock.py')
-rw-r--r--tests/patcher_test_importlib_lock.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/patcher_test_importlib_lock.py b/tests/patcher_test_importlib_lock.py
new file mode 100644
index 0000000..8f7cea7
--- /dev/null
+++ b/tests/patcher_test_importlib_lock.py
@@ -0,0 +1,30 @@
+from __future__ import print_function
+
+import sys
+
+import eventlet
+
+
+# no standard tests in this file, ignore
+__test__ = False
+
+
+def do_import():
+ import encodings.idna
+
+
+if __name__ == '__main__':
+ eventlet.monkey_patch()
+ threading = eventlet.patcher.original('threading')
+
+ sys.modules.pop('encodings.idna', None)
+
+ # call "import encodings.idna" in a new thread
+ thread = threading.Thread(target=do_import)
+ thread.start()
+
+ # call "import encodings.idna" in the main thread
+ do_import()
+
+ thread.join()
+ print('ok')