Skip to content

Commit

Permalink
BF: don't poll() if script process has disappeared
Browse files Browse the repository at this point in the history
Also make sure that we unbind the whileRunning Idle() task by bringing
that call forwards slightly
  • Loading branch information
peircej committed Sep 24, 2020
1 parent 28d3135 commit cc56713
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions psychopy/app/runner/scriptProcess.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ def whileRunningFile(self, event=None):
newOutput = self._stdoutThread.getBuffer()
if newOutput:
sys.stdout.write(newOutput)
returnVal = self.scriptProcess.poll()
if returnVal is not None:
if (self.scriptProcess is None
or self.scriptProcess.poll() is not None):
# no script or poll() sent a returncode (None means still running)
self.onProcessEnded()
else:
time.sleep(0.1) # let's not check too often
Expand All @@ -130,13 +131,14 @@ def onProcessEnded(self, event=None):
wx.EndBusyCursor()
except wx._core.wxAssertionError:
pass
self.scriptProcess = None
self.Bind(wx.EVT_IDLE, None)
# handle stdout
self._stdoutThread.exit = True
time.sleep(0.1) # give time for the buffers to finish writing?
buff = self._stdoutThread.getBuffer()
self.app.runner.stdOut.write(buff)
self.app.runner.stdOut.flush()
self.app.runner.Show()

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

0 comments on commit cc56713

Please sign in to comment.