summaryrefslogtreecommitdiffstats
path: root/Lib/test/crashers
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/crashers')
-rw-r--r--Lib/test/crashers/file_threads.py8
-rw-r--r--Lib/test/crashers/multithreaded_close.py14
2 files changed, 14 insertions, 8 deletions
diff --git a/Lib/test/crashers/file_threads.py b/Lib/test/crashers/file_threads.py
deleted file mode 100644
index d82ad3c..0000000
--- a/Lib/test/crashers/file_threads.py
+++ /dev/null
@@ -1,8 +0,0 @@
-# An example for http://bugs.python.org/issue815646
-
-import thread
-
-while 1:
- f = open("/tmp/dupa", "w")
- thread.start_new_thread(f.close, ())
- f.close()
diff --git a/Lib/test/crashers/multithreaded_close.py b/Lib/test/crashers/multithreaded_close.py
new file mode 100644
index 0000000..5224341
--- /dev/null
+++ b/Lib/test/crashers/multithreaded_close.py
@@ -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()