2012-06-18 19:20:35 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import initExample ## Add path to library (just for examples; you do not need this)
|
|
|
|
import numpy as np
|
|
|
|
import pyqtgraph.multiprocess as mp
|
2012-06-22 02:00:04 +00:00
|
|
|
import pyqtgraph as pg
|
2012-06-18 19:20:35 +00:00
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-12 19:35:32 +00:00
|
|
|
print("\n=================\nStart Process")
|
2012-06-18 19:20:35 +00:00
|
|
|
proc = mp.Process()
|
|
|
|
import os
|
2013-01-12 19:35:32 +00:00
|
|
|
print("parent:", os.getpid(), "child:", proc.proc.pid)
|
|
|
|
print("started")
|
2012-06-18 19:20:35 +00:00
|
|
|
rnp = proc._import('numpy')
|
|
|
|
arr = rnp.array([1,2,3,4])
|
2013-01-12 19:35:32 +00:00
|
|
|
print(repr(arr))
|
|
|
|
print(str(arr))
|
|
|
|
print("return value:", repr(arr.mean(_returnType='value')))
|
|
|
|
print( "return proxy:", repr(arr.mean(_returnType='proxy')))
|
|
|
|
print( "return auto: ", repr(arr.mean(_returnType='auto')))
|
2012-06-18 19:20:35 +00:00
|
|
|
proc.join()
|
2013-01-12 19:35:32 +00:00
|
|
|
print( "process finished")
|
2012-06-18 19:20:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-12 19:35:32 +00:00
|
|
|
print( "\n=================\nStart ForkedProcess")
|
2012-06-18 19:20:35 +00:00
|
|
|
proc = mp.ForkedProcess()
|
|
|
|
rnp = proc._import('numpy')
|
|
|
|
arr = rnp.array([1,2,3,4])
|
2013-01-12 19:35:32 +00:00
|
|
|
print( repr(arr))
|
|
|
|
print( str(arr))
|
|
|
|
print( repr(arr.mean()))
|
2012-06-18 19:20:35 +00:00
|
|
|
proc.join()
|
2013-01-12 19:35:32 +00:00
|
|
|
print( "process finished")
|
2012-06-18 19:20:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import pyqtgraph as pg
|
|
|
|
from pyqtgraph.Qt import QtCore, QtGui
|
2021-01-27 18:42:38 +00:00
|
|
|
app = pg.QtGui.QApplication([])
|
2012-06-18 19:20:35 +00:00
|
|
|
|
2013-01-12 19:35:32 +00:00
|
|
|
print( "\n=================\nStart QtProcess")
|
2013-01-10 21:10:27 +00:00
|
|
|
import sys
|
|
|
|
if (sys.flags.interactive != 1):
|
2013-01-12 19:35:32 +00:00
|
|
|
print( " (not interactive; remote process will exit immediately.)")
|
2012-06-18 19:20:35 +00:00
|
|
|
proc = mp.QtProcess()
|
|
|
|
d1 = proc.transfer(np.random.normal(size=1000))
|
|
|
|
d2 = proc.transfer(np.random.normal(size=1000))
|
|
|
|
rpg = proc._import('pyqtgraph')
|
|
|
|
plt = rpg.plot(d1+d2)
|
|
|
|
|
|
|
|
|
|
|
|
## Start Qt event loop unless running in interactive mode or using pyside.
|
|
|
|
#import sys
|
|
|
|
#if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
|
|
|
|
#QtGui.QApplication.instance().exec_()
|