Thread-safe enqueue of one outbound SDK message. Every message is passed through ``_json_safe`` so a stray non-serializable value can never make the server's ``json.dumps`` in the WS pump raise and silently kill the outbound stream.
(self, msg: dict)
| 133 | # ─── outbound helpers (worker thread → main loop) ────────────────────── |
| 134 | |
| 135 | def _emit(self, msg: dict) -> None: |
| 136 | """Thread-safe enqueue of one outbound SDK message. |
| 137 | |
| 138 | Every message is passed through ``_json_safe`` so a stray |
| 139 | non-serializable value can never make the server's ``json.dumps`` in |
| 140 | the WS pump raise and silently kill the outbound stream. |
| 141 | """ |
| 142 | try: |
| 143 | self.loop.call_soon_threadsafe(self.out_queue.put_nowait, _json_safe(msg)) |
| 144 | except RuntimeError: |
| 145 | # Loop closed (server shutting down) — drop. |
| 146 | pass |
| 147 | |
| 148 | def _close_stream(self) -> None: |
| 149 | try: |
no test coverage detected