Skip to content

Commit

Permalink
Fixed race conditions pointed out in #3024.
Browse files Browse the repository at this point in the history
  • Loading branch information
michalgregor committed Jun 30, 2016
1 parent fb77e2c commit e9d19a2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions spyderlib/widgets/externalshell/baseshell.py
Expand Up @@ -302,22 +302,24 @@ def write_output(self):
self.buffer_lock.lock()
self.buffer.append(self.get_stdout())
self.buffer_lock.unlock()
return

if not self.write_lock.tryLock():
return

self.shell.write(self.get_stdout(), flush=True)

while True:
self.buffer_lock.lock()
messages = self.buffer
self.buffer = []
self.buffer_lock.unlock()

if not messages:
break
self.write_lock.unlock()
self.buffer_lock.unlock()
return

self.shell.write("\n".join(messages), flush=True)

self.write_lock.unlock()
self.buffer_lock.unlock()
self.shell.write("\n".join(messages), flush=True)

def send_to_process(self, qstr):
raise NotImplementedError
Expand Down

0 comments on commit e9d19a2

Please sign in to comment.