symbian-qemu-0.9.1-12/python-2.6.1/Lib/test/crashers/multithreaded_close.py
author Shane McErlean <shane.mcerlean@accenture.com>
Fri, 27 Aug 2010 15:33:49 +0100
changeset 101 1e82a8be084a
parent 1 2fb8b9db1c86
permissions -rw-r--r--
NTT DOCOMO, INC - Fix for bug 1290 "E32test t_atomic.EXE failed with unhandled exception handling"

# 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()