Skip to content

Commit

Permalink
A different way of terminating gnuplot. Possibly more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
boatbod committed Mar 25, 2018
1 parent 118e793 commit 8bdb531
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions op25/gr-op25_repeater/apps/gr_gnuplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,18 @@ def attach_gp(self):

def kill(self):
try:
self.gp.communicate("quit\n")
self.gp.stdin.close() # closing pipe should cause subprocess to exit
except IOError:
pass
pass
sleep_count = 0
while True: # wait politely, but only for so long
self.gp.poll()
if self.gp.returncode is not None:
break
time.sleep(0.1)
sleep_count += 1
if (sleep_count % 5) == 0:
self.gp.kill()

def set_interval(self, v):
self.plot_interval = v
Expand Down Expand Up @@ -193,7 +202,10 @@ def plot(self, buf, bufsz, mode='eye'):
dat = '%splot %s\n%s' % (h, ','.join(plots), s)
self.gp.poll()
if self.gp.returncode is None: # make sure gnuplot is still running
self.gp.stdin.write(dat)
try:
self.gp.stdin.write(dat)
except (IOError, ValueError):
pass
if filename:
self.filename = filename
return consumed
Expand Down

0 comments on commit 8bdb531

Please sign in to comment.