Wait until the connection with the server ends. Client applications can use this function to block the main thread during the life of the connection.
(self)
| 175 | self.connected = True |
| 176 | |
| 177 | def wait(self): |
| 178 | """Wait until the connection with the server ends. |
| 179 | |
| 180 | Client applications can use this function to block the main thread |
| 181 | during the life of the connection. |
| 182 | """ |
| 183 | while True: |
| 184 | self.eio.wait() |
| 185 | self.sleep(1) # give the reconnect task time to start up |
| 186 | if not self._reconnect_task: |
| 187 | if self.eio.state == 'connected': # pragma: no cover |
| 188 | # connected while sleeping above |
| 189 | continue |
| 190 | else: |
| 191 | # the reconnect task gave up |
| 192 | break |
| 193 | self._reconnect_task.join() |
| 194 | if self.eio.state != 'connected': |
| 195 | break |
| 196 | |
| 197 | def emit(self, event, data=None, namespace=None, callback=None): |
| 198 | """Emit a custom event to the server. |