diff --git a/src/socketio/async_simple_client.py b/src/socketio/async_simple_client.py index 61425220..a4d0928d 100644 --- a/src/socketio/async_simple_client.py +++ b/src/socketio/async_simple_client.py @@ -163,6 +163,8 @@ async def call(self, event, data=None, timeout=60): return await self.client.call(event, data, namespace=self.namespace, timeout=timeout) + except TimeoutError: + raise except SocketIOError: pass diff --git a/src/socketio/simple_client.py b/src/socketio/simple_client.py index 9bc5390c..7e1a8a5b 100644 --- a/src/socketio/simple_client.py +++ b/src/socketio/simple_client.py @@ -155,6 +155,8 @@ def call(self, event, data=None, timeout=60): try: return self.client.call(event, data, namespace=self.namespace, timeout=timeout) + except TimeoutError: + raise except SocketIOError: pass diff --git a/tests/async/test_simple_client.py b/tests/async/test_simple_client.py index 0f3e5045..b7f0193c 100644 --- a/tests/async/test_simple_client.py +++ b/tests/async/test_simple_client.py @@ -142,6 +142,17 @@ async def test_call_retries(self): client.client.call.assert_awaited_with('foo', 'bar', namespace='/', timeout=60) + async def test_call_timeout(self): + client = AsyncSimpleClient() + client.connected_event.set() + client.connected = True + client.client = mock.MagicMock() + client.client.call = mock.AsyncMock() + client.client.call.side_effect = TimeoutError() + + with pytest.raises(TimeoutError): + await client.call('foo', 'bar') + async def test_receive_with_input_buffer(self): client = AsyncSimpleClient() client.input_buffer = ['foo', 'bar'] diff --git a/tests/common/test_simple_client.py b/tests/common/test_simple_client.py index 6adcb382..43236fe8 100644 --- a/tests/common/test_simple_client.py +++ b/tests/common/test_simple_client.py @@ -130,6 +130,16 @@ def test_call_retries(self): client.client.call.assert_called_with('foo', 'bar', namespace='/', timeout=60) + def test_call_timeout(self): + client = SimpleClient() + client.connected_event.set() + client.connected = True + client.client = mock.MagicMock() + client.client.call.side_effect = TimeoutError() + + with pytest.raises(TimeoutError): + client.call('foo', 'bar') + def test_receive_with_input_buffer(self): client = SimpleClient() client.input_buffer = ['foo', 'bar']