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

Method testParallel

tensorflow/python/kernel_tests/py_func_test.py:364–384  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

362
363 @test_util.run_v1_only("b/120545219")
364 def testParallel(self):
365 # Tests that tf.compat.v1.py_func's can run in parallel if they release
366 # the GIL.
367 with self.cached_session() as session:
368 q = queue.Queue(1)
369
370 def blocking_put():
371 q.put(42)
372 q.join() # Wait for task_done().
373 return 42
374
375 def blocking_get():
376 v = q.get(block=True) # Wait for put().
377 q.task_done()
378 return v
379
380 x, = script_ops.py_func(blocking_put, [], [dtypes.int64])
381 y, = script_ops.py_func(blocking_get, [], [dtypes.int64])
382
383 # This will result in a deadlock if the py_func's don't run in parallel.
384 session.run([x, y])
385
386 def testNoReturnValueStateful(self):
387

Callers

nothing calls this directly

Calls 3

QueueMethod · 0.80
cached_sessionMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected