Lines Matching defs:task
105 task = self.__class__.Task[str]
106 self.assertEqual(task.__args__, (str,))
107 self.assertIsInstance(task, GenericAlias)
167 await task
169 task = asyncio.ensure_future(test(), loop=self.loop)
173 self.loop.run_until_complete(task)
386 # Autogenerated task names should have monotonically increasing numbers
407 task = self.new_task(self.loop, wait_for(fut))
409 self.assertRegex(repr(task),
413 self.loop.run_until_complete(task)
432 # Test that when awaiting on a task when an exception is already
433 # active, if the task raises an exception it will be chained
445 task = self.new_task(loop, raise_error())
447 await task
455 task = self.new_task(loop, run())
456 loop.run_until_complete(task)
475 task = self.new_task(loop, process_exc(exc))
477 await task
484 task = self.new_task(loop, run())
485 loop.run_until_complete(task)
495 async def task():
499 t = self.new_task(loop, task())
519 async def task():
527 t = self.new_task(loop, task())
548 self.assertTrue(t.cancelled()) # Finally, task complete
551 # uncancel is no longer effective after the task is complete
575 task = asyncio.current_task()
576 loop = task.get_loop()
585 task.cancel()
597 and task.uncancel() == 0
606 # that triggered the need to uncancel the task, regardless of
625 # Additionally, the original stimulus to `cancel()` the task
626 # needs to be unscheduled to avoid re-cancelling the task later.
646 self.assertTrue(outer_code_reached) # task got uncancelled after leaving
649 self.assertEqual(t1.cancelling(), 0) # no pending cancellation of the outer task
672 async def task():
676 t = self.new_task(loop, task())
702 task = self.new_task(loop, sleep())
704 task.cancel(*cancel_args)
705 done, pending = await asyncio.wait([task])
706 task.result()
708 task = self.new_task(loop, coro())
710 loop.run_until_complete(task)
736 task = self.new_task(loop, sleep())
738 task.cancel(*cancel_args)
739 done, pending = await asyncio.wait([task])
740 task.exception()
742 task = self.new_task(loop, coro())
744 loop.run_until_complete(task)
770 task = self.new_task(loop, coro())
772 loop.run_until_complete(task)
788 task = self.new_task(loop, sleep())
790 task.cancel('my message')
791 done, pending = await asyncio.wait([task])
792 task.exception()
794 task = self.new_task(loop, coro())
796 loop.run_until_complete(task)
805 async def task():
810 t = self.new_task(self.loop, task())
822 async def task():
826 t = self.new_task(self.loop, task())
827 test_utils.run_briefly(self.loop) # start task
837 async def task():
841 t = self.new_task(self.loop, task())
858 async def task():
865 t = self.new_task(self.loop, task())
882 async def task():
891 t = self.new_task(self.loop, task())
911 async def task():
918 t = self.new_task(loop, task())
928 """coroutine end right after task is cancelled"""
932 async def task():
937 t = self.new_task(loop, task())
948 # a task cancellation is requested for a task which is not
949 # currently blocked, such as a task cancelling itself.
951 # or task the cancelled task blocks on is cancelled correctly
956 task = nested_task = None
964 # Create a sub-task and wait for it to run.
968 # Request the current task to be cancelled.
969 task.cancel()
970 # Block on the nested task, which should be immediately
974 task = self.new_task(loop, coro())
976 loop.run_until_complete(task)
978 self.assertTrue(task.cancelled())
987 # When calling Future.result() on a cancelled task, check that the
997 task = self.new_task(loop, nested())
999 task.cancel()
1000 await task # search target
1002 task = self.new_task(loop, coro())
1004 loop.run_until_complete(task)
1009 self.assert_text_contains(tb, "await task # search target")
1014 # When calling Future.exception() on a cancelled task, check that the
1024 task = self.new_task(loop, nested())
1026 task.cancel()
1027 done, pending = await asyncio.wait([task])
1028 task.exception() # search target
1030 task = self.new_task(loop, coro())
1032 loop.run_until_complete(task)
1038 "task.exception() # search target")
1057 async def task():
1065 t = self.new_task(loop, task())
1081 task = self.new_task(self.loop, coro())
1083 task._log_traceback = True
1084 self.loop.run_until_complete(task)
1120 task = self.new_task(
1124 done, pending = self.loop.run_until_complete(task)
1155 task = self.new_task(
1159 done, pending = loop.run_until_complete(task)
1184 task = self.new_task(
1188 done, pending = self.loop.run_until_complete(task)
1204 # first_exception, task already has exception
1211 task = self.new_task(
1215 done, pending = loop.run_until_complete(task)
1243 task = asyncio.wait([b, a], return_when=asyncio.FIRST_EXCEPTION)
1245 done, pending = loop.run_until_complete(task)
1635 task = self.new_task(self.loop, coro())
1637 self.assertIs(task._fut_waiter, fut)
1639 task.cancel()
1642 asyncio.CancelledError, self.loop.run_until_complete, task)
1643 self.assertIsNone(task._fut_waiter)
1651 task = self.new_task(self.loop, gen)
1654 task.set_result('ok')
1657 task.set_exception(ValueError())
1660 self.loop.run_until_complete(task),
1664 # If coroutine returns future, task waits on this future.
1713 task = self.new_task(loop, notmutch())
1716 task.cancel()
1717 self.assertFalse(task.done())
1721 self.assertTrue(task.done())
1722 self.assertFalse(task.cancelled())
1723 self.assertIs(task.exception(), base_exc)
1773 self.assertIs(asyncio.current_task(), task)
1775 self.assertIs(asyncio.current_task(None), task)
1776 self.assertIs(asyncio.current_task(), task)
1778 task = self.new_task(self.loop, coro(self.loop))
1779 self.loop.run_until_complete(task)
2024 # at this point, the only reference to kill_me() task is
2032 # schedule the task
2034 task = asyncio.ensure_future(coro, loop=self.loop)
2036 self.assertEqual(asyncio.all_tasks(loop=self.loop), {task})
2040 # execute the task so it waits for future
2045 source_traceback = task._source_traceback
2046 task = None
2048 # no more reference to kill_me() task: the task is destroyed by the GC
2055 'task': mock.ANY,
2069 task = self.new_task(loop, coro())
2071 task.cancel()
2072 task = None
2080 task = self.new_task(self.loop, coroutine_function())
2082 self.assertIsInstance(task._source_traceback, list)
2083 self.assertEqual(task._source_traceback[-2][:3],
2087 self.loop.run_until_complete(task)
2098 # gathering task is done at the same time as the child future
2113 # At this point the task should complete.
2161 'raised by inner task to the gather() caller.'
2171 task = self.new_task(self.loop, foo())
2173 self.assertIsNotNone(task.exception().__traceback__)
2218 task = self.new_task(self.loop, coro())
2219 self.assertIsInstance(task, self.Task)
2220 self.loop.run_until_complete(task)
2224 task = self.new_task(self.loop, coro())
2225 self.assertIsInstance(task, self.Task)
2226 self.loop.run_until_complete(task)
2229 task = self.new_task(self.loop, CoroLikeObject())
2230 self.assertIsInstance(task, self.Task)
2231 self.assertEqual(self.loop.run_until_complete(task), 42)
2235 task = self.new_task(self.loop, CoroLikeObject())
2236 self.assertIsInstance(task, self.Task)
2237 self.assertEqual(self.loop.run_until_complete(task), 42)
2245 task = asyncio.create_task(inner())
2246 self.assertIsInstance(task, self.Task)
2247 ret = await task
2258 task = asyncio.create_task(coro_noop(), name='No-op')
2259 self.assertEqual(task.get_name(), 'No-op')
2260 await task
2282 task = self.new_task(loop, main())
2283 loop.run_until_complete(task)
2293 # of the "main()" task.
2307 # Test that task passed its context to add_done_callback:
2314 task = self.new_task(loop, main())
2315 loop.run_until_complete(task)
2335 task = loop.create_task(sub(random.randint(0, 10)))
2336 tasks.append(task)
2369 task = self.new_task(loop, main())
2370 ret = loop.run_until_complete(task)
2397 task = self.new_task(loop, main())
2398 ret = loop.run_until_complete(task)
2425 task = loop.create_task(main())
2426 ret = loop.run_until_complete(task)
2436 task = self.new_task(loop, coro)
2437 loop.run_until_complete(task)
2438 self.assertIs(task.get_coro(), coro)
2472 task = self.Task(func(), loop=self.loop)
2474 result = self.loop.run_until_complete(task)
2479 dict(task.calls),
2512 task = self.new_task(self.loop, coro)
2513 Future.set_result(task, 'spam')
2516 self.loop.run_until_complete(task),
2539 task = self.new_task(self.loop, coro)
2540 Future.set_exception(task, MyExc())
2543 self.loop.run_until_complete(task)
2568 task = self.new_task(self.loop, coro())
2569 self.loop.run_until_complete(task)
2572 task.__init__(coro(), loop=self.loop)
2573 self.loop.run_until_complete(task)
2579 task = self.new_task(self.loop, coro())
2580 self.loop.run_until_complete(task)
2582 del task._log_destroy_pending
2660 task = self.loop.create_task(coro())
2661 res = self.loop.run_until_complete(task)
2683 task = TaskLike()
2687 self._register_task(task)
2688 self.assertEqual(asyncio.all_tasks(loop), {task})
2689 self._unregister_task(task)
2699 task = TaskLike()
2703 self._register_task(task)
2704 self.assertEqual(asyncio.all_tasks(loop), {task})
2705 self._unregister_task(task)
2715 task = TaskLike()
2719 self._register_task(task)
2721 self._unregister_task(task)
2724 task = mock.Mock()
2727 self._enter_task(loop, task)
2728 self.assertIs(asyncio.current_task(loop), task)
2729 self._leave_task(loop, task)
2742 task = mock.Mock()
2744 self._enter_task(loop, task)
2745 self._leave_task(loop, task)
2759 task = mock.Mock()
2762 self._leave_task(loop, task)
2766 task = mock.Mock()
2768 task.get_loop = lambda: loop
2769 self._register_task(task)
2770 self._unregister_task(task)
2774 task = mock.Mock()
2776 self._unregister_task(task)
2818 self.assertIs(asyncio.current_task(loop=self.loop), task)
2820 self.assertIs(asyncio.current_task(None), task)
2821 self.assertIs(asyncio.current_task(), task)
2823 task = self.new_task(coro())
2824 self.loop.run_until_complete(task)
3241 # Check that there's no pending task (add has been cancelled)
3242 for task in asyncio.all_tasks(self.loop):
3243 self.assertTrue(task.done())
3247 when the task is cancelled."""
3255 when the task factory raise an exception."""
3267 # Set corrupted task factory