Merge pull request #580 from campagnola/multiprocess-pyqt-setapi

Allow calling sip.setapi in subprocess before pyqtgraph is imported
This commit is contained in:
Luke Campagnola 2017-10-03 13:15:18 -07:00 committed by GitHub
commit 45999e0f2b
2 changed files with 12 additions and 3 deletions

View File

@ -22,6 +22,12 @@ if __name__ == '__main__':
while len(sys.path) > 0: while len(sys.path) > 0:
sys.path.pop() sys.path.pop()
sys.path.extend(path) 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): if opts.pop('pyside', False):
import PySide import PySide

View File

@ -39,7 +39,7 @@ class Process(RemoteEventHandler):
""" """
_process_count = 1 # just used for assigning colors to each process for debugging _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:** **Arguments:**
@ -47,7 +47,7 @@ class Process(RemoteEventHandler):
from the remote process. from the remote process.
target Optional function to call after starting remote process. target Optional function to call after starting remote process.
By default, this is startEventLoop(), which causes the remote 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, is asked to quit. If you wish to specify a different target,
it must be picklable (bound methods are not). it must be picklable (bound methods are not).
copySysPath If True, copy the contents of sys.path to the remote process. 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 for a python bug: http://bugs.python.org/issue3905
but has the side effect that child output is significantly but has the side effect that child output is significantly
delayed relative to the parent output. 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: if target is None:
@ -130,7 +132,8 @@ class Process(RemoteEventHandler):
targetStr=targetStr, targetStr=targetStr,
path=sysPath, path=sysPath,
pyside=USE_PYSIDE, pyside=USE_PYSIDE,
debug=procDebug debug=procDebug,
pyqtapis=pyqtapis,
) )
pickle.dump(data, self.proc.stdin) pickle.dump(data, self.proc.stdin)
self.proc.stdin.close() self.proc.stdin.close()