mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 19:55:41 +03:00
maintainers/scripts/update: Prepare for ordered updates
Just minor refactorings: - Extract `updater_tasks` into a variable. - Make `main` itself async.
This commit is contained in:
parent
f9d05fe6a1
commit
1d2c1810eb
1 changed files with 27 additions and 23 deletions
|
@ -289,34 +289,36 @@ async def start_updates(
|
||||||
|
|
||||||
# Prepare updater workers for each temp_dir directory.
|
# Prepare updater workers for each temp_dir directory.
|
||||||
# At most `num_workers` instances of `run_update_script` will be running at one time.
|
# At most `num_workers` instances of `run_update_script` will be running at one time.
|
||||||
updaters = asyncio.gather(
|
updater_tasks = [
|
||||||
*[
|
updater(
|
||||||
updater(
|
nixpkgs_root,
|
||||||
nixpkgs_root,
|
temp_dir,
|
||||||
temp_dir,
|
merge_lock,
|
||||||
merge_lock,
|
packages_to_update,
|
||||||
packages_to_update,
|
keep_going,
|
||||||
keep_going,
|
commit,
|
||||||
commit,
|
)
|
||||||
)
|
for temp_dir in temp_dirs
|
||||||
for temp_dir in temp_dirs
|
]
|
||||||
]
|
|
||||||
|
tasks = asyncio.gather(
|
||||||
|
*updater_tasks,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Start updater workers.
|
# Start updater workers.
|
||||||
await updaters
|
await tasks
|
||||||
except asyncio.exceptions.CancelledError:
|
except asyncio.exceptions.CancelledError:
|
||||||
# When one worker is cancelled, cancel the others too.
|
# When one worker is cancelled, cancel the others too.
|
||||||
updaters.cancel()
|
tasks.cancel()
|
||||||
except UpdateFailedException as e:
|
except UpdateFailedException as e:
|
||||||
# When one worker fails, cancel the others, as this exception is only thrown when keep_going is false.
|
# When one worker fails, cancel the others, as this exception is only thrown when keep_going is false.
|
||||||
updaters.cancel()
|
tasks.cancel()
|
||||||
eprint(e)
|
eprint(e)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def main(
|
async def main(
|
||||||
max_workers: int,
|
max_workers: int,
|
||||||
keep_going: bool,
|
keep_going: bool,
|
||||||
commit: bool,
|
commit: bool,
|
||||||
|
@ -338,7 +340,7 @@ def main(
|
||||||
eprint()
|
eprint()
|
||||||
eprint("Running update for:")
|
eprint("Running update for:")
|
||||||
|
|
||||||
asyncio.run(start_updates(max_workers, keep_going, commit, packages))
|
await start_updates(max_workers, keep_going, commit, packages)
|
||||||
|
|
||||||
eprint()
|
eprint()
|
||||||
eprint("Packages updated!")
|
eprint("Packages updated!")
|
||||||
|
@ -388,12 +390,14 @@ if __name__ == "__main__":
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
main(
|
asyncio.run(
|
||||||
args.max_workers,
|
main(
|
||||||
args.keep_going,
|
args.max_workers,
|
||||||
args.commit,
|
args.keep_going,
|
||||||
args.packages,
|
args.commit,
|
||||||
args.skip_prompt,
|
args.packages,
|
||||||
|
args.skip_prompt,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
except KeyboardInterrupt as e:
|
except KeyboardInterrupt as e:
|
||||||
# Let’s cancel outside of the main loop too.
|
# Let’s cancel outside of the main loop too.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue