aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéo de la Hogue2024-04-23 18:23:27 +0200
committerThéo de la Hogue2024-04-23 18:23:27 +0200
commit61ff3086313b5e6c321adb14969938b429549260 (patch)
tree6cf0ec992449e32351a907361d4700088483d6ae /src
parentb7ff8a91f6748f7ec8ada7d65eba275aca24b38b (diff)
downloadargaze-61ff3086313b5e6c321adb14969938b429549260.zip
argaze-61ff3086313b5e6c321adb14969938b429549260.tar.gz
argaze-61ff3086313b5e6c321adb14969938b429549260.tar.bz2
argaze-61ff3086313b5e6c321adb14969938b429549260.tar.xz
Removing pipe properly at the end.
Diffstat (limited to 'src')
-rw-r--r--src/argaze/__main__.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/argaze/__main__.py b/src/argaze/__main__.py
index 091b660..b94e5ec 100644
--- a/src/argaze/__main__.py
+++ b/src/argaze/__main__.py
@@ -22,6 +22,7 @@ import logging
import json
import contextlib
import os
+import stat
from . import load
from .ArFeatures import ArCamera, ArContext, PostProcessingContext, LiveProcessingContext
@@ -45,9 +46,10 @@ logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG if
# Manage pipe communication
if args.pipe_path is not None:
+ # Create FIFO
if not os.path.exists(args.pipe_path):
- os.mkfifo(args.pipe_path)
+ os.mkfifo(args.pipe_path)
# Open the fifo in non-blocking mode or it will stalls until someone opens it for writting
pipe_file = os.open(args.pipe_path, os.O_RDONLY | os.O_NONBLOCK)
@@ -91,19 +93,19 @@ with load(args.context_file) as context:
# Read message from pipe if required
if args.pipe_path is not None:
- message = pipe.read().rstrip('\n')
+ try:
- if message:
+ message = pipe.read().rstrip('\n')
- logging.info('%s: %s', args.pipe_path, message)
+ if message:
- try:
+ logging.info('%s pipe received: %s', args.pipe_path, message)
exec(message)
- except Exception as e:
+ except Exception as e:
- logging.error('%s', e)
+ logging.error('%s', e)
# Window mode on
if not args.no_window:
@@ -153,3 +155,13 @@ with load(args.context_file) as context:
# Stop frame display
cv2.destroyAllWindows()
+
+ # Manage pipe communication
+ if args.pipe_path is not None:
+
+ # Remove pipe
+ if os.path.exists(args.pipe_path):
+
+ os.remove(args.pipe_path)
+
+ logging.info('%s pipe closed', args.pipe_path)