From b5e339145306f7ca1de6909db73d54458244c8d2 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Fri, 22 Sep 2017 16:44:53 -0700 Subject: [PATCH] Allow calling sip.setapi in subprocess before pyqtgraph is imported --- pyqtgraph/multiprocess/bootstrap.py | 6 ++++++ pyqtgraph/multiprocess/processes.py | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pyqtgraph/multiprocess/bootstrap.py b/pyqtgraph/multiprocess/bootstrap.py index f9cb0b0e..a8a03d41 100644 --- a/pyqtgraph/multiprocess/bootstrap.py +++ b/pyqtgraph/multiprocess/bootstrap.py @@ -22,6 +22,12 @@ if __name__ == '__main__': while len(sys.path) > 0: sys.path.pop() sys.path.extend(path) + + pyqtapis = opts.pop('pyqtapis', None) + if pyqtapis is not None: + import sip + for k,v in pyqtapis.items(): + sip.setapi(k, v) if opts.pop('pyside', False): import PySide diff --git a/pyqtgraph/multiprocess/processes.py b/pyqtgraph/multiprocess/processes.py index 7560ff70..1be7e50b 100644 --- a/pyqtgraph/multiprocess/processes.py +++ b/pyqtgraph/multiprocess/processes.py @@ -39,7 +39,7 @@ class Process(RemoteEventHandler): """ _process_count = 1 # just used for assigning colors to each process for debugging - def __init__(self, name=None, target=None, executable=None, copySysPath=True, debug=False, timeout=20, wrapStdout=None): + def __init__(self, name=None, target=None, executable=None, copySysPath=True, debug=False, timeout=20, wrapStdout=None, pyqtapis=None): """ ============== ============================================================= **Arguments:** @@ -47,7 +47,7 @@ class Process(RemoteEventHandler): from the remote process. target Optional function to call after starting remote process. By default, this is startEventLoop(), which causes the remote - process to process requests from the parent process until it + process to handle requests from the parent process until it is asked to quit. If you wish to specify a different target, it must be picklable (bound methods are not). copySysPath If True, copy the contents of sys.path to the remote process. @@ -61,6 +61,8 @@ class Process(RemoteEventHandler): for a python bug: http://bugs.python.org/issue3905 but has the side effect that child output is significantly delayed relative to the parent output. + pyqtapis Optional dictionary of PyQt API version numbers to set before + importing pyqtgraph in the remote process. ============== ============================================================= """ if target is None: @@ -130,7 +132,8 @@ class Process(RemoteEventHandler): targetStr=targetStr, path=sysPath, pyside=USE_PYSIDE, - debug=procDebug + debug=procDebug, + pyqtapis=pyqtapis, ) pickle.dump(data, self.proc.stdin) self.proc.stdin.close()