Skip to content

Commit

Permalink
Add support for synchronous and asynchronous modes in package cache
Browse files Browse the repository at this point in the history
- Introduced a new command-line argument `--pkg-cache-mode` to specify caching mode.
- Allows users to choose between 'sync' and 'async' modes, overriding the default configuration.
- Updated `add_variant` function to handle the new caching mode option.
- Ensures backward compatibility by maintaining default behavior when no mode is specified.
  • Loading branch information
Pixel-Minions committed Oct 14, 2024
1 parent 491497f commit c21b725
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/rez/cli/pkg-cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ def setup_parser(parser, completions=False):
group.add_argument(
"--daemon", action="store_true", help=SUPPRESS
)
parser.add_argument(
"--pkg-cache-mode",
choices=["sync", "async"],
default=None,
help="If provided, override the rezconfig's package_cache_async key. "
"If 'sync', the process will block until packages are cached. "
"If 'async', the process will not block while packages are cached."
)
parser.add_argument(
"-c", "--columns", nargs='+', choices=column_choices,
default=["status", "package", "variant_uri", "cache_path"],
Expand Down Expand Up @@ -70,7 +78,15 @@ def add_variant(pkgcache, uri, opts):
print("No such variant: %s" % uri, file=sys.stderr)
sys.exit(1)

destpath, status = pkgcache.add_variant(variant, force=opts.force)
if opts.pkg_cache_mode is not None:
cache_mode = True if opts.pkg_cache_mode == "sync" else False
destpath, status = pkgcache.add_variant(
variant, force=opts.force,
wait_for_copying=cache_mode
)
# If no mode is specified, use the default behavior.
else:
destpath, status = pkgcache.add_variant(variant, force=opts.force)

if status == PackageCache.VARIANT_FOUND:
print_info("Already exists: %s", destpath)
Expand Down

0 comments on commit c21b725

Please sign in to comment.