aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2024-06-25 17:44:52 +0200
committerThéo de la Hogue2024-06-25 17:44:52 +0200
commit886fe82d67798522f4d5d4677fce17c25d822ac4 (patch)
treece74e9666c2bcab84e577f8095110940d1c5d45f
parenta9f5d765182f8851b0dab6768aafb52809a58503 (diff)
downloadargaze-886fe82d67798522f4d5d4677fce17c25d822ac4.zip
argaze-886fe82d67798522f4d5d4677fce17c25d822ac4.tar.gz
argaze-886fe82d67798522f4d5d4677fce17c25d822ac4.tar.bz2
argaze-886fe82d67798522f4d5d4677fce17c25d822ac4.tar.xz
Adding a wait parameter to PipelineStepImage wrapper in order to not raise an exception when a sharedObject is busy. Using this option into __main__ script.
-rw-r--r--src/argaze/DataFeatures.py23
-rw-r--r--src/argaze/__main__.py8
2 files changed, 22 insertions, 9 deletions
diff --git a/src/argaze/DataFeatures.py b/src/argaze/DataFeatures.py
index fa9b52e..32dd0e1 100644
--- a/src/argaze/DataFeatures.py
+++ b/src/argaze/DataFeatures.py
@@ -940,16 +940,29 @@ def PipelineStepImage(method):
"""Define a decorator use into PipelineStepObject class to wrap pipeline step image method."""
@wraps(method)
- def wrapper(self, **kwargs) -> numpy.array:
- """Wrap pipeline step image method."""
+ def wrapper(self, wait: bool = True, **kwargs) -> numpy.array:
+ """Wrap pipeline step image method.
+
+ Parameters:
+ wait: for SharedObject, wait until the object is available else throw a SharedObjectBusy exception.
+ """
# Check shared object instance
if issubclass(type(self), SharedObject):
- # Busy shared object can't return image
- if self.busy():
+ # Wait until the shared object is available if required
+ if wait:
+
+ while self.busy():
+
+ time.sleep(1e-6)
+
+ # Otherwise, busy shared object can't return image
+ else:
+
+ if self.busy():
- raise SharedObjectBusy(f'Can\'t return image because {self.name} is busy.')
+ raise SharedObjectBusy(f'Can\'t return image because {self.name} is busy.')
if kwargs:
diff --git a/src/argaze/__main__.py b/src/argaze/__main__.py
index 2647198..cb8bd01 100644
--- a/src/argaze/__main__.py
+++ b/src/argaze/__main__.py
@@ -154,8 +154,8 @@ def load_context(args):
try:
- # Display context
- display(context.name, context.image(draw_pipeline=draw_pipeline), 0.75, draw_help=draw_help)
+ # Display context if the pipeline is available
+ display(context.name, context.image(wait = False, draw_pipeline=draw_pipeline), 0.75, draw_help=draw_help)
except SharedObjectBusy:
@@ -168,8 +168,8 @@ def load_context(args):
try:
- # Display scene's frame
- display(scene_frame.name, scene_frame.image(), 0.5)
+ # Display scene's frame if available
+ display(scene_frame.name, scene_frame.image(wait = False), 0.5)
except SharedObjectBusy: