Busy loop until connection is established. Will abort after timeout (seconds). Return value is a boolean, whether connection could be established.
(self, timeout=10)
| 64 | self._cf.close_link() |
| 65 | |
| 66 | def wait_for_connection(self, timeout=10): |
| 67 | """ |
| 68 | Busy loop until connection is established. |
| 69 | |
| 70 | Will abort after timeout (seconds). Return value is a boolean, whether |
| 71 | connection could be established. |
| 72 | |
| 73 | """ |
| 74 | start_time = datetime.datetime.now() |
| 75 | while True: |
| 76 | if self.connected: |
| 77 | return True |
| 78 | now = datetime.datetime.now() |
| 79 | if (now - start_time).total_seconds() > timeout: |
| 80 | return False |
| 81 | time.sleep(0.5) |
| 82 | |
| 83 | def search_memories(self): |
| 84 | """ |