MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / DataFlowReentrantGuard

Class DataFlowReentrantGuard

tensorpack/dataflow/base.py:24–40  ·  view source on GitHub ↗

A tool to enforce non-reentrancy. Mostly used on DataFlow whose :meth:`get_data` is stateful, so that multiple instances of the iterator cannot co-exist.

Source from the content-addressed store, hash-verified

22
23
24class DataFlowReentrantGuard(object):
25 """
26 A tool to enforce non-reentrancy.
27 Mostly used on DataFlow whose :meth:`get_data` is stateful,
28 so that multiple instances of the iterator cannot co-exist.
29 """
30 def __init__(self):
31 self._lock = threading.Lock()
32
33 def __enter__(self):
34 self._succ = self._lock.acquire(False)
35 if not self._succ:
36 raise threading.ThreadError("This DataFlow is not reentrant!")
37
38 def __exit__(self, exc_type, exc_val, exc_tb):
39 self._lock.release()
40 return False
41
42
43class DataFlowMeta(ABCMeta):

Callers 11

reset_stateMethod · 0.85
__init__Method · 0.85
reset_stateMethod · 0.85
reset_stateMethod · 0.85
reset_stateMethod · 0.85
reset_stateMethod · 0.85
reset_stateMethod · 0.85
reset_stateMethod · 0.85
reset_stateMethod · 0.85
reset_stateMethod · 0.85
reset_stateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected