[server test] use a lock instead of sleep to have higher green probability :/ stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 09 May 2011 14:34:23 +0200
branchstable
changeset 7339 dd5e49a5dcab
parent 7337 67cd9d5b4c2e
child 7340 9303fd71c2ee
[server test] use a lock instead of sleep to have higher green probability :/
server/test/unittest_repository.py
--- a/server/test/unittest_repository.py	Mon May 09 12:03:03 2011 +0200
+++ b/server/test/unittest_repository.py	Mon May 09 14:34:23 2011 +0200
@@ -277,13 +277,16 @@
         cnxid = repo.connect(self.admlogin, password=self.admpassword)
         repo.execute(cnxid, 'INSERT CWUser X: X login "toto", X upassword "tutu", X in_group G WHERE G name "users"')
         repo.commit(cnxid)
+        lock = threading.Lock(), threading.Lock()
+        lock.acquire()
         # close has to be in the thread due to sqlite limitations
         def close_in_a_few_moment():
-            time.sleep(0.1)
+            lock.acquire()
             repo.close(cnxid)
         t = threading.Thread(target=close_in_a_few_moment)
         t.start()
         def run_transaction():
+            lock.release()
             repo.execute(cnxid, 'DELETE CWUser X WHERE X login "toto"')
             repo.commit(cnxid)
         try: