def CheckTwoThreads(self):
        def reader(dbpath):
            reader = sqlite.connect(dbpath, timeout=2000)
            cu = reader.cursor()
            while True:
                l = [ x for x in cu.execute('SELECT * from foo') ]
                if l == [ None ]:
                    break
            thread.exit()

        fd, dbfile = tempfile.mkstemp()
        os.close(fd)
        writer = sqlite.connect(dbfile, timeout=500)
        cu = writer.cursor()
        cu.execute('CREATE TABLE foo(bar int)')
        writer.commit()
        thread.start_new_thread(reader, (dbfile,))
        for i in xrange(100):
            cu.execute('INSERT INTO foo values(?)', (i,))
            if i % 10 == 0:
                writer.commit()
            if i % 20 == 0:
                cu.execute('DELETE FROM foo')
                writer.commit()
        cu.execute('INSERT INTO foo VALUES(NULL)')
        writer.commit()
dataset/ETHPy150Open sassoftware/conary/conary/pysqlite3/test/thread_tests.py/ThreadTests.CheckTwoThreads/original