Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Copy sub_processes in monitor_sub_pools #80

Merged
merged 2 commits into from
Dec 6, 2023
Merged
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
6 changes: 5 additions & 1 deletion python/xoscar/backends/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,13 +911,16 @@ def _parse_config(config: dict, kw: dict) -> dict:

class MainActorPoolBase(ActorPoolBase):
__slots__ = (
"_subprocess_start_method",
"_allocated_actors",
"sub_actor_pool_manager",
"_auto_recover",
"_monitor_task",
"_on_process_down",
"_on_process_recover",
"_recover_events",
"_allocation_lock",
"sub_processes",
)

def __init__(
Expand Down Expand Up @@ -1389,7 +1392,8 @@ def process_sub_pool_lost(self, address: str):
async def monitor_sub_pools(self):
try:
while not self._stopped.is_set():
for address, process in self.sub_processes.items():
# Copy sub_processes to avoid changes during recover.
for address, process in list(self.sub_processes.items()):
try:
recover_events_discovered = address in self._recover_events
if not await self.is_sub_pool_alive(
Expand Down
Loading