MCPcopy Create free account
hub / github.com/miguelgrinberg/python-socketio / receive

Method receive

src/socketio/simple_client.py:163–183  ·  view source on GitHub ↗

Wait for an event from the server. :param timeout: The waiting timeout. If the timeout is reached before the server acknowledges the event, then a ``TimeoutError`` exception is raised. The return value is a list with the event name as

(self, timeout=None)

Source from the content-addressed store, hash-verified

161 pass
162
163 def receive(self, timeout=None):
164 """Wait for an event from the server.
165
166 :param timeout: The waiting timeout. If the timeout is reached before
167 the server acknowledges the event, then a
168 ``TimeoutError`` exception is raised.
169
170 The return value is a list with the event name as the first element. If
171 the server included arguments with the event, they are returned as
172 additional list elements.
173 """
174 while not self.input_buffer:
175 if not self.connected_event.wait(
176 timeout=timeout): # pragma: no cover
177 raise TimeoutError()
178 if not self.connected:
179 raise DisconnectedError()
180 if not self.input_event.wait(timeout=timeout):
181 raise TimeoutError()
182 self.input_event.clear()
183 return self.input_buffer.pop(0)
184
185 def disconnect(self):
186 """Disconnect from the server."""

Callers 12

_expectMethod · 0.45
test_admin_featuresMethod · 0.45
_expectMethod · 0.45
test_admin_featuresMethod · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45

Calls 3

TimeoutErrorClass · 0.90
DisconnectedErrorClass · 0.90
waitMethod · 0.45

Tested by 8

_expectMethod · 0.36
test_admin_featuresMethod · 0.36
_expectMethod · 0.36
test_admin_featuresMethod · 0.36