MCPcopy Index your code
hub / github.com/python/cpython / put

Method put

Lib/asyncio/queues.py:125–154  ·  view source on GitHub ↗

Put an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. Raises QueueShutDown if the queue has been shut down.

(self, item)

Source from the content-addressed store, hash-verified

123 return self.qsize() >= self._maxsize
124
125 async def put(self, item):
126 """Put an item into the queue.
127
128 Put an item into the queue. If the queue is full, wait until a free
129 slot is available before adding item.
130
131 Raises QueueShutDown if the queue has been shut down.
132 """
133 while self.full():
134 if self._is_shutdown:
135 raise QueueShutDown
136 putter = self._get_loop().create_future()
137 self._putters.append(putter)
138 try:
139 await putter
140 except:
141 putter.cancel() # Just in case putter is not done yet.
142 try:
143 # Clean self._putters from canceled putters.
144 self._putters.remove(putter)
145 except ValueError:
146 # The putter could be removed from self._putters by a
147 # previous get_nowait call or a shutdown call.
148 pass
149 if not self.full() and not putter.cancelled():
150 # We were woken up by get_nowait(), but can't take
151 # the call. Wake up the next in line.
152 self._wakeup_next(self._putters)
153 raise
154 return self.put_nowait(item)
155
156 def put_nowait(self, item):
157 """Put an item into the queue without blocking.

Callers 15

testShareMethod · 0.95
test_closeMethod · 0.95
test_putMethod · 0.95
test_forkMethod · 0.95
test_qsizeMethod · 0.95
_test_repr_or_strMethod · 0.95
test_emptyMethod · 0.95
test_fullMethod · 0.95
test_orderMethod · 0.95
test_get_with_puttersMethod · 0.95

Calls 9

fullMethod · 0.95
_wakeup_nextMethod · 0.95
put_nowaitMethod · 0.95
_get_loopMethod · 0.80
create_futureMethod · 0.45
appendMethod · 0.45
cancelMethod · 0.45
removeMethod · 0.45
cancelledMethod · 0.45

Tested by 15

testShareMethod · 0.76
test_closeMethod · 0.76
test_putMethod · 0.76
test_forkMethod · 0.76
test_qsizeMethod · 0.76
_test_repr_or_strMethod · 0.76
test_emptyMethod · 0.76
test_fullMethod · 0.76
test_orderMethod · 0.76
test_get_with_puttersMethod · 0.76