MCPcopy Index your code
hub / github.com/RustPython/RustPython / acquire

Method acquire

Lib/threading.py:181–215  ·  view source on GitHub ↗

Acquire a lock, blocking or non-blocking. When invoked without arguments: if this thread already owns the lock, increment the recursion level by one, and return immediately. Otherwise, if another thread owns the lock, block until the lock is unlocked. Once the lock i

(self, blocking=True, timeout=-1)

Source from the content-addressed store, hash-verified

179 self._count = 0
180
181 def acquire(self, blocking=True, timeout=-1):
182 """Acquire a lock, blocking or non-blocking.
183
184 When invoked without arguments: if this thread already owns the lock,
185 increment the recursion level by one, and return immediately. Otherwise,
186 if another thread owns the lock, block until the lock is unlocked. Once
187 the lock is unlocked (not owned by any thread), then grab ownership, set
188 the recursion level to one, and return. If more than one thread is
189 blocked waiting until the lock is unlocked, only one at a time will be
190 able to grab ownership of the lock. There is no return value in this
191 case.
192
193 When invoked with the blocking argument set to true, do the same thing
194 as when called without arguments, and return true.
195
196 When invoked with the blocking argument set to false, do not block. If a
197 call without an argument would block, return false immediately;
198 otherwise, do the same thing as when called without arguments, and
199 return true.
200
201 When invoked with the floating-point timeout argument set to a positive
202 value, block for at most the number of seconds specified by timeout
203 and as long as the lock cannot be acquired. Return true if the lock has
204 been acquired, false if the timeout has elapsed.
205
206 """
207 me = get_ident()
208 if self._owner == me:
209 self._count += 1
210 return 1
211 rc = self._block.acquire(blocking, timeout)
212 if rc:
213 self._owner = me
214 self._count = 1
215 return rc
216
217 __enter__ = acquire
218

Callers 9

_acquire_restoreMethod · 0.45
_acquire_restoreMethod · 0.45
_is_ownedMethod · 0.45
waitMethod · 0.45
_internal_pollMethod · 0.45
_waitMethod · 0.45
_get_candidate_namesFunction · 0.45
_gettempdirFunction · 0.45
getMethod · 0.45

Calls 1

get_identFunction · 0.70

Tested by

no test coverage detected