Stop the background thread and clear registered resources.
(self, timeout=None)
| 88 | return c |
| 89 | |
| 90 | def stop(self, timeout=None): |
| 91 | '''Stop the background thread and clear registered resources.''' |
| 92 | from .connection import Client |
| 93 | with self._lock: |
| 94 | if self._address is not None: |
| 95 | c = Client(self._address, |
| 96 | authkey=process.current_process().authkey) |
| 97 | c.send(None) |
| 98 | c.close() |
| 99 | self._thread.join(timeout) |
| 100 | if self._thread.is_alive(): |
| 101 | util.sub_warning('_ResourceSharer thread did ' |
| 102 | 'not stop when asked') |
| 103 | self._listener.close() |
| 104 | self._thread = None |
| 105 | self._address = None |
| 106 | self._listener = None |
| 107 | for key, (send, close) in self._cache.items(): |
| 108 | close() |
| 109 | self._cache.clear() |
| 110 | |
| 111 | def _afterfork(self): |
| 112 | for key, (send, close) in self._cache.items(): |