Skip to content

Commit

Permalink
Add package_cache_async flag.
Browse files Browse the repository at this point in the history
Adds a `package_cachy_async` flag which allows users to run caching synchronously (blocking) or asynchronously from the config.

Signed-off-by: ttrently <41705925+ttrently@users.noreply.github.com>
  • Loading branch information
ttrently authored and isohedronpipeline committed Mar 6, 2024
1 parent 153bd87 commit 0d1e29c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/rez/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ def _parse_env_var(self, value):
"package_cache_during_build": Bool,
"package_cache_local": Bool,
"package_cache_same_device": Bool,
"package_cache_async": Bool,
"color_enabled": ForceOrBool,
"resolve_caching": Bool,
"cache_package_files": Bool,
Expand Down
10 changes: 7 additions & 3 deletions src/rez/package_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def remove_variant(self, variant):

return self.VARIANT_REMOVED

def add_variants_async(self, variants):
def add_variants_async(self, variants, _async=False):
"""Update the package cache by adding some or all of the given variants.
This method is called when a context is created or sourced. Variants
Expand Down Expand Up @@ -460,8 +460,12 @@ def add_variants_async(self, variants):
else:
out_target = devnull

subprocess.Popen(
[exe, "--daemon", self.path],
func = subprocess.Popen
if not _async:
func = subprocess.call

func(
args,
stdout=out_target,
stderr=out_target,
**kwargs
Expand Down
5 changes: 4 additions & 1 deletion src/rez/resolved_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1844,7 +1844,10 @@ def _update_package_cache(self):

pkgcache = self._get_package_cache()
if pkgcache:
pkgcache.add_variants_async(self.resolved_packages)
pkgcache.add_variants_async(
self.resolved_packages,
config.package_cache_async
)

@classmethod
def _init_context_tracking_payload_base(cls):
Expand Down
3 changes: 3 additions & 0 deletions src/rez/rezconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@
# Enable package caching during a package build.
package_cache_during_build = False

# Enable package caching to run asynchronously during a resolve.
package_cache_async = True

# Allow caching of local packages. You would only want to set this True for
# testing purposes.
package_cache_local = False
Expand Down

0 comments on commit 0d1e29c

Please sign in to comment.