Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for synchronous and asynchronous modes in package cache #1853

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 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 All @@ -59,6 +67,7 @@ def setup_parser(parser, completions=False):


def add_variant(pkgcache, uri, opts):
from rez.config import config
from rez.packages import get_variant_from_uri
from rez.utils.logging_ import print_info, print_warning
from rez.package_cache import PackageCache
Expand All @@ -70,7 +79,17 @@ 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 == "async":
sync = False
elif opts.pkg_cache_mode == "sync":
sync = True
else:
sync = not config.package_cache_async

destpath, status = pkgcache.add_variant(
variant, force=opts.force,
wait_for_copying=sync
)

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