<s> import testsupport <EOL> import os , sys , tempfile , time , unittest , thread <EOL> import sqlite3 as sqlite <EOL> class ThreadTests ( unittest . TestCase ) : <EOL> def CheckTwoThreads ( self ) : <EOL> def reader ( dbpath ) : <EOL> reader = sqlite . connect ( dbpath , timeout = <NUM_LIT> ) <EOL> cu = reader . cursor ( ) <EOL> while True : <EOL> l = [ x for x in cu . execute ( '<STR_LIT>' ) ] <EOL> if l == [ None ] : <EOL> break <EOL> thread . exit ( ) <EOL> fd , dbfile = tempfile . mkstemp ( ) <EOL> os . close ( fd ) <EOL> writer = sqlite . connect ( dbfile , timeout = <NUM_LIT> ) <EOL> cu = writer . cursor ( ) <EOL> cu . execute ( '<STR_LIT>' ) <EOL> writer . commit ( ) <EOL> thread . start_new_thread ( reader , ( dbfile , ) ) <EOL> for i in xrange ( <NUM_LIT:100> ) : <EOL> cu . execute ( '<STR_LIT>' , ( i , ) ) <EOL> if i % <NUM_LIT:10> == <NUM_LIT:0> : <EOL> writer . commit ( ) <EOL> if i % <NUM_LIT:20> == <NUM_LIT:0> : <EOL> cu . execute ( '<STR_LIT>' ) <EOL> writer . commit ( ) <EOL> cu . execute ( '<STR_LIT>' ) <EOL> writer . commit ( ) <EOL> def suite ( ) : <EOL> thread_suite = unittest . makeSuite ( ThreadTests , "<STR_LIT>" ) <EOL> test_suite = unittest . TestSuite ( ( thread_suite , ) ) <EOL> return test_suite <EOL> def main ( ) : <EOL> runner = unittest . TextTestRunner ( ) <EOL> runner . run ( suite ( ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
