[Python-checkins] r58576 - python/trunk/Lib/test/crashers/multithreaded_close.py

armin.rigo python-checkins at python.org
Sun Oct 21 11:14:16 CEST 2007


Author: armin.rigo
Date: Sun Oct 21 11:14:15 2007
New Revision: 58576

Added:
   python/trunk/Lib/test/crashers/multithreaded_close.py   (contents, props changed)
Log:
Add a crasher for the long-standing issue with closing a file
while another thread uses it.


Added: python/trunk/Lib/test/crashers/multithreaded_close.py
==============================================================================
--- (empty file)
+++ python/trunk/Lib/test/crashers/multithreaded_close.py	Sun Oct 21 11:14:15 2007
@@ -0,0 +1,14 @@
+# f.close() is not thread-safe: calling it at the same time as another
+# operation (or another close) on the same file, but done from another
+# thread, causes crashes.  The issue is more complicated than it seems,
+# witness the discussions in:
+#
+# http://bugs.python.org/issue595601
+# http://bugs.python.org/issue815646
+
+import thread
+
+while 1:
+    f = open("multithreaded_close.tmp", "w")
+    thread.start_new_thread(f.close, ())
+    f.close()


More information about the Python-checkins mailing list