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)
| 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.""" |