Skip to content

Commit 8108eb0

Browse files
committed
refactor(client_sync, transport): remove unused attributes and improve event loop timeout handling
1 parent b9d6468 commit 8108eb0

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

src/wokwi_client/client_sync.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ class WokwiClientSync:
3939
tracked, so we can cancel & drain them on `disconnect()`.
4040
"""
4141

42-
# Public attributes mirrored for convenience
43-
version: str
44-
last_pause_nanos: int # this proxy resolves via __getattr__
45-
4642
def __init__(self, token: str, server: str | None = None):
4743
# Create a new event loop for the background thread
4844
self._loop = asyncio.new_event_loop()
@@ -54,12 +50,10 @@ def __init__(self, token: str, server: str | None = None):
5450
)
5551
self._thread.start()
5652
# **Wait until loop is fully started before proceeding** (prevents race conditions)
57-
if not self._loop_started_event.wait(timeout=5.0): # timeout to avoid deadlock
53+
if not self._loop_started_event.wait(timeout=8.0): # timeout to avoid deadlock
5854
raise RuntimeError("WokwiClientSync event loop failed to start")
5955
# Initialize underlying async client on the running loop
6056
self._async_client = WokwiClient(token, server)
61-
# Mirror version attribute for quick access
62-
self.version = self._async_client.version
6357
# Track background monitor tasks (futures) for cancellation on exit
6458
self._bg_futures: set[Future[Any]] = set()
6559
# Flag to avoid double-closing

src/wokwi_client/transport.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,12 @@ async def connect(self, throw_error: bool = True) -> dict[str, Any]:
4444
"User-Agent": f"wokwi-client-py/{get_version()}",
4545
},
4646
)
47-
# Handshake: read the hello BEFORE starting the background loop.
4847
hello: IncomingMessage = await self._recv()
4948
if hello["type"] != MSG_TYPE_HELLO or hello.get("protocolVersion") != PROTOCOL_VERSION:
5049
raise ProtocolError(f"Unsupported protocol handshake: {hello}")
5150
hello_msg = cast(HelloMessage, hello)
5251
self._closed = False
53-
# Start background message processor AFTER successful hello.
52+
# Start background message processor after successful hello.
5453
self._recv_task = asyncio.create_task(self._background_recv(throw_error))
5554
return {"version": hello_msg["appVersion"]}
5655

0 commit comments

Comments
 (0)