From 733bd59f4fad158d1adf1067293ed2afe84830ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Wed, 15 May 2024 10:28:13 +0200 Subject: [PATCH] Apply review comment --- jupyter_client/channels.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/jupyter_client/channels.py b/jupyter_client/channels.py index ea1f4cbf..465dccdf 100644 --- a/jupyter_client/channels.py +++ b/jupyter_client/channels.py @@ -220,12 +220,11 @@ def _recv(self, **kwargs: t.Any) -> t.Dict[str, t.Any]: ident, smsg = self.session.feed_identities(msg) return self.session.deserialize(smsg) - def get_msg(self, timeout: t.Optional[int] = None) -> t.Dict[str, t.Any]: + def get_msg(self, timeout: t.Optional[float] = None) -> t.Dict[str, t.Any]: """Gets a message if there is one that is ready.""" assert self.socket is not None - if timeout is not None: - timeout *= 1000 # seconds to ms - ready = self.socket.poll(timeout) + timeout_ms = None if timeout is None else int(timeout * 1000) # seconds to ms + ready = self.socket.poll(timeout_ms) if ready: res = self._recv() return res @@ -305,9 +304,8 @@ async def get_msg( # type:ignore[override] ) -> t.Dict[str, t.Any]: """Gets a message if there is one that is ready.""" assert self.socket is not None - if timeout is not None: - timeout *= 1000 # seconds to ms - ready = await self.socket.poll(timeout) + timeout_ms = None if timeout is None else int(timeout * 1000) # seconds to ms + ready = await self.socket.poll(timeout_ms) if ready: res = await self._recv() return res