Skip to content

Commit

Permalink
Lul, fix everything for cluster helper
Browse files Browse the repository at this point in the history
  • Loading branch information
goodboy committed Oct 6, 2021
1 parent 3f8f848 commit 38b844f
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions tractor/_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ async def open_actor_cluster(
count: int = cpu_count(),
names: Optional[list[str]] = None,

) -> AsyncGenerator[..., dict[str, tractor.Portal]]:
) -> AsyncGenerator[
list[str],
dict[str, tractor.Portal]
]:

portals: dict[str, tractor.Portal] = {}
uid = tractor.current_actor().uid
Expand All @@ -30,20 +33,18 @@ async def open_actor_cluster(
raise ValueError(
'Number of names is {len(names)} but count it {count}')

async with (
tractor.open_nursery() as an,
trio.open_nursery() as n,
):
for index, key in zip(range(count), names):
async with tractor.open_nursery() as an:
async with trio.open_nursery() as n:
for index, key in zip(range(count), names):

async def start(i) -> None:
key = f'worker_{i}.' + '_'.join(uid)
portals[key] = await an.start_actor(
enable_modules=modules,
name=key,
)
async def start(i) -> None:
key = f'worker_{i}.' + '_'.join(uid)
portals[key] = await an.start_actor(
enable_modules=modules,
name=key,
)

n.start_soon(start, index)
n.start_soon(start, index)

assert len(portals) == count
yield portals

0 comments on commit 38b844f

Please sign in to comment.