diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-10-27 17:49:21 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-10-27 17:49:21 (GMT) |
commit | a3af0eb7a62932babfae681d6c1aca30269f5fb1 (patch) | |
tree | c769982bbcb632e293412a8de08399987dc9f49e /Lib/test/test_bz2.py | |
parent | e02d1a0fd477e9f4009c693eaccf1f12c11f83fd (diff) | |
download | cpython-a3af0eb7a62932babfae681d6c1aca30269f5fb1.zip cpython-a3af0eb7a62932babfae681d6c1aca30269f5fb1.tar.gz cpython-a3af0eb7a62932babfae681d6c1aca30269f5fb1.tar.bz2 |
Merged revisions 75820 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r75820 | antoine.pitrou | 2009-10-27 18:47:14 +0100 (mar., 27 oct. 2009) | 9 lines
Merged revisions 75818 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75818 | antoine.pitrou | 2009-10-27 18:41:58 +0100 (mar., 27 oct. 2009) | 3 lines
Issue #7205: Fix a possible deadlock when using a BZ2File object from several threads at once.
........
................
Diffstat (limited to 'Lib/test/test_bz2.py')
-rw-r--r-- | Lib/test/test_bz2.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py index 6715a02..9a9afa6 100644 --- a/Lib/test/test_bz2.py +++ b/Lib/test/test_bz2.py @@ -7,6 +7,7 @@ from io import BytesIO import os import subprocess import sys +import threading # Skip tests if the bz2 module doesn't exist. bz2 = support.import_module('bz2') @@ -282,6 +283,23 @@ class BZ2FileTest(BaseTest): else: self.fail("1/0 didn't raise an exception") + def testThreading(self): + # Using a BZ2File from several threads doesn't deadlock (issue #7205). + data = b"1" * 2**20 + nthreads = 10 + f = bz2.BZ2File(self.filename, 'wb') + try: + def comp(): + for i in range(5): + f.write(data) + threads = [threading.Thread(target=comp) for i in range(nthreads)] + for t in threads: + t.start() + for t in threads: + t.join() + finally: + f.close() + class BZ2CompressorTest(BaseTest): def testCompress(self): |