| 116 | self.shm.close_handle() |
| 117 | |
| 118 | def close(self): |
| 119 | if self.is_closed: |
| 120 | return |
| 121 | with self.lock: |
| 122 | self._read_meta() |
| 123 | self.is_closed = True |
| 124 | if not self.meta.is_closed: |
| 125 | self.meta.is_closed = 1 |
| 126 | self._write_meta() |
| 127 | # Notify only one waiting worker about closing the queue, the woken up worker |
| 128 | # will notify the next one. Avoid notify_all at this point, due to possible |
| 129 | # deadlock if one of the notified workers exited abruptly when waiting |
| 130 | # on cv_not_empty without proper releasing of the underlying semaphore. |
| 131 | self.cv_not_empty.notify() |
| 132 | |
| 133 | def put(self, msgs: List[MSG_CLASS]) -> Optional[int]: |
| 134 | assert len(msgs), "Cannot write an empty list of messages" |