Add docstrings

This commit is contained in:
gandalf3
2017-07-09 14:49:34 -07:00
parent 8cc606b263
commit 32f0d9fdb6

View File

@@ -35,6 +35,9 @@ def subprocess_operator(cls: Operator, polling_interval=.01) -> Operator:
def decorate_invoke(orig_invoke): def decorate_invoke(orig_invoke):
"""
Create pipe and modal timer, start subprocess
"""
def invoke(self, context, event): def invoke(self, context, event):
self.pipe = Pipe() self.pipe = Pipe()
@@ -57,6 +60,9 @@ def subprocess_operator(cls: Operator, polling_interval=.01) -> Operator:
return invoke return invoke
def poll_subprocess(self): def poll_subprocess(self):
"""
Check the pipe for new messages (nonblocking). If there is a new message, call the callback
"""
self.log.debug("polling") self.log.debug("polling")
try: try:
if self.pipe[0].poll(): 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 self.handle_response(resp.data) #TODO: make this a customizable callback
# this should allow chaining of multiple subprocess in a single operator # this should allow chaining of multiple subprocess in a single operator
return {'PASS_THROUGH'}
decoratify(cls, 'execute', decorate_execute) decoratify(cls, 'execute', decorate_execute)
decoratify(cls, 'invoke', decorate_invoke) decoratify(cls, 'invoke', decorate_invoke)
setattr(cls, 'poll_subprocess', poll_subprocess) setattr(cls, 'poll_subprocess', poll_subprocess)
@@ -104,6 +108,10 @@ def subprocess_function(func, *args, pipe, **kwargs):
return wrapper return wrapper
class SubprocessMessage: 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): def __init__(self, exception=None, data=None):
self.exception = exception self.exception = exception
self.data = data self.data = data