Drop tractor.run() from @tractor_test
parent
41a4de5af2
commit
32b10681a1
|
@ -2,7 +2,9 @@ import inspect
|
||||||
import platform
|
import platform
|
||||||
from functools import partial, wraps
|
from functools import partial, wraps
|
||||||
|
|
||||||
from tractor import run
|
import trio
|
||||||
|
import tractor
|
||||||
|
# from tractor import run
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['tractor_test']
|
__all__ = ['tractor_test']
|
||||||
|
@ -34,6 +36,7 @@ def tractor_test(fn):
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
# __tracebackhide__ = True
|
# __tracebackhide__ = True
|
||||||
|
|
||||||
if 'arb_addr' in inspect.signature(fn).parameters:
|
if 'arb_addr' in inspect.signature(fn).parameters:
|
||||||
# injects test suite fixture value to test as well
|
# injects test suite fixture value to test as well
|
||||||
# as `run()`
|
# as `run()`
|
||||||
|
@ -54,11 +57,33 @@ def tractor_test(fn):
|
||||||
# set of subprocess spawning backends
|
# set of subprocess spawning backends
|
||||||
kwargs['start_method'] = start_method
|
kwargs['start_method'] = start_method
|
||||||
|
|
||||||
return run(
|
if kwargs:
|
||||||
partial(fn, *args, **kwargs),
|
|
||||||
|
# use explicit root actor start
|
||||||
|
|
||||||
|
async def _main():
|
||||||
|
async with tractor.open_root_actor(
|
||||||
|
# **kwargs,
|
||||||
arbiter_addr=arb_addr,
|
arbiter_addr=arb_addr,
|
||||||
loglevel=loglevel,
|
loglevel=loglevel,
|
||||||
start_method=start_method,
|
start_method=start_method,
|
||||||
)
|
|
||||||
|
# TODO: only enable when pytest is passed --pdb
|
||||||
|
# debug_mode=True,
|
||||||
|
|
||||||
|
) as actor:
|
||||||
|
await fn(*args, **kwargs)
|
||||||
|
|
||||||
|
main = _main
|
||||||
|
|
||||||
|
else:
|
||||||
|
# use implicit root actor start
|
||||||
|
main = partial(fn, *args, **kwargs),
|
||||||
|
|
||||||
|
return trio.run(main)
|
||||||
|
# arbiter_addr=arb_addr,
|
||||||
|
# loglevel=loglevel,
|
||||||
|
# start_method=start_method,
|
||||||
|
# )
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
Loading…
Reference in New Issue