Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions aiomultiprocess/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import os
import sys
from typing import Any, Callable, Dict, Optional, Sequence

from .types import Context, R, Unit

DEFAULT_START_METHOD = "spawn"
Expand Down Expand Up @@ -114,7 +113,7 @@ def __init__(
initargs=initargs,
loop_initializer=loop_initializer,
)
self.aio_process = context.Process( # type: ignore[attr-defined]
self.aio_process: multiprocessing.Process = context.Process( # type: ignore[attr-defined]
group=group,
target=process_target or Process.run_async,
args=(self.unit,),
Expand Down Expand Up @@ -160,11 +159,14 @@ async def join(self, timeout: Optional[int] = None) -> None:
if not self.is_alive() and self.exitcode is None:
raise ValueError("must start process before joining it")

if timeout is not None:
return await asyncio.wait_for(self.join(), timeout)

if timeout:
return await asyncio.wait_for(self.join, timeout)
Comment on lines -163 to +164

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes seem strange. asyncio.wait_for() expects an awaitable object, not a function. Also, this code will not work correctly for timeout=0. It is better to leave it unchanged here.

while self.exitcode is None:
await asyncio.sleep(0.005)
await asyncio.to_thread(self.aio_process.join, 0.005)




@property
def name(self) -> str:
Expand Down