<s> """<STR_LIT>""" <EOL> NUM_THREADS = <NUM_LIT:20> <EOL> FILES_PER_THREAD = <NUM_LIT:50> <EOL> import thread <EOL> import threading <EOL> from test . test_support import TestFailed , threading_setup , threading_cleanup <EOL> import StringIO <EOL> from traceback import print_exc <EOL> import tempfile <EOL> startEvent = threading . Event ( ) <EOL> class TempFileGreedy ( threading . Thread ) : <EOL> error_count = <NUM_LIT:0> <EOL> ok_count = <NUM_LIT:0> <EOL> def run ( self ) : <EOL> self . errors = StringIO . StringIO ( ) <EOL> startEvent . wait ( ) <EOL> for i in range ( FILES_PER_THREAD ) : <EOL> try : <EOL> f = tempfile . TemporaryFile ( "<STR_LIT>" ) <EOL> f . close ( ) <EOL> except : <EOL> self . error_count += <NUM_LIT:1> <EOL> print_exc ( file = self . errors ) <EOL> else : <EOL> self . ok_count += <NUM_LIT:1> <EOL> def test_main ( ) : <EOL> threads = [ ] <EOL> thread_info = threading_setup ( ) <EOL> print "<STR_LIT>" <EOL> for i in range ( NUM_THREADS ) : <EOL> t = TempFileGreedy ( ) <EOL> threads . append ( t ) <EOL> t . start ( ) <EOL> print "<STR_LIT>" <EOL> startEvent . set ( ) <EOL> print "<STR_LIT>" <EOL> ok = errors = <NUM_LIT:0> <EOL> for t in threads : <EOL> t . join ( ) <EOL> ok += t . ok_count <EOL> errors += t . error_count <EOL> if t . error_count : <EOL> print '<STR_LIT>' % ( t . getName ( ) , t . errors . getvalue ( ) ) <EOL> msg = "<STR_LIT>" % ( errors , ok ) <EOL> print msg <EOL> if errors : <EOL> raise TestFailed ( msg ) <EOL> threading_cleanup ( * thread_info ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> import sys , getopt <EOL> opts , args = getopt . getopt ( sys . argv [ <NUM_LIT:1> : ] , "<STR_LIT>" ) <EOL> for o , v in opts : <EOL> if o == "<STR_LIT>" : <EOL> FILES_PER_THREAD = int ( v ) <EOL> elif o == "<STR_LIT>" : <EOL> NUM_THREADS = int ( v ) <EOL> test_main ( ) </s>
