Some stuff from old exception-based error handling approach

This commit is contained in:
Ellwood Zwovic
2017-07-09 18:59:36 -07:00
parent d4a01350fd
commit f411c68115
3 changed files with 47 additions and 28 deletions

View File

@@ -44,7 +44,13 @@ def subprocess_operator(cls: Operator, polling_interval=.01) -> Operator:
# and the pipe is needed for the subprocess_function decorator.
# TODO: Perhaps this responsibility should be handled here instead (simplifies things but looses some flexibility)
orig_invoke(self, context, event)
orig_ret = orig_invoke(self, context, event)
# HACK to allow early exits.
# Perhaps subprocess_operators should define separately named methods, to avoid confusing mixing semantics in return types
if not orig_ret.issubset({'RUNNING_MODAL'}):
log.debug('Exiting early')
return orig_ret
self.proc = Process(
*getattr(self, 'proc_args', []),
@@ -66,7 +72,7 @@ def subprocess_operator(cls: Operator, polling_interval=.01) -> Operator:
"""
Check the pipe for new messages (nonblocking). If there is a new message, call the callback
"""
self.log.debug("polling")
log.debug("polling")
try:
if self.pipe[0].poll():
resp = self.pipe[0].recv()
@@ -74,7 +80,7 @@ def subprocess_operator(cls: Operator, polling_interval=.01) -> Operator:
else:
resp = None
except EOFError:
self.log.debug("done polling")
log.debug("done polling")
return {'FINISHED'}
if resp is not None: