Hirokazu Yamamoto <[email protected]> added the comment:
> Does the following patch solve your issue?
I tried, but it still crashed. I could reproduce the crash by following
script. It crashed also on Python2.7, but it doesn't crash on Python3.
And when I used io.open() instead of builtin open(), it doesn't crash
even on Python2.x. (Probably because io.open implements buffer protocol
by itself)
//////////////////////////////////////////////////////
import threading
import sys
if sys.version_info.major == 3:
xrange = range
def main():
size = 1024 * 1024 # large enough
f = open("__temp__.tmp", "w", size)
for _ in xrange(size):
f.write("c")
t1 = threading.Thread(target=f.close)
t2 = threading.Thread(target=f.close)
t1.start()
t2.start()
t1.join()
t2.join()
if __name__ == '__main__':
main()
//////////////////////////////////////////////////////
I lied a bit on msg110655. close(2) is not used, that is actually
fclose(). I didn't notice the variable *close* was declared as
the parameter of fill_file_fields().
----------
versions: +Python 2.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue9295>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com