MCPcopy
hub / github.com/tornadoweb/tornado / _ReleasingContextManager

Class _ReleasingContextManager

tornado/locks.py:258–279  ·  view source on GitHub ↗

Releases a Lock or Semaphore at the end of a "with" statement. with (yield semaphore.acquire()): pass # Now semaphore.release() has been called.

Source from the content-addressed store, hash-verified

256
257
258class _ReleasingContextManager:
259 """Releases a Lock or Semaphore at the end of a "with" statement.
260
261 with (yield semaphore.acquire()):
262 pass
263
264 # Now semaphore.release() has been called.
265 """
266
267 def __init__(self, obj: Any) -> None:
268 self._obj = obj
269
270 def __enter__(self) -> None:
271 pass
272
273 def __exit__(
274 self,
275 exc_type: "Optional[Type[BaseException]]",
276 exc_val: Optional[BaseException],
277 exc_tb: Optional[types.TracebackType],
278 ) -> None:
279 self._obj.release()
280
281
282class Semaphore(_TimeoutGarbageCollector):

Callers 2

releaseMethod · 0.85
acquireMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected