Skip to content
Snippets Groups Projects
Commit 07b289e2 authored by Christoph Schmidt's avatar Christoph Schmidt
Browse files

Updated to v0.1.0. Child Process functions can be connected without triggering...

Updated to v0.1.0. Child Process functions can be connected without triggering a signal when finished. Emit function bug removed
parent a5645cb0
Branches
No related tags found
No related merge requests found
...@@ -104,9 +104,7 @@ class CProcessControl(CBase, QObject): ...@@ -104,9 +104,7 @@ class CProcessControl(CBase, QObject):
self.logger.warning(f"Error cannot handle log record: {e}") self.logger.warning(f"Error cannot handle log record: {e}")
elif isinstance(res, cmp.CResultRecord): elif isinstance(res, cmp.CResultRecord):
try: try:
if isinstance(res, Signal):
res.emit_signal(self._signal_class) res.emit_signal(self._signal_class)
self._internal_logger.debug(f"Emitted {res} in {self._signal_class.__class__.__name__}.")
except Exception as e: except Exception as e:
self._internal_logger.error(f"Error while emitting {res} in {self.__class__.__name__}: {e}") self._internal_logger.error(f"Error while emitting {res} in {self.__class__.__name__}: {e}")
else: else:
......
import logging
from inspect import Signature, Parameter from inspect import Signature, Parameter
from cmp import CProcessControl as CProcessControl from cmp import CProcessControl as CProcessControl
...@@ -12,7 +13,16 @@ class CResultRecord: ...@@ -12,7 +13,16 @@ class CResultRecord:
def emit_signal(self, class_object: CProcessControl): def emit_signal(self, class_object: CProcessControl):
if hasattr(class_object, '_internal_logger'): if hasattr(class_object, '_internal_logger'):
class_object._internal_logger.info(f"Function {self.function_name} returned {self.result}. " logger: logging.Logger = class_object._internal_logger
else:
logger = logging.getLogger(f"{__name__} - fallback")
if self.signal_name is None:
logger.info(f"Function {self.function_name} returned {self.result}. "
f"No signal to emit.")
return
if hasattr(class_object, '_internal_logger'):
logger.info(f"Function {self.function_name} returned {self.result}. "
f"Emitting {self} in {class_object.__class__.__name__}.") f"Emitting {self} in {class_object.__class__.__name__}.")
emitter = getattr(class_object, self.signal_name).emit emitter = getattr(class_object, self.signal_name).emit
if isinstance(self.result, tuple): if isinstance(self.result, tuple):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment