Add docstrings
This commit is contained in:
@@ -35,6 +35,9 @@ def subprocess_operator(cls: Operator, polling_interval=.01) -> Operator:
|
||||
|
||||
|
||||
def decorate_invoke(orig_invoke):
|
||||
"""
|
||||
Create pipe and modal timer, start subprocess
|
||||
"""
|
||||
def invoke(self, context, event):
|
||||
self.pipe = Pipe()
|
||||
|
||||
@@ -57,6 +60,9 @@ def subprocess_operator(cls: Operator, polling_interval=.01) -> Operator:
|
||||
return invoke
|
||||
|
||||
def poll_subprocess(self):
|
||||
"""
|
||||
Check the pipe for new messages (nonblocking). If there is a new message, call the callback
|
||||
"""
|
||||
self.log.debug("polling")
|
||||
try:
|
||||
if self.pipe[0].poll():
|
||||
@@ -75,8 +81,6 @@ def subprocess_operator(cls: Operator, polling_interval=.01) -> Operator:
|
||||
self.handle_response(resp.data) #TODO: make this a customizable callback
|
||||
# this should allow chaining of multiple subprocess in a single operator
|
||||
|
||||
return {'PASS_THROUGH'}
|
||||
|
||||
decoratify(cls, 'execute', decorate_execute)
|
||||
decoratify(cls, 'invoke', decorate_invoke)
|
||||
setattr(cls, 'poll_subprocess', poll_subprocess)
|
||||
@@ -104,6 +108,10 @@ def subprocess_function(func, *args, pipe, **kwargs):
|
||||
return wrapper
|
||||
|
||||
class SubprocessMessage:
|
||||
"""
|
||||
Container for communications between child processes and the parent process
|
||||
"""
|
||||
#TODO: currently only used for child -> parent, might need something different for parent -> child?
|
||||
def __init__(self, exception=None, data=None):
|
||||
self.exception = exception
|
||||
self.data = data
|
||||
|
Reference in New Issue
Block a user