use explicit multiprocessing context for creating Pipe in subproc.py (#1102)
This commit is contained in:
parent
a043711c10
commit
9c0b3e7292
8
tianshou/env/worker/subproc.py
vendored
8
tianshou/env/worker/subproc.py
vendored
@ -3,7 +3,7 @@ import multiprocessing
|
||||
import time
|
||||
from collections import OrderedDict
|
||||
from collections.abc import Callable
|
||||
from multiprocessing import Pipe, connection
|
||||
from multiprocessing import connection
|
||||
from multiprocessing.context import BaseContext
|
||||
from typing import Any, Literal
|
||||
|
||||
@ -149,11 +149,11 @@ class SubprocEnvWorker(EnvWorker):
|
||||
share_memory: bool = False,
|
||||
context: BaseContext | Literal["fork", "spawn"] | None = None,
|
||||
) -> None:
|
||||
self.parent_remote, self.child_remote = Pipe()
|
||||
self.share_memory = share_memory
|
||||
self.buffer: dict | tuple | ShArray | None = None
|
||||
if not isinstance(context, BaseContext):
|
||||
context = multiprocessing.get_context(context)
|
||||
self.parent_remote, self.child_remote = context.Pipe()
|
||||
self.share_memory = share_memory
|
||||
self.buffer: dict | tuple | ShArray | None = None
|
||||
assert hasattr(context, "Process") # for mypy
|
||||
if self.share_memory:
|
||||
dummy = env_fn()
|
||||
|
Loading…
x
Reference in New Issue
Block a user