[py-svn] r31521 - in py/branch/distributed/py/test/rsession: . testing
hpk at codespeak.net
hpk at codespeak.net
Wed Aug 23 12:14:46 CEST 2006
Author: hpk
Date: Wed Aug 23 12:14:32 2006
New Revision: 31521
Modified:
py/branch/distributed/py/test/rsession/master.py
py/branch/distributed/py/test/rsession/rsession.py
py/branch/distributed/py/test/rsession/testing/test_dispatcher.py
Log:
(fijal, hpk) Remove Event logic, just have an optional waiter function.
Modified: py/branch/distributed/py/test/rsession/master.py
==============================================================================
--- py/branch/distributed/py/test/rsession/master.py (original)
+++ py/branch/distributed/py/test/rsession/master.py Wed Aug 23 12:14:32 2006
@@ -23,7 +23,8 @@
itemspec = item.listnames()
self.channel.send(itemspec)
-def dispatch_loop(masternodes, itemgenerator, shouldstop, event,
+def dispatch_loop(masternodes, itemgenerator, shouldstop,
+ waiter = lambda: py.std.time.sleep(0.1),
maxtasks_per_node = MAX_TASKS_PER_NODE):
while 1:
try:
@@ -35,12 +36,8 @@
node.send(item)
except StopIteration:
break
- event.wait(3) # XXX argh
- event.clear()
+ waiter()
- # XXX: wait here for completion
-
-
def bin_rsync(source, sshaddress, destpath):
_rsync = py.path.local.sysfind("rsync")
print "rsyncing", source, "to", sshaddress, destpath
Modified: py/branch/distributed/py/test/rsession/rsession.py
==============================================================================
--- py/branch/distributed/py/test/rsession/rsession.py (original)
+++ py/branch/distributed/py/test/rsession/rsession.py Wed Aug 23 12:14:32 2006
@@ -13,7 +13,6 @@
self.config = config
def report(self, *whatever):
- self.event.set()
print whatever
def iteritems(self, colitems):
@@ -42,7 +41,6 @@
rootdir = getrootdir(args)
nodes = []
import threading
- self.event = threading.Event()
nodes_lock = threading.Condition()
def host_init(host):
@@ -67,7 +65,7 @@
nodes_lock.release()
itemgenerator = self.iteritems(colitems)
- dispatch_loop(nodes, itemgenerator, lambda : False, self.event)
+ dispatch_loop(nodes, itemgenerator, lambda : False)
print "INITIALIZED, dying now ..."
import time
time.sleep(3)
Modified: py/branch/distributed/py/test/rsession/testing/test_dispatcher.py
==============================================================================
--- py/branch/distributed/py/test/rsession/testing/test_dispatcher.py (original)
+++ py/branch/distributed/py/test/rsession/testing/test_dispatcher.py Wed Aug 23 12:14:32 2006
@@ -20,23 +20,14 @@
def send(self, data):
self.pending.append(data)
-class DummyEvent(object):
- def __init__(self, nodes):
- self.nodes = nodes
-
- def wait(self, timeout = None):
- for node in self.nodes:
- node.pending.pop()
-
- def clear(self):
- pass
-
def test_dispatch_loop():
masternodes = [DummyMasterNode(), DummyMasterNode()]
- event = DummyEvent(masternodes)
itemgenerator = iter(range(100))
shouldstop = lambda : False
- dispatch_loop(masternodes, itemgenerator, shouldstop, event)
+ def waiter():
+ for node in masternodes:
+ node.pending.pop()
+ dispatch_loop(masternodes, itemgenerator, shouldstop, waiter=waiter)
def test_slave_setup():
gw = py.execnet.PopenGateway()
@@ -49,10 +40,7 @@
gw.exit()
def test_slave_running():
- event = threading.Event()
-
def simple_reporter(result):
- event.set()
item, res = result
if item.code.name == 'funcpass':
assert res.passed
@@ -74,4 +62,4 @@
funcfail_item.parent.parent.parent.parent.parent.parent = None
itemgenerator = iter([funcfail_item] + [funcpass_item] * 5 + [funcfail_item] * 5)
shouldstop = lambda : False
- dispatch_loop(master_nodes, itemgenerator, shouldstop, event)
+ dispatch_loop(master_nodes, itemgenerator, shouldstop)
More information about the pytest-commit
mailing list