Create and start the background event loop. This is called once during initialization to create the dedicated event loop for all socket I/O operations.
(self)
| 504 | self._pending_futures.pop(request_id, None) |
| 505 | |
| 506 | def _ensure_event_loop(self): |
| 507 | """Create and start the background event loop. |
| 508 | |
| 509 | This is called once during initialization to create the dedicated |
| 510 | event loop for all socket I/O operations. |
| 511 | """ |
| 512 | if self._loop is not None: |
| 513 | return # Already created |
| 514 | |
| 515 | self._loop = asyncio.new_event_loop() |
| 516 | |
| 517 | def run_loop(): |
| 518 | asyncio.set_event_loop(self._loop) |
| 519 | self._loop.run_forever() |
| 520 | |
| 521 | self._loop_thread = threading.Thread(target=run_loop, |
| 522 | daemon=True, |
| 523 | name="rpc_client_loop") |
| 524 | self._loop_thread.start() |
| 525 | |
| 526 | # Wait briefly to ensure the loop is running before returning |
| 527 | time.sleep(0.2) |
| 528 | |
| 529 | def _call_sync(self, method_name, *args, **kwargs): |
| 530 | """Synchronous version of RPC call.""" |