@@ -41,6 +41,14 @@ def setup_parser(parser, completions=False):
4141 group .add_argument (
4242 "--daemon" , action = "store_true" , help = SUPPRESS
4343 )
44+ parser .add_argument (
45+ "--pkg-cache-mode" ,
46+ choices = ["sync" , "async" ],
47+ default = None ,
48+ help = "If provided, override the rezconfig's package_cache_async key. "
49+ "If 'sync', the process will block until packages are cached. "
50+ "If 'async', the process will not block while packages are cached."
51+ )
4452 parser .add_argument (
4553 "-c" , "--columns" , nargs = '+' , choices = column_choices ,
4654 default = ["status" , "package" , "variant_uri" , "cache_path" ],
@@ -59,6 +67,7 @@ def setup_parser(parser, completions=False):
5967
6068
6169def add_variant (pkgcache , uri , opts ):
70+ from rez .config import config
6271 from rez .packages import get_variant_from_uri
6372 from rez .utils .logging_ import print_info , print_warning
6473 from rez .package_cache import PackageCache
@@ -70,7 +79,17 @@ def add_variant(pkgcache, uri, opts):
7079 print ("No such variant: %s" % uri , file = sys .stderr )
7180 sys .exit (1 )
7281
73- destpath , status = pkgcache .add_variant (variant , force = opts .force )
82+ if opts .pkg_cache_mode == "async" :
83+ sync = False
84+ elif opts .pkg_cache_mode == "sync" :
85+ sync = True
86+ else :
87+ sync = not config .package_cache_async
88+
89+ destpath , status = pkgcache .add_variant (
90+ variant , force = opts .force ,
91+ wait_for_copying = sync
92+ )
7493
7594 if status == PackageCache .VARIANT_FOUND :
7695 print_info ("Already exists: %s" , destpath )
0 commit comments