PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/Lib/test/crashers/multithreaded_close.py

http://unladen-swallow.googlecode.com/
Python | 14 lines | 5 code | 2 blank | 7 comment | 1 complexity | 1a49637dceb456e81a36609dc7a1d34b MD5 | raw file
 1# f.close() is not thread-safe: calling it at the same time as another
 2# operation (or another close) on the same file, but done from another
 3# thread, causes crashes.  The issue is more complicated than it seems,
 4# witness the discussions in:
 5#
 6# http://bugs.python.org/issue595601
 7# http://bugs.python.org/issue815646
 8
 9import thread
10
11while 1:
12    f = open("multithreaded_close.tmp", "w")
13    thread.start_new_thread(f.close, ())
14    f.close()