Put an object into the queue, without blocking. This always succeeds, because the queue is unbounded. We don't provide a blocking ``put`` method, because it would never need to block. Args: obj (object): The object to enqueue.
(self, obj: T)
| 92 | |
| 93 | @_core.enable_ki_protection |
| 94 | def put_nowait(self, obj: T) -> None: |
| 95 | """Put an object into the queue, without blocking. |
| 96 | |
| 97 | This always succeeds, because the queue is unbounded. We don't provide |
| 98 | a blocking ``put`` method, because it would never need to block. |
| 99 | |
| 100 | Args: |
| 101 | obj (object): The object to enqueue. |
| 102 | |
| 103 | """ |
| 104 | if not self._data: |
| 105 | assert not self._can_get |
| 106 | if self._lot: |
| 107 | self._lot.unpark(count=1) |
| 108 | else: |
| 109 | self._can_get = True |
| 110 | self._data.append(obj) |
| 111 | |
| 112 | def _get_batch_protected(self) -> list[T]: |
| 113 | data = self._data.copy() |