MCPcopy
hub / github.com/python-trio/trio / put_nowait

Method put_nowait

src/trio/_core/_unbounded_queue.py:94–110  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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()

Callers 12

runMethod · 0.80
run_systemMethod · 0.80
in_trio_threadMethod · 0.80
run_syncMethod · 0.80
process_eventsMethod · 0.80
process_eventsMethod · 0.80
trio_mainFunction · 0.80

Calls 1

unparkMethod · 0.80