Commit 99cd1f03 authored by Kirill Smelkov's avatar Kirill Smelkov

bigfile/tests: move NotifyChannel to test_thread.py

NotifyChannel was introduced in c7c01ce4 (bigfile/zodb: ZODB.Connection
can migrate between threads on close/open and we have to care) to test
thread interaction specific to ZODB.

We'll however need NotifyChannel to do more threading test of virtmem
core, and this way the proper place for NotifyChannel is test_thread.py
itself.

Move it.
parent 81bf620c
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
# #
# See COPYING file for full licensing terms. # See COPYING file for full licensing terms.
from wendelin.bigarray.array_zodb import ZBigArray from wendelin.bigarray.array_zodb import ZBigArray
from wendelin.bigfile.tests.test_filezodb import kkey, cacheInfo, NotifyChannel, ram_reclaim_all from wendelin.bigfile.tests.test_filezodb import kkey, cacheInfo, ram_reclaim_all
from wendelin.bigfile.tests.test_thread import NotifyChannel
from wendelin.lib.zodb import dbclose from wendelin.lib.zodb import dbclose
from wendelin.lib.testing import getTestDB from wendelin.lib.testing import getTestDB
from persistent import UPTODATE from persistent import UPTODATE
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
# See COPYING file for full licensing terms. # See COPYING file for full licensing terms.
from wendelin.bigfile.file_zodb import LivePersistent, ZBigFile, ZBlk_fmt_registry from wendelin.bigfile.file_zodb import LivePersistent, ZBigFile, ZBlk_fmt_registry
from wendelin.bigfile import file_zodb, ram_reclaim from wendelin.bigfile import file_zodb, ram_reclaim
from wendelin.bigfile.tests.test_thread import NotifyChannel
from wendelin.lib.zodb import dbclose from wendelin.lib.zodb import dbclose
from wendelin.lib.testing import getTestDB from wendelin.lib.testing import getTestDB
from persistent import UPTODATE, GHOST, CHANGED from persistent import UPTODATE, GHOST, CHANGED
...@@ -343,33 +344,6 @@ def test_bigfile_filezodb(): ...@@ -343,33 +344,6 @@ def test_bigfile_filezodb():
# Notify channel for
# - one thread to .wait('condition'), until
# - other thread does .tell('condition')
class NotifyChannel:
def __init__(self):
self.state = None
def tell(self, condition):
#print >>sys.stderr, ' tell %s\tthread_id: %s\n' \
# % (condition, _thread.get_ident()),
# wait until other thread reads previous tell
while self.state is not None:
pass
self.state = condition
def wait(self, condition):
#print >>sys.stderr, ' wait %s\tthread_id: %s\n' \
# % (condition, _thread.get_ident()),
while self.state != condition:
pass
#print >>sys.stderr, ' have %s\tthread_id: %s\n' \
# % (condition, _thread.get_ident()),
self.state = None
# connection can migrate between threads handling requests. # connection can migrate between threads handling requests.
# verify _ZBigFileH properly adjusts. # verify _ZBigFileH properly adjusts.
# ( NOTE this test is almost dupped at test_zbigarray_vs_conn_migration() ) # ( NOTE this test is almost dupped at test_zbigarray_vs_conn_migration() )
......
...@@ -20,6 +20,34 @@ from threading import Thread ...@@ -20,6 +20,34 @@ from threading import Thread
from time import sleep from time import sleep
from wendelin.bigfile.tests.test_basic import bchr_py2 from wendelin.bigfile.tests.test_basic import bchr_py2
from six.moves import _thread
# Notify channel for
# - one thread to .wait('condition'), until
# - other thread does .tell('condition')
class NotifyChannel:
def __init__(self):
self.state = None
def tell(self, condition):
#print >>sys.stderr, ' tell %s\tthread_id: %s\n' \
# % (condition, _thread.get_ident()),
# wait until other thread reads previous tell
while self.state is not None:
pass
self.state = condition
def wait(self, condition):
#print >>sys.stderr, ' wait %s\tthread_id: %s\n' \
# % (condition, _thread.get_ident()),
while self.state != condition:
pass
#print >>sys.stderr, ' have %s\tthread_id: %s\n' \
# % (condition, _thread.get_ident()),
self.state = None
# Synthetic bigfile that verifies there is no concurrent calls to loadblk # Synthetic bigfile that verifies there is no concurrent calls to loadblk
......
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