Skip to content

FEAT: extend profiling to child processes#431

Open
TTsangSC wants to merge 134 commits into
pyutils:mainfrom
TTsangSC:profile-child-processes
Open

FEAT: extend profiling to child processes#431
TTsangSC wants to merge 134 commits into
pyutils:mainfrom
TTsangSC:profile-child-processes

Conversation

@TTsangSC

@TTsangSC TTsangSC commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

This PR adds support for kernprof to profile code execution in child Python processes, building on ongoing work (see Credits).

Usage

The EXPERIMENTAL new flags --no-prof-child-procs and --prof-child-procs[=...] are added to kernprof. By setting --prof-child-procs to true, child Python processes created by the profiled process are also profiled:1

$ kernprof -lv --prof-child-procs -c "if True:
    import itertools
    import multiprocessing
    from collections.abc import Collection

    def sum_worker(nums: Collection[int]) -> int:
        result = 0
        for x in nums:
            result += x
        return result

    def sum_parallel(nums: Collection[int], nprocs: int) -> int:
        size_ = len(nums) / nprocs
        size = int(size_)
        if size_ > size:
            size += 1
        with multiprocessing.Pool(nprocs) as pool:
            sub_sums = pool.map(sum_worker, itertools.batched(nums, size))  # 3.12+
            pool.close()
            pool.join()
        return sum_worker(sub_sums)

    if __name__ == '__main__':
        print(sum_parallel(range(1, 1001), 3))"
500500
Wrote profile results to 'kernprof-command-<...>.lprof'
Timer unit: 1e-06 s

Total time: 0.000312 s
File: <...>/kernprof-command.py
Function: sum_worker at line 6

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
     6                                               def sum_worker(nums: Collection[int]) -> int:
     7         4          3.0      0.8      1.0          result = 0
     8      1007        155.0      0.2     49.7          for x in nums:
     9      1003        153.0      0.2     49.0              result += x
    10         4          1.0      0.2      0.3          return result

Total time: 0.100223 s
File: <...>/kernprof-command.py
Function: sum_parallel at line 12

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
    12                                               def sum_parallel(nums: Collection[int], nprocs: int) -> int:
    13         1          1.0      1.0      0.0          size_ = len(nums) / nprocs
    14         1          1.0      1.0      0.0          size = int(size_)
    15         1          0.0      0.0      0.0          if size_ > size:
    16         1          0.0      0.0      0.0              size += 1
    17         2      21685.0  10842.5     21.6          with multiprocessing.Pool(nprocs) as pool:
    18         1      68692.0  68692.0     68.5              sub_sums = pool.map(sum_worker, itertools.batched(nums, size))  # 3.12+
    19         1         27.0     27.0      0.0              pool.close()
    20         1       9800.0   9800.0      9.8              pool.join()
    21         1         17.0     17.0      0.0          return sum_worker(sub_sums)

Note how the sum_worker() calls are profiled:

  • The main process contributes 1 call and 3 loops summing the sub-sums.
  • The 3 child processes each contributes 1 call, and they loop over all 1000 of the items combined.

Highlights

  • Children created by (including but not limited to) these methods can be profiled:
    • os.system() and subprocess.run()
    • multiprocessing2
  • All three multiprocessing "start methods" ('fork', 'forkserver', and 'spawn') tested to be compatible, where available on the platform
  • Profiling unaffected by whether the profiled function run in child processes:
    • Is locally defined in the profiled code or imported
    • Executes cleanly or errors out
  • Mode of profiling (with eager --preimports or via test-code rewriting) replicated in child processes

Explanation

  • A serializable cache object (line_profiler._child_process_profiling.cache.LineProfilingCache) is created by the main process, containing session config information (e.g. values for --prod-mod and --preimports) so that profiling can be replicated in child processes.
  • In the main process, environment variables are injected, so that it and its children would have access to its PID and the cache-directory location.
  • A temporary .pth file is created; Python processes inheriting the right environment will thus go through profiling setup, while those without the env var (and just happens to share the Python executable) will be minimally affected.
  • os.fork() (where available) is patched with a wrapper which ensures consistent global states.
  • As with coverage.multiproc, various multiprocessing components are patched (line_profiler._child_process_profiling.multiprocessing_patches.apply()) so that child processes can retrieve the cache and explicitly cleanup before exiting. Patches are inherited by forked child processes and reapplied by spawned ones.
  • To make sure that multiprocessing child processes are allowed to fully clean up and write their profiling, even when the parallel workload errors out,3 additional patches are made to multiprocessing.
  • When properly set up, child processes write profiling output on exit to the session cache directory, which kernprof then gather and merge with the profiling result in main process.

Code changes

New code (click to expand)

line_profiler/_threading_patches.py

New submodule patching threading for the consistent gathering of profiling data between tracing modes.

  • apply():
    When legacy tracing is used (Python < 3.12 or LINE_PROFILER_CORE=ctrace), patch threading.Thread.__init__() so that the profiler starts with the same .enable_count on the new thread as with the parent thread; this is necessary for correctness because the profiler may otherwise not be enabled on the new thread.

line_profiler/cleanup.py

New submodule defining the Cleanup class, which handles various setup/cleanup tasks like:

  • Registering/Calling callbacks
  • Creation/Deletion of tempfiles
  • Insertion/Reversion of environment variables
  • Patching/Restoration of object attributes

line_profiler/curated_profiling.py

New submodule containing mostly relocated code from kernprof, so that child processes can more easily reestablish profiling:

  • ClassifiedPreimportTargets:
    Object resolving and classifying the --prof-mods, and writing a corresponding preimport module
  • CuratedProfilerContext:
    Context manager managing the state of the LineProfiler, e.g.:
    • Slipping it into line_profiler.profile on startup
    • Patching threading (see _threading_patches above) so that the profiler stays enabled on newly spawned threads
    • Purging its .enable_counts on teardown

line_profiler/_child_process_profiling/

New private subpackage for maintaining the states, setting up the hooks, and performing the patches which makes it possible to profile child processes:

  • cache.py::LineProfilingCache:
    "Session state" object. It:
    • Can be auto-(de-)serialized in the main and child processes based on env-var values, managing setup (module patches, profiler curation, eager pre-imports) and cleanup (tempfile management, dumping and gathering of profiling results) in each process.

    • Injects the following environment variables, which are inherited by child processes:

      • ${LINE_PROFILER_PROFILE_CHILD_PROCESSES_CACHE_PID}: main-process PID
      • ${LINE_PROFILER_PROFILE_CHILD_PROCESSES_CACHE_DIR_<PID>}: location of the cache directory

      From the combination of both, child processes can retrieve the cache by calling .load().

  • multiprocessing_patches.py::apply():
    Apply patches to these multiprocessing module components so that profiling results are properly gathered on child-process exit:
    • Process (read: multiprocessing.process.BaseProcess):
      • ._bootstrap():
        Wrapped call to:
        • Call LineProfilingCache.cleanup() on exit.
        • Where possible, register a SIGTERM handler to do the above as a failsafe.
      • .terminate():
        Wrapped call to poll on the child process, and soft-block (with a timeout) until it is deleted.
    • spawn.runpy:
      Replaced with a localized, patched clone of runpy (see runpy_patches.py below). This is necessary for profiling to function in non-eager-preimports mode (--no-preimports).
    • forkserver.ForkServer:
      Global instance rebooted if reboot_forkserver=True so that child processes fork with the profiling infrastructure set up properly.
  • pth_hooks.py:
    Facilities for effecting profiling-code execution in child processes by injecting a temporary .pth file into the current venv. This module is kept as minimal as possible to minimize the amount of startup code run as the mere result of having said .pth file.
    • write_pth_hook():
      Set up a .pth file under the directory sysconfig.get_path('purelib') which calls load_pth_hook() (see below). The .pth file will be cleaned up by the supplied cache object.
    • load_pth_hook():
      For processes inheriting a matching "parent PID" from the environment (see LineProfilingCache above), load the cache and set up the LineProfiler instance used, like how the main kernprof process does.
  • runpy_patches.py::create_runpy_wrapper():
    Make a clone of the runpy module which checks if the code executed is the code to be profiled; if so, it goes through the same code-rewriting facilities that line_profiler.autoprofile.autoprofile.run() uses to set up profiling.
  • threading_patches.py::apply():
    Patch threading.Thread.__init__() so that when using legacy tracing the profiler is suitably enabled on newly-spawn thread, depending on whether it is enabled on the current thread.

tests/conftest.py

Add the @pytest.mark.retry marker so that we can retry flaky tests.

  • _RetryEntry:
    Object containing info on retried test items so that they can be summarized when the session ends.
  • _RetryHelper:
    Object implementing the retrying of failing test functions (pytest.Function) and the teardown of function-scoped fixtures between retries.
    • pytest_pyfunc_call():
      Hook implementation for instantiating a helper to handle test rerunning if necessary.
    • get_helper():
      Instantiate from a pytest.Function marked with @pytest.mark.retry(...).
  • pytest_addhooks():
    Hook implementation for registering _RetryHelper as a plugin.
  • pytest_configure():
    Hook implementation for defining the @pytest.mark.retry marker, so that it doesn't produce a pytest.PytestUnknownMarkWarning when used.
  • pytest_terminal_summary():
    Hook implementation for writing a summary section if any test is retried.

tests/test_retry_tests.py

Test that the @pytest.mark.retry marker:

  • Properly handles fixture scoping (test_fixture_scoping()), esp. the teardown on non-persisted function-scoped fixtures between retries (test_fixture_teardown())
  • Allows for constraining the "allowed" error classes where retries are attempted (test_exception_restrictions())
  • Writes a summary of the retried tests at the end of the session.
  • Does not produce a pytest.PytestUnknownMarkWarning when used.

tests/test_child_procs.py

  • _ModuleFixture:
    Helper object which handles:
    • Module-name mangling (à la tests/test_cython.py::propose_name()) to avoid clashes; and
    • Installation into and cleanup from sys.path and os.environ['PYTHONPATH'].
  • _Params:
    Helper object which handles concatenation and Cartesian products of parametrizations.
  • ext_module:
    New _ModuleFixture representing a module defining the sum function used by test_module when run without the --local flag.
  • _run_subproc():
    New wrapper around subprocess.run() which provide extra debugging output (standard streams, timing info, etc.)
  • "Unit tests" for the line_profiler._child_processing_profiling components, or as close as is possible thereto:
    • test_runpy_patches():
      Test the functionality of ~.runpy_patches.create_runpy_wrapper().
    • test_cache_dump_load():
      Test the functionalities of ~.cache.LineProfilingCache.dump() and .load().
    • test_cache_setup_main_process():
      Test the functionality of ~.cache.LineProfilingCache._setup_in_main_process().
    • test_cache_setup_child():
      Test the functionality of ~.cache.LineProfilingCache._setup_in_child_process().
    • test_load_pth_hook():
      Test the functionality of ~.pth_hook.load_pth_hook().
    • test_apply_mp_patches():
      Test the functionality of ~.multiprocessing_patches.apply().
  • test_profiling_multiproc_script():
    "Main" new test for running the test_module (see Modified Code) with kernprof --prof-child-procs; heavily parametrized to check for profiling-result correctness in different contexts:
    • run_func: execution modes (kernprof <script>, kernprof -m <module>, and kernprof -c <code>)
    • prof_child_procs; whether to use child-process profiling (--[no-]prof-child-procs)
    • preimports: eager vs. on-import profiling (--[no-]preimports)
    • use_local_func: whether the parallel workload is locally defined in the executed code or imported from external modules
    • fail: whether the parallel workload errors out
    • start_method: multiprocessing "start methods" ('fork', 'forkserver', and 'spawn')
  • test_profiling_bare_python():
    New test for profiling child processes where the code run by kernprof --prof-child-procs doesn't directly invoke multiprocessing, but spins up another Python process that does (via os.system() or subprocess.run()).

Modified code (click to expand)

line_profiler/line_profiler.py::LineStats

  • .get_empty_instance():
    New convenience class method for creating an instance with no profiling data and the platform-appropriate .unit.
  • .from_files():
    Added new argument on_defective: Literal['ignore', 'warn', 'error'], allowing for passing over bad files (e.g. empty ones) with optional warnings. The old behavior (on_defective='error') remains the default.

line_profiler/rc/line_profiler.toml

  • [tool.line_profiler.kernprof]:
    New key-value pair prof-child-procs for the default of the kernprof --[no-]prof-child-procs flag.

  • [tool.line_profiler.multiprocessing]:
    New key-value pairs for controlling the application of the .multiprocessing_patches:

    • intercept_logs (bool):
      Whether to patch methods like multiprocessing.util.debug() to also capture the multiprocessing logs.
    • polling:
      Behavior for the polling for child-process termination:
      • cooldown (float):
        Time (s) to wait between polls.
      • timeout (float):
        Timeout (s) for the overall polling.
      • on_timeout (Literal['error', 'warn', 'ignore']):
        What to do when the polling timed out.

    The multiprocssing table and its contents are as of yet considered private implementation details.

kernprof.py

  • _add_core_parser_arguments():
    Now adding the new --[no-]prof-child-procs flags to the parser.

  • _write_preimports():
    Refactored to use the new/relocated facilities at line_profiler.curated_profiling.

  • _dump_filtered_stats():

    • New argument extra_line_stats: LineStats | None allows for handling and combining the profiling stats gathered elsewhere (e.g. child processes).
    • Partially split off into the new _dump_filtered_line_stats() which it now calls.
  • _manage_profiler:
    Context manager refactored from the old _pre_profile() for more Pythonic handling of setups and teardowns.

    • Added setup for the session cache via calling _prepare_child_profiling_cache().
    • The old function body is split off into smaller components (_prepare_profiler(), _prepare_exec_script()).
    • Now calling _post_profile() on context exit so that we no longer have to explicitly try: ... finally: ... in _main_profile().
  • _post_profile():

    • New argument extra_line_stats: LineStats | None allows for handling and combining the profiling stats gathered elsewhere (e.g. child processes).
    • Simplified because some of the cleanup is relocated to line_profiler.curated_profiling.

tests/test_child_procs.py

  • test_module:
    • Refactored from a Path fixture into a _ModuleFixture (see above in New Code).
    • Added the following command-line flags to the code:
      • --start-method selects a specific multiprocessing "start method".
      • --local toggles between using a sum function defined locally in test_module or the one defined externally in ext_module (see New Code).
      • --force-failure toggles whether the sum function should return normally or raise an error.
  • _run_as_{script,module}():
    • Now joined by a _run_as_literal_code() to also test kernprof -c ....
    • Now taking test_module as a _ModuleFixture instead of a path, and handling its installation.
  • _run_test_module():
    • New convenience wrappers run_module = partial(_run_test_module, _run_as_module), etc. now available for more convenient testing of kernprof execution modes as test parametrization.
    • New arguments:
      • profiled_code_is_tempfile: bool helps with constructing the kernprof command line in cases where the code is anonymous (kernprof -c ...).
      • use_local_func: bool, fail: bool, and start_method: Literal['fork', 'forkserver', 'spawn'] | None allows for fuzzing code execution with the aforementioned test_module CLI flags (resp. --local, --force-failure, and --start-method).
      • nhits: dict[str, int] | None, when provided, checks that the line-hit stats are as expected (all calls traced with --prof-child-procs, only those in the main process without).
    • Added checks:
      • If fail is true, the kernprof subprocess should fail.
      • Temporary .pth files created by kernprof --prof-child-procs should be cleaned up.
      • Profiling output is consistent with the provided nhits (where available).
  • test_multiproc_script_sanity_check():
    • Now fuzzing the parametrizations use_local_func, fail, and start_method, to ensure that the test script is fully functional in vanilla Python.
    • Superseded the argument as_module: bool with run_func: Callable[..., CompletedProcess], allowing for more flexible testing of execution modes (python ..., python -m ..., and the new python -c added via the aforementioned _run_as_literal_code()).
  • test_running_multiproc_script():
    New parametrization run_func allows for absorbing the old test_running_multiproc_module() into the same test as additional parametrization, as well as testing kernprof -c.

Caveats

  • The temporary .pth file created is course benign and as mentioned tries to be as out of the way as possible, but I just figured that the use of .pth files should be called out, given their recent spotlight in a CVE vulnerability.

  • Since the .pth file is written to sys.get_path('purelib'), it depends on said directory being writable. If we aren't in a venv or a similarly isolated environment (which is increasingly unlikely nowadays), all processes using the system Python will have to import and run line_profiler._child_process_profiling.load_pth_hook(). Though the function itself should quit rather quickly when we're not in a child process, it may still entail loading a significant portion of line_profiler into sys.modules.

  • Blocking Process.terminate()3 is a bit dodgy:

    • To avoid uncontrolled hot-looping .poll()-ing for the activity of the child-process PID, I'm just using a 1/32-s cooldown.

    • After all, there's a reason Process.terminate() just SIGTERMs the child process with reckless regard – children which errored out are sporadically stuck in an unclean state, and the polling may enter a deadlock. To guard against that I added:

      • A 0.25-s timeout for the polling, after which we just issue a warning and the SIGTERM is sent anyway
      • For tests running kernprof --prof-child-procs or equivalent code:
        • A 5-s timeout for subprocess.run().
        • The opportunity to retry twice if the test failed by insufficient profiling data (because the child process did clean up properly) or if the polling timed out and errored out; the latter doesn't currently happen but can be configured to

      This seems to be enough to both get rid of the deadlocks in tests and preserve profiling data... but the problem is that for child processes to deadlock AT ALL, their cleanup routines must have (of yet) failed to complete, and thus there is still a risk of profiling data not being written. So there's probably either some race conditions hidden by the delays, or an error in how the PID statuses are detected.

  • (Note however that on non-Windows platforms we can and do just setup a SIGTERM handler,4 which ensures that cleanup finishes before the child succumbs to termination. But yeah on Windows it's just the polling and the delays keeping us afloat.)

  • Apparently coverage gets by alright by only patching Process._bootstrap(), without the above termination issue. Gotta figure out why...

TODO

  • Add documentation on this new feature.
  • Maybe we should indicate this feature to be experimental...
  • Would it make more sense for any of the content in line_profiler._child_process_profiling to become public API?

Credits

Notes

Welp. This took way longer than I expected. The main friction points were that:

  • There isn't a pre-existing "global-ish" state object that I can leverage, and which can be easily replicated in subprocesses. The new line_profiler._child_process_profiling.cache.LineProfilingCache class tackles this issue.
  • I had a very hard time trying to make profiling results consistent even when the parallelly-executed function errors out. Would have thought that I already took care of that in the other project (see pytest-autoprofile::tests/test_subprocess.py::_test_inner()), but apparently I only made the tests fail there, not the parallel functions themselves. Had to do some rather hacky stuff to circumvent that (see Caveats)...3

Footnotes

  1. Note however that the equivalent vanilla Python command (python -c ...) would error out, because functions sent to multiprocessing must be pickle-able and thus reside in a physical file. This is sidestepped by kernprof's always writing code received by kernprof -c ... and ... | kernprof - to a tempfile (ENH: auto-profile stdin or literal snippets #338).

  2. In the test suite we're only testing process creation with the most common multiprocessing[.get_context(...)].Pool. However, since none of the patched components are specific to multiprocessing.pool, it should also work with other model of parallelism built with the components of multiprocessing.

  3. From the docs for mulitprocessing.Process.terminate(): Note that exit handlers and finally clauses, etc., will not be executed. Normally this doesn't matter, but if the parallelly-executed function errors out, multiprocessing has a bad habit of just .terminate()-ing child processes without allowing for enough time to run cleanup, leading to incomplete profiling data. Hence the only workaround seems to be intercepting Process.terminate() calls and blocking them where appropriate. 2 3

  4. Handling SIGTERM on Windows is generally noted to be inconsistent. See e.g. this coverage.control.Coverage._init_for_start() comment and this SO discussion that it refers to.

@TTsangSC TTsangSC changed the title FEAT: extend profiling to child processes [Draft] FEAT: extend profiling to child processes Apr 14, 2026
@TTsangSC

Copy link
Copy Markdown
Collaborator Author

Did some more tests on local post-#428-merge, maybe it is just legacy Python and dependency versions causing the issues. Will just rebase, force-push, and see what happens.

@TTsangSC TTsangSC force-pushed the profile-child-processes branch from 2cd2ed4 to f9a37af Compare April 15, 2026 03:48
TTsangSC added 26 commits April 15, 2026 20:14
- `line_profiler/curated_profiling.py`
  New module for setting up profiling in a curated environment

  - `ClassifiedPreimportTargets.from_targets()`
    Method for creating a `ClassifiedPreimportTargets` instance,
    facilitating writing pre-import modules in a replicable and portable
    manner
  - `ClassifiedPreimportTargets.write_preimport_module()`
    Method for writing a pre-import module based on an instance;
    also fixed bug where the body of the written module was intercepted
    without appearing in the debug output

- `kernprof.py`
  - `_gather_preimport_targets()`
    Migrated to `line_profiler.curated_profiling`
  - `_write_preimports()`
    Now using the new `ClassifiedPreimportTargets` class, moving esp.
    the logic to the `write_preimport_module()` method
- `kernprof.py::_manage_profiler`
  `line_profiler/curated_profiling.py::CuratedProfilerContext`
  New context-manager classes for handling profiler setup and teardown
- `kernprof.py::_pre_profile()`
  Refactored into the above context managers and other private functions
  (`_prepare_profiler()`, `_prepare_exec_script()`)
line_profiler/_child_process_profiling/cache.py::LineProfilingCache
    New class for passing info onto child processes so that profiling
    can resume there

line_profiler/pth_hook.py
    New submodule for the .pth-file-based solution to propagating
    profiling into child processes:

    write_pth_hook()
        In the main process, write the temporary .pth file to be loaded
        in child processes
    load_pth_hook()
        Called by the .pth in child process, loading the cache and
        setting up profiling based thereon
line_profiler/_child_process_profiling/cache.py::LineProfilingCache
    Added new `.profile_imports` attribute to correspond to `kernprof`'s
    `--prof-imports` flag

line_profiler/_child_process_profiling/meta_path_finder.py
    New submodule defining the `RewritingFinder` class, a meta path
    finder which rewrites a single module on import

line_profiler/_child_process_profiling/pth_hook.py
    write_pth_hook()
        Now also handling the `os.fork()` patching/wrapping
    _setup_in_child_process()
        Now creating a `RewritingFinder` to mirror what
        `~.autoprofile.autoprofile.run()` does in the main process

.
line_profiler/_child_process_profiling/cache::LineProfilingCache
    Refactored `.load()`

line_profiler/_child_process_profiling/multiprocessing_patches.py
    New submodule for applying patches to the `multiprocessing`
    package, so that profiling is automatically set up in child
    processes created by it
line_profiler/_child_process_profiling/cache.py::LineProfilingCache
    <general>
        Added debug logging to various methods
    gather_stats()
        New method for gathering profiling stats from child processes
    inject_env_vars()
        New method for injecting `.environ` into `os.environ`

line_profiler/line_profiler.py::LineStats
    get_empty_instance()
        New convenience method for creating an empty instance
    from_files()
        Added new argument `on_defective` to allow for processing a
        group of files that cannot all be correctly read
line_profiler/rc/line_profiler.toml::[tool.line_profiler.kernprof]
    Added new key-value pair `prof-child-procs` for the default value
    of `kernprof --prof-child-procs`

kernprof.py
    - New boolean flags
      `[--prof-child-procs[=...] | --no-prof-child-procs]` for
      controlling whether to set up profiling in child processes
    - Fixed bug in `_manage_profiler.__exit__()` where
      `CuratedProfilerContext.uninstall()` can be skipped if the
      preceding code raises an error
kernprof.py::_prepare_child_profiling_cache()
    - Now respecting ${LINE_PROFILER_KEEP_TEMPDIRS}
    - Now setting `LineProfilingCache.debug`

line_profiler/_child_process_profiling/cache.py::LineProfilingCache
    - Added new attributes `.debug` and `._debug_log`
    - Now diverting debug messages to log files in `.cache_dir`
line_profiler/_child_process_profiling/cache.py::LineProfilingCache
    add_cleanup()
        Now deferring to a `._add_cleanup()` method which allows for
        cleanup-function prioritization
    _debug_output()
       Fixed type-checking

line_profiler/_child_process_profiling/multiprocessing_patches.py
::apply()
    Added debug output before `_setup_in_child_process()` is called to
    help with tracing

line_profiler/_child_process_profiling/pth_hook.py
    load_pth_hook()
    _wrap_os_fork()
        Added debug output before `_setup_in_child_process()` is called
        to help with tracing
    _setup_in_child_process()
        - `wrap_os_fork` now defaults to false
        - `prof.dump_stats()` now has increased priority over other
          callbacks (doesn't seem to help with the malformed prof files
          though...)
        - Child-process profiling output now written to a less
          randomized filename to facilitate debugging
line_profiler/_child_process_profiling/cache.py::LineProfilingCache
    profiler
        New attribute for the profiler instance
    copy(..., inherit_profiler=...)
        New argument for inheriting the `.profiler`
    load()
        Now keeping track of the loaded instance and returning it in
        subsequent calls

line_profiler/_child_process_profiling/multiprocessing_patches.py
::apply(..., lp_cache=None)
    - If the `LineProfilingCache.load()`-ed instance is consistent with
      that loaded from `cache_path`, the former is used
    - Added more debugging output

line_profiler/_child_process_profiling/pth_hook.py
    load_pth_hook()
        Added more debugging output
    _wrap_os_fork()
        Updated debugging output
    _setup_in_child_process()
        - Now returning a boolean (whether setup has been newly done)
        - Now setting `.profiler` of the cache instance
        - Added moew debugging output
kernprof.py::_manage_profiler.__enter__()
    Updated so that the created `LineProfilingCache` instance carries a
    `.rewrite_module`

line_profiler/_child_process_profiling/cache.py::LineProfilingCache
    Added an optional `.rewrite_module` attribute

line_profiler/_child_process_profiling/import_machinery.py
::RewritingFinder.find_spec()
    Now looking at `.lp_cache.rewrite_module` (where available) to check
    for specs to return
line_profiler/_child_process_profiling/
    cache.py::LineProfilingCache
        _replace_loaded_instance()
            New convenience method for an instance in a fork to replace
            the instance to be `.load()`-ed
        _consistent_with_loaded_instance
            New attribute for checking whether the instance is
            consistent with what would have been `.load()`-ed
    multiprocessing_patches.py
        bootstrap(..., lp_cache=...)
            Can now be `None`, which defers the `.load()`-ing of the
            cache instance
        apply()
            - Streamlined logic for retrieving the loaded instance
            - Now using the above deferred loading whenever appropriate,
              so that cleanup and profiling is preserved in forked
              processes
    pth_hook.py::_wrap_os_fork()
        Now using `._replace_loaded_instance()`, so that future calls to
        `.load()` in the forked process retrieves the newly-created
        instance
kernprof.py::_prepare_child_profiling_cache()
    - Updated call to `[...].multiprocessing_patches.apply()`
    - Now always setting up the created instance as the one returned by
      further calls to `.load()`

line_profiler/_child_process_profiling/multiprocessing_patches.py
    PickleHook
        - Refactored to contain no instance variables
        - Now always using `LineProfilingCache.load()` to retrieve the
          appropriate cache instance
    bootstrap()
        Removed argument `lp_cache`
    get_preparation_data()
        Removed arguemnt `cache_path`
    apply()
        - Removed argument `cache_path`
        - Argument `lp_cache` now required
        - Simplified implementation
line_profiler/_child_process_profiling/import_machinery.py
    Removed

line_profiler/_child_process_profiling/pth_hook.py
::_setup_in_child_process()
    No longer set up the `RewritingFinder` because messing with the
    import system doesn't help with propagating autoprofiling rewrites
    to child processes...
kernprof.py
    _dump_filtered_stats()
        Fixed bug where if no tempfile remains, the `extra_line_stats`
        are not merged into the dumped stats
    _prepare_child_profiling_cache()
        Now setting the `.profiler` of the returned cache object
line_profiler/_child_process_profiling/multiprocessing_patches.py
::_apply_mp_patches()
    - Added debugging output for the patches
    - Now patching the copy of `runpy` imported by
      `multiprocessing.runpy`

line_profiler/_child_process_profiling/pth_hook.py
    _wrap_os_fork()
        No longer creating a new `LineProfiler` instance (helps with
        handling forked processes)
    _setup_in_child_process(..., prof=...)
        New argument for avoiding instantiating a new profiler when not
        necessary (e.g. in a forked process)

line_profiler/_child_process_profiling/runpy_patches.py
    New submodule for the aforementioned patching of `runpy`
tests/test_child_procs.py
    test_running_multiproc_literal_code()
        New test paralleling `test_running_multiproc_{script,module}` to
        test `kernprof -c ...`
    test_multiproc_script_sanity_check()
        - Refactored parameters for better `pytest` output
        - Added testing for running the code with `python -c ...`
    <Misc>
        - Added CLI argument `--local` to the profiled module to toggle
          between a locally-defined summing function and an imported one
        - Refactored how the test modules are injected
        - Added debugging output to `subprocess.run()` calls
        - Added provisional support for examining the profiling data
tests/test_child_procs.py::test_multiproc_script_sanity_check()
    Now parametrized to test passing the function defined in the test
    module itself to `multiprocessing`
tests/test_child_procs.py
    test_running_multiproc_{module,literal_code}()
        Integrated into `test_running_multiproc_script()`
    test_running_multiproc_script()
        Extended parametrization
tests/test_child_procs.py
    test_profiling_multiproc_script()
        Test parallel to `test_running_multiproc_script()`, checking
        whether we are correctly profiling the child processes
    <General>
        - Added more docs
        - Updated dummy parameter names
    _ext_module, _test_module
        - Refactored how the fixtures are set up
        - Module names now randomized and clash-proof via `uuid.uuid4()`
    _run_subproc()
        - Moved code outputting captured streams from
          `_run_test_module()` to here
        - Added timing code
tests/test_child_procs.py
    TEST_MODULE_BODY, [_]test_module()
        Added CLI flag to select `multiprocessing` start methods
    _Params
        New convenience class for test parametrization
    test_multiproc_script_sanity_check()
        - Streamlined parametrization (15 subtests -> 10)
        - Added subtests for various `multiprocessing` start methods
    test_multiproc_script_sanity_check()
        - Streamlined parametrization (24 subtests -> 21)
        - Added subtests for various `multiprocessing` start methods
tests/test_child_procs.py
    test_module(), ext_module()
        Updated so that we can toggle for the function sent to
        `multiprocessing` to raise an error with the `--force-failure`
        CLI flag
    _run_test_module()
        - Now raising a new `ResultMismatch` error class (instead of
          using base assertions) for:
          - If `test_module()` writes the wrong number to stdout
          - If `nhits` are provided and the profiling results differ
            therefrom
        - Added argument `fail` for using the aforementioned
          `--force-failure` flag
    test_multiproc_script_sanity_check()
        Now also chceking the cases where the test module is run with
        `--force-failure`
    test_profiling_multiproc_script()
        Now also chceking the cases where the test module is run with
        `--force-failure`
        (FIXME: profiling bugged when the function errors out, and
        doesn't fail with a consistent pattern)
.github/workflows/tests.yml
    "Test full loose sdist", "Test wheel ${{ matrix.install-extras }}"
        Added 10-m timeouts
    "Build binary wheels"
        Added 60-m timeout
@TTsangSC

Copy link
Copy Markdown
Collaborator Author

When trying to sniff around and trigger and fix the bug I ran into an even weirder issue.

  • In principle, the @_timeout decorator does nothing other than to run the function on a new (daemon) thread, pickle and return/raise the result if it finished execution without the time limit, and just raise a timeout error otherwise.
  • Moving said decorator out from the function using multiprocessing to the entire test function, the first subtest passes while the following mostly fails, on account of the profiling stats being inconsistent.
  • Interestingly, the failure patterns seem to be that the stats are:
    • Correctly collected in child threads and/or processes when using multiprocessing.dummy (i.e. threads) or the start methods forkserver or spawn, but
    • Not collected when using the start method fork, and
    • Not collected in the "current" thread on which the test function is run.

This seems to indicate something being wrong when profiling starts on a non-main thread; in view of that, how start_method='fork' completely falls apart kinda makes sense, given Python's warnings on mixing process forking and multithreading. But then this still doesn't explain why we're losing stats on the current thread from the second subtest onwards. There's possibly some pollution in thread-local states which I'll have to diagnose...

TTsangSC added 7 commits May 22, 2026 07:16
tests/test_child_procs.py
    @_timeout
        Fixed bug where thread-local profiler states aren't cleaned up
        when used to decorate a test function
    _test_apply_mp_patches_inner()
        Moved `@_timeout` decorator from the parallel function
        (`test_module_object.sum_in_child_procs()`) to the test function
        itself
tests/test_child_procs.py::_run_subproc()
    - Simplified handling of the `check` parameter
    - Updated implementation so that the `CalledProcessError` or
      `TimeoutExpired`'s `.stdout` and `.stderr` are used for
      end-of-process debug printouts
tests/test_child_procs.py
    _preserve_attributes
        Now permitting `targets=None`, which resolves to
        `_GLOBAL_PATCHES` at `.__enter__()` time
    {_run_as,run}_{module,script,literal_code}()
        Updated signatures:
        - New leading parameter `request`
        - New keyword-only parameter `subproc` for controlling whether
          to spin up a subprocess to run `kernprof` (old and default
          behavior) or emulate one in-process
    _run_kernprof_main_in_process()
        New function for emulating
        `_run_subproc(['kernprof', ...], ...)` in-process to attempt to
        recover more debugging output (because `capture_output`
        seems to completely fail when the process is timed out)
    test_multiproc_script_sanity_check()
    _test_profiling_multiproc_script()
    test_profiling_multiproc_script_{success,failure}()
        Updated signatures and implementations to pass in a `request` as
        required
kernprof.py::_prepare_child_profiling_cache()
    Now creating the session-cache directory inside the tempdir already
    created in `main()`

line_profiler/_child_process_profiling/cache.py::LineProfilingCache
    _warn_possible_lack_of_stats()
        Now gracefully handling the edge case where this is called (e.g.
        in `multiprocessing.Process.terminate()`) after the associated
        `.cache_dir` has been deleted
    _replace_loaded_instance()
        Now setting up for the old value of `._loaded_instance` to be
        restored at `.cleanup()` time

tests/test_child_procs.py::test_cache_setup_main_process()
    Updated order of checks because of the above change in
    `LineProfilingCache._replace_loaded_instance()`
line_profiler/_child_process_profiling/cache.py
::LineProfilingCache._consistent_with_loaded_instance
    Fixed bug where accessing this property causes an instance to be
    cached if one isn't already `.load()`-ed, making for incomplete
    `.cleanup()` after which `.load()` returns said created instance
    instead of a fresh one
tests/test_child_procs.py
    _WarningContext
        - Added init param `.reissue_warnings` and method `.reissue()`
          to handle the reissuing of the intercepted warnings
        - Added methods `.suppress_warnings()` and
          `.propagate_warnings()` for fine-grained control over which
          warnings to reissue
    _check_warnings
        - Added methods `.suppress_warnings()` and
          `.propagate_warnings()` (see above)
        - Updated `.__exit__()` so that captured warnings are
          conditionally reissued with `_WarningContext.reissue()`
    _run_as_{script,module,literal_code}()
    _run_kernprof_main_in_process()
        When using `subproc=False` (e.g. in
        `test_profiling_multiproc_script_{success,failure}()`), stray
        warnings are guarded against with `_check_warnings`, as we're
        already doing in `test_apply_mp_patches_{success,failure}()`
tests/test_child_procs.py
    _run_test_module()
        - `subproc` is now a named keyword param
        - if `subproc=False`, try harder to recover and print the debug
          logs even if `kernprof.main()` hasn't written to `debug_log`
    test_profiling_multiproc_script_{success,failure}()
        - Now including `subproc` in the parametrization so that we
          still have a case testing running `kernprof` in a subprocess
@TTsangSC

TTsangSC commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator Author

Sorry for the lack of update. Was a bit shellshocked after the last blunder and held off on making pushes until I can diagnose what happened and better reproduce the sporadic hanging bug...

... in which however I am not quite successful. It still only shows up every ≈1000 tests or so, and apparently according to the logs, that is due to the signal handler's somehow not firing on one of the child processes; still trying to figure out how that is at all possible. Still I've made some further changes:

  • Added workflow-level timeouts to all the test jobs to avert the worse-case scenario of something being stuck for six hours.
  • Fixed a bug in LineProfilingCache which causes global-state pollution after kernprof.main() has been called.
  • Updated tests/test_child_procs.py::test_profiling_multiproc_{success,failure}() so that most of the subtests are run with kernprof.main() in-process.

If it isn't as safe and deterministic to temper with signal handling as I've initially hoped, we may just have to report profiling stats more granularly like on Windows, where each multiproc pool task prompts the child process to write the profiling stats to its assigned file. Since one of the patches already patches task/result queues to send the child-process identity back to the parent alongside the task result, it should be easy (though with overhead) to also slip the collected stats in. Will see if that helps.

Oh and looks like I broke something else completely related... not a good sign. The lint-job failure seems unrelated though, it was on line_profiler/autoprofile/profmod_extractor.py and I didn't touch that file. Seems an artifact of our not pinning the ty version – on 0.0.31 it still type-checked and now on 0.0.46 it doesn't. Will fix both either way.

@TTsangSC

Copy link
Copy Markdown
Collaborator Author

Still working on this on-and-off, but I'm unfortunately still stuck with flaky tests... seems that there's something which makes SIGTERM handling inherently unreliable in multiprocessing child processes, causing them to randomly hang (see python/cpython#73945, python/cpython#82408, and coveragepy/coveragepy#1310).

Unfortunately this means that there's no guarantee for profiling output when a child process is BaseProcess.terminate()-ed, since an unhandled SIGTERM breaks the Python runtime (try-finally clauses, atexit hooks, etc.). Seems that the only workaround is to avoid having children terminated at all, will look more into that.

TTsangSC added 15 commits June 26, 2026 03:27
kernprof.py::_prepare_profiler()
    No longer replacing `sys.argv` because it its protected by the
    `@_restore.sequence(sys.argv)` decorator on `main()`, and swapping
    out the object invalidates said protection
line_profiler/_child_process_profiling/cache.py
::@LineProfilingCache._method_wrapper
    Now indicating the wrapper in the emitted debug-log messages so as
    to reduce confusion for callables wrapped multiple times (e.g.
    `multiprocessing.pool.worker()`)
tests/test_child_procs.py
    _check_warnings.__init__()
        `reissue_warnings` now defaults to true
    _run_kernprof_main_in_process()
        Fixed bug where if `_check_warnings` raises a `ResultMismatch`
        it is erroneously converted into a non-zero return code (instead
        of just being propagated)
    test_cache_setup_child()
    test_apply_mp_patches_{success,failure}(start_method='fork')
        Updated implementations to explicitly suppress (i.e. not
        reissue) expected warnings
line_profiler/_child_process_profiling/cache.py::LineProfilingCache
    _wrap_os_fork()
        Updated `os.fork()` wrapper to unregister the `._atexit_hook` of
        the inherited instance
    @_method_wrapper
        Added new parameter `wrapper_name` for more flexible debug-log
        messages
tests/test_child_procs.py::test_apply_mp_patches_{success,failure}()
    Moved location of `pytest.skip()` call because calling it from
    within a child thread (such as that created by `@_timeout`) causes
    issues
line_profiler/_child_process_profiling/multiprocessing_patches.py
::_setup_in_mp_child()
    Moved PID check from one of the sub-callbacks to here

tests/test_child_procs.py
    _check_warnings, _WarningContext
        Added new parameter `format_warnings` for controlling whether
        to format the recorded warnings that caused the
        `ResultMismatch` error, because apparently `.reissue()` leaves
        some warnings out sometimes
    _run_kernprof_main_in_process(), _test_apply_mp_patches()
        Updated warning filters to be more specific to avoid bycatches
line_profiler/_child_process_profiling/multiprocessing_patches.py
    TaskWrapper, wrap_get_tasks(), wrap_guarded_task_generation()
        Removed (superseded by `wrap_worker_pool_write_per_task()`)
    _QueuePIDWrapper
        Reworked into `_QueuePutWrapper`
    wrap_worker_pool()
        Reworked into `wrap_worker_pool_write_on_exit()`
    wrap_worker_pid()
        Refactored to use the new `_QueuePutWrapper`
    wrap_process()
        Now asserting `BaseProcess.join()` and `.terminate()` to be
        bound methods
line_profiler/_child_process_profiling/multiprocessing_patches.py
    _PatchRegistry
        New mapping class to allow for prioritization of the registered
        plugins
    _PATCHES
        Now a `_PatchRegistry`
    _register_patch()
        - Now `_PATCHES.register()`
        - Now taking the optional argument `priority`
    wrap_worker_pool_write_per_task()
        Now also calling `_setup_in_mp_child()`
    apply()
        Now making use of `_PatchRegistry.select()` for selecting the
        patches to apply
line_profiler/_child_process_profiling/multiprocessing_patches/
    Split the contents of `__init__.py` into separate submodules:

    poller.py::Poller
        Migrated from `__init__.py::_Poller`
    _queue.py::PutWrapper
        Migrated from `__init__.py::_QueuePutWrapper`
    config.py::MPConfig
        Migrated from `__init__.py::MPConfig`
    _infrastructure.py
        Patch
            - Migrated from `__init__.py::_Patch`
            - Added attribute `.priority` to the interface
        SingleModulePatch
            Migrated from `__init__.py::Patch`
        Registry
            - Migrated from `__init__.py::_PatchRegistry`
            - Added class method `.from_entry_point()` for constructing
              an instance from patches loaded from an entry point
    _mandatory_patches.py::{RebootForkserver,ResourceTracker,RunPy}Patch
        - Migrated from the eponymous classes in `__init__.py`
        - Now declared as `line_profiler._multiproc_patches` entry
          points
    _profiling_patches.py
        POOL_PATCH, PROCESS_PATCH
            `SingleModulePatch` objects that are now exposed as
            `line_profiler._multiproc_patches` entry points
        wrap_worker[_{write_on_exit,write_per_task}]()
            Migrated from `__init__.py::wrap_worker_pool*()`
        wrap_bootstrap(), wrap_terminate()
            Migrated from the eponymous functions in `__init__.py`
    _optional_patches.py
        CHILD_PIDS_PATCH, LOGGING_PATCH
            `SingleModulePatch` objects that are now exposed as
            `line_profiler._multiproc_patches` entry points
        wrap_handle_results(), wrap_process()
            Migrated from the eponymous functions in `__init__.py`
        wrap_worker()
            Migrated from `__init__.py::wrap_worker_pid()`
    __init__.py::__all__
        Now including the following:
        - `MPConfig` (= `config.py::MPConfig`)
        - `Poller` (= `poller.py::Poller`)
        - `Registry` (= `_infrastructure.py::Registry`)
        - `Timeout` (= `poller.py::Poller.Timeout`)

tests/test_child_procs.py
    Updated imports from
    `line_profiler._child_process_profiling.multiprocessing_patches`

setup.py
    Added the aforementioned `line_profiler._multiproc_patches` entry
    points
line_profiler/_child_process_profiling/multiprocessing_patches/
    _mandatory_patches.py::wrap_{terminate,start,bootstrap}()
    _mandatory_patches.py::PROCESS_TERMINATION_PATCH
        New patch for `multiprocessing.process.BaseProcess` with
        increased priority, which ensures that SIGTERM isn't sent to
        child processes until they are finished with setting up;
        exposed as entry point `__process_termination`
    _mandatory_patches.py::setup_mp_child()
        Refactored and migrated from
        `_profiling_patches.py::setup_mp_child()`
    _profiling_patches.py::wrap_{worker_*,bootstrap}()
        Removed basic setup (migrated to `PROCESS_TERMINATION_PATCH`)

setup.py
    Added entry point `__process_termination` to
    `line_profiler._multiproc_patches`
line_profiler/_child_process_profiling/cache.py
::LineProfilingCache._wrap_os_fork()
    `os.fork()` wrapper now clearing the cleanup-callback stacks on the
    pre-fork instance in the forked process to avoid clashes with the
    new, post-fork instance

line_profiler/rc/line_profiler.toml
    Updated comments
We no longer catch and handle SIGTERM because that apparently causes
deadlocks in `multiprocessing` child processes (see CPython GitHub
issues 73945 & 82408, coverage issue 1310)... have to figure out another
way to ensure the writing of profiling data.

line_profiler/_child_process_profiling/
    cache.py::LineProfilingCache
        Removed private attributes and methods related to signal
        handling
    multiprocessing_patches/_mandatory_patches.py::setup_mp_child()
        No longer adding `SIGTERM` handling
    multiprocessing_patches/_profiling_patches.py
        dump_stats_quick()
            Updated call signature
        wrap_worker_write_*(), wrap_bootstrap()
            Removed reference to `SIGTERM` handling
    multiprocessing_patches/mp_config.py::MPConfig
        Removed attribute `.catch_sigterm`

line_profiler/rc/line_profiler.toml
::[tool.line_profiler.child_processes.multiprocessing]
    Removed config item `catch_sigterm`

TODO:
    Update `_profiling_patches` to mitigate `BaseProcess.terminate()`
line_profiler/_child_process_profiling/multiprocessing_patches
    (The `child_pids` optional patch has been reworked into the
    `__pool_worker_pid` mandatory patch.)

    __init__.py::apply()
        Updated docstring
    _infrastructure.py::Registry.from_entry_point()
        Updated doctest
    _mandatory_patches.py
        POOL_WORKER_PID_PATCH
            Migrated from `_optional_patches.py::CHILD_PIDS_PATCH`
        wrap_handle_results(), wrap_process(), wrap_worker()
            Migrated from eponymous functions in `_optional_patches.py`
    _profiling_patches.py
        wrap_worker()
            Now always using the previous `wrap_worker_write_per_task()`
            implementation, because we're no longer catching SIGTERM
            even on POSIX
        wrap_terminate()
            Now only blocking the call to `BaseProcess.terminate()` if
            `self` is a pool worker which has run at least 1 task; this
            avoids having idle workers in a "dirty" state interfering
            with pool termination

line_profiler/rc/line_profiler.toml
::[tool.line_profiler.child_processes.multiprocessing.patches]
    Removed item `child_pids`

setup.py
    Renamed entry point: `line_profiler._multiproc_patches.child_pids`
    -> `.__pool_worker_pid`

tests/test_child_procs.py
    _run_kernprof_main_in_process()
    _test_apply_mp_patches()
    test_apply_mp_patches_success()
        Removed references to the `child_pids` patch
tests/test_child_procs.py::test_apply_mp_patches_failure()
    Removed `@pytest.mark.retry` marker

tests/conftest.py, tests/test_child_procs.py
    Removed because `@pytest.mark.retry` is no longer used anywhere
@TTsangSC TTsangSC force-pushed the profile-child-processes branch from fe70770 to bc3adb9 Compare June 26, 2026 01:47
@TTsangSC

TTsangSC commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator Author

The lint job failed on ty with 5 diagnostics, but they are all warnings (redundant casts) and I don't think we're supposed to fail on those...

EDIT: of course they set error-on-warning to true in 0.0.52.

@Erotemic

Erotemic commented Jun 26, 2026

Copy link
Copy Markdown
Member

Yeah, I'm going to either pin ty or use a more stable linter for CI. Don't worry much about that.

Let's take this approach.

Let's clearly define the boundary between the cases that we guarantee will work, and the unsupported cases.

It feels like there are some fundamental limitations.

The signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored

https://man7.org/linux/man-pages/man7/signal.7.html

@TTsangSC

Copy link
Copy Markdown
Collaborator Author

Yeah at this point I think I have to accept defeat, that:

  • Per-task profiling (as implemented in the pool patch) is the only way to consistently profile Pool workloads (i.e. "tasks");
  • A worker process can arbitrarily hang between tasks, probably because it is waiting to acquire a lock on a shared queue, which is either held by the parent as a part of pool termination, or maybe by another worker which got terminated before it can properly release the lock.
  • We probably shouldn't try to block/defer the call to BaseProcess.terminate() (as implemented in the process patch) as it's bound to either be nondeterministic or cause hangs.

Which is a bummer, but I guess it's about time I learned, instead of continuing burning CI compute in flaky tests and letting the PR sit in limbo. As such I'll probably have to:

  • Remove the subtests where we apply only the process patch but not the pool patch, because the underlying test script is ultimately using pool-based parallelism.
  • Keep the subtests that has both applied (i.e. the default behavior) to ensure that there are no adverse interactions between the two, and
  • Write new tests that directly create and manage BaseProcess objects without going through a Pool, and test that the pool patch works as expected there.

Other remarks:

  • All the Linux failures in the last pipeline however happened on a single other test, and was because of an edge case that I haven't yet run into: an idle worker process (having run 0 tasks), which however has naturally died before Pool._terminate_pool() is called. Since the process isn't alive, neither BaseProcess.terminate() nor .join() was called, and thus we didn't register that the process was idle and that we expected its profiling-stats file to be empty. I have a fix on local where we patch Pool._terminate_pool() instead of Pool.Process() for the bookkeeping, which should fix the issues.
  • And the Windows job... unfortunately it errored out when processing the logs, which makes it a bit hard to figure out what exactly happened. Even more curious is how it failed on a *_success test (i.e. one where the parallel workload doesn't raise an error), while usually it's the *_failure tests where all hell breaks loose. Guess that we can fix the bare asserts and put in more helpful error messages.
  • The MacOS failure particularly stings because the offending tests have been run into the ground on my local. Trust me, I wouldn't have pushed if the tests were a tenth as flaky in my testing as they behave on CI. But alas, works-on-my-machine-itis is a thing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants