__init__.py
46 lines
| 1.2 KiB
| text/x-python
|
PythonLexer
MinRK
|
r3637 | """toplevel setup/teardown for parallel tests.""" | ||
MinRK
|
r3654 | import tempfile | ||
MinRK
|
r3595 | import time | ||
MinRK
|
r3654 | from subprocess import Popen, PIPE, STDOUT | ||
MinRK
|
r3595 | |||
from IPython.zmq.parallel.ipcluster import launch_process | ||||
from IPython.zmq.parallel.entry_point import select_random_ports | ||||
MinRK
|
r3637 | processes = [] | ||
MinRK
|
r3654 | blackhole = tempfile.TemporaryFile() | ||
MinRK
|
r3637 | |||
# nose setup/teardown | ||||
MinRK
|
r3595 | |||
def setup(): | ||||
MinRK
|
r3654 | cp = Popen('ipcontrollerz --profile iptest -r --log-level 40'.split(), stdout=blackhole, stderr=STDOUT) | ||
MinRK
|
r3637 | processes.append(cp) | ||
time.sleep(.5) | ||||
add_engine() | ||||
MinRK
|
r3654 | time.sleep(2) | ||
MinRK
|
r3595 | |||
MinRK
|
r3637 | def add_engine(profile='iptest'): | ||
MinRK
|
r3654 | ep = Popen(['ipenginez']+ ['--profile', profile, '--log-level', '40'], stdout=blackhole, stderr=STDOUT) | ||
MinRK
|
r3595 | # ep.start() | ||
MinRK
|
r3637 | processes.append(ep) | ||
MinRK
|
r3595 | return ep | ||
def teardown(): | ||||
time.sleep(1) | ||||
while processes: | ||||
p = processes.pop() | ||||
if p.poll() is None: | ||||
try: | ||||
p.terminate() | ||||
except Exception, e: | ||||
print e | ||||
pass | ||||
if p.poll() is None: | ||||
time.sleep(.25) | ||||
if p.poll() is None: | ||||
try: | ||||
print 'killing' | ||||
p.kill() | ||||
except: | ||||
print "couldn't shutdown process: ",p | ||||