MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / put

Method put

tools/python-3.11.9-amd64/Lib/queue.py:122–152  ·  view source on GitHub ↗

Put an item into the queue. If optional args 'block' is true and 'timeout' is None (the default), block if necessary until a free slot is available. If 'timeout' is a non-negative number, it blocks at most 'timeout' seconds and raises the Full exception if no fr

(self, item, block=True, timeout=None)

Source from the content-addressed store, hash-verified

120 return 0 < self.maxsize <= self._qsize()
121
122 def put(self, item, block=True, timeout=None):
123 ''&#x27;Put an item into the queue.
124
125 If optional args 'block' is true and 'timeout' is None (the default),
126 block if necessary until a free slot is available. If 'timeout' is
127 a non-negative number, it blocks at most 'timeout' seconds and raises
128 the Full exception if no free slot was available within that time.
129 Otherwise ('block' is false), put an item on the queue if a free slot
130 is immediately available, else raise the Full exception ('timeout'
131 is ignored in that case).
132 ''&#x27;
133 with self.not_full:
134 if self.maxsize > 0:
135 if not block:
136 if self._qsize() >= self.maxsize:
137 raise Full
138 elif timeout is None:
139 while self._qsize() >= self.maxsize:
140 self.not_full.wait()
141 elif timeout < 0:
142 raise ValueError("'timeout' must be a non-negative number")
143 else:
144 endtime = time() + timeout
145 while self._qsize() >= self.maxsize:
146 remaining = endtime - time()
147 if remaining <= 0.0:
148 raise Full
149 self.not_full.wait(remaining)
150 self._put(item)
151 self.unfinished_tasks += 1
152 self.not_empty.notify()
153
154 def get(self, block=True, timeout=None):
155 ''&#x27;Remove and return an item from the queue.

Callers 2

put_nowaitMethod · 0.95
optimizeFunction · 0.45

Calls 5

_qsizeMethod · 0.95
_putMethod · 0.95
timeClass · 0.90
waitMethod · 0.45
notifyMethod · 0.45

Tested by

no test coverage detected