MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / QueueRunners

Function QueueRunners

tensorflow/contrib/slim/python/slim/queues.py:44–74  ·  view source on GitHub ↗

Creates a context manager that handles starting and stopping queue runners. Args: session: the currently running session. Yields: a context in which queues are run. Raises: NestedQueueRunnerError: if a QueueRunners context is nested within another.

(session)

Source from the content-addressed store, hash-verified

42
43@contextmanager
44def QueueRunners(session):
45 """Creates a context manager that handles starting and stopping queue runners.
46
47 Args:
48 session: the currently running session.
49
50 Yields:
51 a context in which queues are run.
52
53 Raises:
54 NestedQueueRunnerError: if a QueueRunners context is nested within another.
55 """
56 if not _queue_runner_lock.acquire(False):
57 raise NestedQueueRunnerError('QueueRunners cannot be nested')
58
59 coord = coordinator.Coordinator()
60 threads = []
61 for qr in ops.get_collection(ops.GraphKeys.QUEUE_RUNNERS):
62 threads.extend(
63 qr.create_threads(
64 session, coord=coord, daemon=True, start=True))
65 try:
66 yield
67 finally:
68 coord.request_stop()
69 try:
70 coord.join(threads, stop_grace_period_secs=120)
71 except RuntimeError:
72 session.close()
73
74 _queue_runner_lock.release()

Callers

nothing calls this directly

Calls 10

request_stopMethod · 0.95
joinMethod · 0.95
acquireMethod · 0.80
CoordinatorMethod · 0.80
create_threadsMethod · 0.80
closeMethod · 0.65
get_collectionMethod · 0.45
extendMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected