~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Lib/test/test_bz2.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
import os
8
8
import subprocess
9
9
import sys
 
10
import threading
10
11
 
11
12
import bz2
12
13
from bz2 import BZ2File, BZ2Compressor, BZ2Decompressor
284
285
        bz2f.close()
285
286
        self.assertEqual(xlines, ['Test'])
286
287
 
 
288
    def testThreading(self):
 
289
        # Using a BZ2File from several threads doesn't deadlock (issue #7205).
 
290
        data = "1" * 2**20
 
291
        nthreads = 10
 
292
        f = bz2.BZ2File(self.filename, 'wb')
 
293
        try:
 
294
            def comp():
 
295
                for i in range(5):
 
296
                    f.write(data)
 
297
            threads = [threading.Thread(target=comp) for i in range(nthreads)]
 
298
            for t in threads:
 
299
                t.start()
 
300
            for t in threads:
 
301
                t.join()
 
302
        finally:
 
303
            f.close()
 
304
 
287
305
 
288
306
class BZ2CompressorTest(BaseTest):
289
307
    def testCompress(self):