handles the timeout logic
(
timeout_fn, timeout_event, handle_exit_code, is_alive, quit_thread
)
| 2698 | |
| 2699 | |
| 2700 | def background_thread( |
| 2701 | timeout_fn, timeout_event, handle_exit_code, is_alive, quit_thread |
| 2702 | ): |
| 2703 | """handles the timeout logic""" |
| 2704 | |
| 2705 | # if there's a timeout event, loop |
| 2706 | if timeout_event: |
| 2707 | while not quit_thread.is_set(): |
| 2708 | timed_out = event_wait(timeout_event, 0.1) |
| 2709 | if timed_out: |
| 2710 | timeout_fn() |
| 2711 | break |
| 2712 | |
| 2713 | # handle_exit_code will be a function ONLY if our command was NOT waited on |
| 2714 | # as part of its spawning. in other words, it's probably a background |
| 2715 | # command |
| 2716 | # |
| 2717 | # this reports the exit code exception in our thread. it's purely for the |
| 2718 | # user's awareness, and cannot be caught or used in any way, so it's ok to |
| 2719 | # suppress this during the tests |
| 2720 | if handle_exit_code and not RUNNING_TESTS: # pragma: no cover |
| 2721 | alive = True |
| 2722 | exit_code = None |
| 2723 | while alive: |
| 2724 | quit_thread.wait(1) |
| 2725 | alive, exit_code = is_alive() |
| 2726 | |
| 2727 | handle_exit_code(exit_code) |
| 2728 | |
| 2729 | |
| 2730 | def output_thread( |
nothing calls this directly
no test coverage detected