Commit c5c229b4 authored by hjk's avatar hjk
Browse files

Debugger: Delay matplot process initialization



Reduces costs in case the feature is not requested.

Change-Id: I66da6f256baaec6ef9d40bc135942551d58e83da
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 401d6676
......@@ -91,24 +91,33 @@ except:
if hasSubprocess and hasPlot:
matplotFigure = {}
matplotCount = 0
devNull = open(os.devnull)
# FIXME: That might not be the one we want.
pythonExecutable = sys.executable
matplotProc = subprocess.Popen(args=[pythonExecutable, "-i"],
bufsize=0, stdin=subprocess.PIPE, stdout=devNull, stderr=devNull)
matplotProc.stdin.write(b"import sys\n")
matplotProc.stdin.write(b"sys.ps1=''\n")
matplotProc.stdin.write(b"from matplotlib import pyplot\n")
matplotProc.stdin.write(b"import time\n")
matplotProc.stdin.write(b"pyplot.ion()\n")
matplotProc.stdin.flush()
matplotProc = None
devNull = None
def matplotInit():
global matplotProc
global devNull
if matplotProc is None:
devNull = open(os.devnull)
# FIXME: That might not be the one we want.
pythonExecutable = sys.executable
matplotProc = subprocess.Popen(args=[pythonExecutable, "-i"],
bufsize=0, stdin=subprocess.PIPE, stdout=devNull, stderr=devNull)
matplotProc.stdin.write(b"import sys\n")
matplotProc.stdin.write(b"sys.ps1=''\n")
matplotProc.stdin.write(b"from matplotlib import pyplot\n")
matplotProc.stdin.write(b"import time\n")
matplotProc.stdin.write(b"pyplot.ion()\n")
matplotProc.stdin.flush()
def matplotSend(iname, show, data):
global matplotFigure
global matplotCount
matplotInit()
def s(line):
matplotProc.stdin.write(line.encode("latin1"))
matplotProc.stdin.write(b"\n")
......@@ -136,9 +145,11 @@ if hasSubprocess and hasPlot:
matplotProc.stdin.flush()
def matplotQuit():
matplotProc.stdin.write(b"exit")
matplotProc.kill()
devNull.close()
global matplotProc
if not matplotProc is None:
matplotProc.stdin.write(b"exit")
matplotProc.kill()
devNull.close()
def arrayForms():
global hasPlot
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment