Skip to content

Commit cc56713

Browse files
committed
BF: don't poll() if script process has disappeared
Also make sure that we unbind the whileRunning Idle() task by bringing that call forwards slightly
1 parent 28d3135 commit cc56713

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

psychopy/app/runner/scriptProcess.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ def whileRunningFile(self, event=None):
117117
newOutput = self._stdoutThread.getBuffer()
118118
if newOutput:
119119
sys.stdout.write(newOutput)
120-
returnVal = self.scriptProcess.poll()
121-
if returnVal is not None:
120+
if (self.scriptProcess is None
121+
or self.scriptProcess.poll() is not None):
122+
# no script or poll() sent a returncode (None means still running)
122123
self.onProcessEnded()
123124
else:
124125
time.sleep(0.1) # let's not check too often
@@ -130,13 +131,14 @@ def onProcessEnded(self, event=None):
130131
wx.EndBusyCursor()
131132
except wx._core.wxAssertionError:
132133
pass
134+
self.scriptProcess = None
135+
self.Bind(wx.EVT_IDLE, None)
136+
# handle stdout
133137
self._stdoutThread.exit = True
134138
time.sleep(0.1) # give time for the buffers to finish writing?
135139
buff = self._stdoutThread.getBuffer()
136140
self.app.runner.stdOut.write(buff)
137141
self.app.runner.stdOut.flush()
138142
self.app.runner.Show()
139143

140-
self.scriptProcess = None
141-
self.Bind(wx.EVT_IDLE, None)
142144
print("##### Experiment ended. #####\n")

0 commit comments

Comments
 (0)