Skip to content

Commit

Permalink
ENH: Copy sub_processes in monitor_sub_pools (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
codingl2k1 authored Dec 6, 2023
1 parent d656b62 commit c7f3de4
Showing 1 changed file with 5 additions and 1 deletion.
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

0 comments on commit c7f3de4

Please sign in to comment.