summaryrefslogtreecommitdiffstats
path: root/Lib/test/crashers/multithreaded_close.py
blob: f862d28b19cf6f1288c26c242224cc2fc10340f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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()