MCPcopy Index your code
hub / github.com/python/cpython / target

Method target

Lib/test/test_asyncio/test_tasks.py:3603–3618  ·  view source on GitHub ↗

Run add coroutine in the event loop.

(self, fail=False, cancel=False, timeout=None,
               advance_coro=False)

Source from the content-addressed store, hash-verified

3601 return a + b
3602
3603 def target(self, fail=False, cancel=False, timeout=None,
3604 advance_coro=False):
3605 """Run add coroutine in the event loop."""
3606 coro = self.add(1, 2, fail=fail, cancel=cancel)
3607 future = asyncio.run_coroutine_threadsafe(coro, self.loop)
3608 if advance_coro:
3609 # this is for test_run_coroutine_threadsafe_task_factory_exception;
3610 # otherwise it spills errors and breaks **other** unittests, since
3611 # 'target' is interacting with threads.
3612
3613 # With this call, `coro` will be advanced.
3614 self.loop.call_soon_threadsafe(coro.send, None)
3615 try:
3616 return future.result(timeout)
3617 finally:
3618 future.done() or future.cancel()
3619
3620 def test_run_coroutine_threadsafe(self):
3621 """Test coroutine submission from a thread to an event loop."""

Calls 7

addMethod · 0.95
call_soon_threadsafeMethod · 0.45
resultMethod · 0.45
doneMethod · 0.45
cancelMethod · 0.45
set_task_factoryMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected