(
runner: Runner,
async_fn: Callable[[Unpack[PosArgT]], Awaitable[object]],
args: tuple[Unpack[PosArgT]],
host_uses_signal_set_wakeup_fd: bool = False,
)
| 2720 | # straight through. |
| 2721 | @enable_ki_protection |
| 2722 | def unrolled_run( |
| 2723 | runner: Runner, |
| 2724 | async_fn: Callable[[Unpack[PosArgT]], Awaitable[object]], |
| 2725 | args: tuple[Unpack[PosArgT]], |
| 2726 | host_uses_signal_set_wakeup_fd: bool = False, |
| 2727 | ) -> Generator[float, EventResult, None]: |
| 2728 | __tracebackhide__ = True |
| 2729 | |
| 2730 | try: |
| 2731 | if not host_uses_signal_set_wakeup_fd: |
| 2732 | runner.entry_queue.wakeup.wakeup_on_signals() |
| 2733 | |
| 2734 | if "before_run" in runner.instruments: |
| 2735 | runner.instruments.call("before_run") |
| 2736 | runner.clock.start_clock() |
| 2737 | runner.init_task = runner.spawn_impl( |
| 2738 | runner.init, |
| 2739 | (async_fn, args), |
| 2740 | None, |
| 2741 | "<init>", |
| 2742 | system_task=True, |
| 2743 | ) |
| 2744 | |
| 2745 | # You know how people talk about "event loops"? This 'while' loop right |
| 2746 | # here is our event loop: |
| 2747 | while runner.tasks: |
| 2748 | if runner.runq: |
| 2749 | timeout: float = 0 |
| 2750 | else: |
| 2751 | deadline = runner.deadlines.next_deadline() |
| 2752 | timeout = runner.clock.deadline_to_sleep_time(deadline) |
| 2753 | timeout = min(max(0, timeout), _MAX_TIMEOUT) |
| 2754 | |
| 2755 | idle_primed = None |
| 2756 | if runner.waiting_for_idle: |
| 2757 | cushion, _ = runner.waiting_for_idle.keys()[0] |
| 2758 | if cushion < timeout: |
| 2759 | timeout = cushion |
| 2760 | idle_primed = IdlePrimedTypes.WAITING_FOR_IDLE |
| 2761 | # We use 'elif' here because if there are tasks in |
| 2762 | # wait_all_tasks_blocked, then those tasks will wake up without |
| 2763 | # jumping the clock, so we don't need to autojump. |
| 2764 | elif runner.clock_autojump_threshold < timeout: |
| 2765 | timeout = runner.clock_autojump_threshold |
| 2766 | idle_primed = IdlePrimedTypes.AUTOJUMP_CLOCK |
| 2767 | |
| 2768 | if "before_io_wait" in runner.instruments: |
| 2769 | runner.instruments.call("before_io_wait", timeout) |
| 2770 | |
| 2771 | # Driver will call io_manager.get_events(timeout) and pass it back |
| 2772 | # in through the yield |
| 2773 | events = yield timeout |
| 2774 | runner.io_manager.process_events(events) |
| 2775 | |
| 2776 | if "after_io_wait" in runner.instruments: |
| 2777 | runner.instruments.call("after_io_wait", timeout) |
| 2778 | |
| 2779 | # Process cancellations due to deadline expiry |
no test coverage detected
searching dependent graphs…