Run add coroutine in the event loop.
(self, fail=False, cancel=False, timeout=None,
advance_coro=False)
| 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.""" |
no test coverage detected