Commit fec9a3a5 authored by Julien Muchembled's avatar Julien Muchembled

qa: fix random failure of check_checkCurrentSerialInTransaction

Generators are not thread-safe:

Exception in thread T2:
Traceback (most recent call last):
  ...
  File "ZODB/tests/StorageTestBase.py", line 157, in _dostore
    r2 = self._storage.tpc_vote(t)
  File "neo/client/Storage.py", line 95, in tpc_vote
    return self.app.tpc_vote(transaction)
  File "neo/client/app.py", line 507, in tpc_vote
    self.waitStoreResponses(txn_context)
  File "neo/client/app.py", line 500, in waitStoreResponses
    _waitAnyTransactionMessage(txn_context)
  File "neo/client/app.py", line 145, in _waitAnyTransactionMessage
    self._waitAnyMessage(queue, block=block)
  File "neo/client/app.py", line 128, in _waitAnyMessage
    conn, packet, kw = get(block)
  File "neo/lib/locking.py", line 203, in get
    self._lock()
  File "neo/tests/threaded/__init__.py", line 590, in _lock
    for i in TIC_LOOP:
ValueError: generator already executing

======================================================================
FAIL: check_checkCurrentSerialInTransaction (neo.tests.zodb.testBasic.BasicTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "neo/tests/zodb/testBasic.py", line 33, in check_checkCurrentSerialInTransaction
    super(BasicTests, self).check_checkCurrentSerialInTransaction()
  File "ZODB/tests/BasicStorage.py", line 294, in check_checkCurrentSerialInTransaction
    utils.load_current(self._storage, b'\0\0\0\0\0\0\0\xf4')[1])
failureException: False is not true
parent a74937c8
......@@ -22,14 +22,21 @@ from ZODB.tests.StorageTestBase import StorageTestBase
from . import ZODBTestCase
from .. import Patch, threaded
class TIC_LOOP(object):
def __init__(self):
self.stop = time.time() + 10
def __iter__(self):
def tic_loop(t=time.time, x=self.stop):
while t() < x:
yield
return tic_loop()
class BasicTests(ZODBTestCase, StorageTestBase, BasicStorage):
def check_checkCurrentSerialInTransaction(self):
x = time.time() + 10
def tic_loop():
while time.time() < x:
yield
with Patch(threaded, TIC_LOOP=tic_loop()):
with Patch(threaded, TIC_LOOP=TIC_LOOP()):
super(BasicTests, self).check_checkCurrentSerialInTransaction()
if __name__ == "__main__":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment