Remove use of tractor.run()

eg_worker_poolz
Tyler Goodlet 2021-01-17 13:34:52 -05:00
parent 2555765882
commit 3c320f467f
1 changed files with 13 additions and 12 deletions

View File

@ -50,7 +50,14 @@ async def worker_pool(workers=4):
"""
async with tractor.open_nursery() as tn:
async with tractor.open_nursery(
loglevel='ERROR',
# uncomment to use ``multiprocessing`` fork server backend
# which gives a startup time boost at the expense of nested
# processs scalability
# start_method='forkserver')
) as tn:
portals = []
results = []
@ -62,7 +69,7 @@ async def worker_pool(workers=4):
portals.append(
await tn.start_actor(
f'worker_{i}',
rpc_module_paths=[__name__],
enable_modules=[__name__],
)
)
@ -105,15 +112,9 @@ async def main():
print(f'processing took {time.time() - start} seconds')
if __name__ == '__main__':
start = time.time()
tractor.run(
main,
loglevel='ERROR',
# uncomment to use ``multiprocessing`` fork server backend
# which gives a startup time boost at the expense of nested
# processs scalability
# start_method='forkserver')
)
if __name__ == '__main__':
start = time.time()
trio.run(main)
print(f'script took {time.time() - start} seconds')