Created
July 29, 2019 22:59
-
-
Save feuGeneA/96f25376444ddcdd9bf412abc75d76dd to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
"""A command-line utility called `parallel`.""" | |
from concurrent.futures import ProcessPoolExecutor, wait | |
from os import chdir | |
from subprocess import check_call | |
from sys import argv | |
PACKAGES = [ | |
"contract_addresses", | |
"contract_artifacts", | |
"contract_wrappers", | |
"json_schemas", | |
"sra_client", | |
"order_utils", | |
"middlewares", | |
] | |
def run_cmd_on_package(package: str): | |
"""cd to the package dir, ./setup.py lint, cd ..""" | |
chdir(package) | |
check_call(f"{' '.join(argv[1:])}".split()) | |
chdir("..") | |
wait(ProcessPoolExecutor().map(run_cmd_on_package, PACKAGES)) | |
Calling that command-line utility: | |
$ ./parallel coverage run setup.py test | |
[...output showing that all executed processes completed without error...] | |
Traceback (most recent call last): | |
File "./parallel", line 44, in <module> | |
wait(ProcessPoolExecutor().map(run_cmd_on_package, PACKAGES)) | |
File "/home/gene/.pythonz/pythons/CPython-3.7.2/lib/python3.7/concurrent/futures/_base.py", line 284, in wait | |
with _AcquireFutures(fs): | |
File "/home/gene/.pythonz/pythons/CPython-3.7.2/lib/python3.7/concurrent/futures/_base.py", line 146, in __enter__ | |
future._condition.acquire() | |
AttributeError: 'NoneType' object has no attribute '_condition' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment