Wake up main thread. The server usually waits in select call in we should terminate one. The simplest way is using socketpair. Select always wait to read from the first socket of socketpair. In this case, we can just write anything to the second socket from
(self)
| 273 | self.prepared = True |
| 274 | |
| 275 | def wake_up(self): |
| 276 | """Wake up main thread. |
| 277 | |
| 278 | The server usually waits in select call in we should terminate one. |
| 279 | The simplest way is using socketpair. |
| 280 | |
| 281 | Select always wait to read from the first socket of socketpair. |
| 282 | |
| 283 | In this case, we can just write anything to the second socket from |
| 284 | socketpair. |
| 285 | """ |
| 286 | self._write.send(b'1') |
| 287 | |
| 288 | def stop(self): |
| 289 | """Stop the server. |