Created
October 1, 2024 11:32
-
-
Save graingert/71ff2fb371a5538df740bc76eedcbdee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[run] | |
branch = True | |
parallel = True | |
concurrency = multiprocessing,thread | |
source_pkgs = demo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
graingert@conscientious venv ~/projects/coverage_multiprocess_chdir coverage run demo.py | |
graingert@conscientious venv ~/projects/coverage_multiprocess_chdir coverage combine | |
Combined data file .coverage.conscientious.481389.XMZfknLx | |
Combined data file .coverage.conscientious.481390.XhvFJIXx | |
graingert@conscientious venv ~/projects/coverage_multiprocess_chdir coverage report -m | |
Name Stmts Miss Branch BrPart Cover Missing | |
----------------------------------------------------- | |
demo.py 19 1 6 1 92% 10, 23->exit | |
----------------------------------------------------- | |
TOTAL 19 1 6 1 92% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import multiprocessing | |
import tempfile | |
import contextlib | |
def hit(): | |
pass | |
def missed(): | |
pass | |
def go(target): | |
p = multiprocessing.Process(target=target) | |
p.start() | |
p.join() | |
def main(): | |
go(hit) | |
with tempfile.TemporaryDirectory() as tmp: | |
with contextlib.chdir(tmp): | |
go(missed) | |
if __name__ == "__main__": | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment