Skip to content

Commit

Permalink
[WIP] Ignore broken pipes
Browse files Browse the repository at this point in the history
  • Loading branch information
tueda committed Aug 21, 2015
1 parent 5a91b3b commit a34fab1
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions form/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,19 +224,27 @@ def close(self):
should call this method after use of FormLink objects.
"""
if not self._closed:
self._parentout.write(self._PROMPT)
self._parentout.flush()
os.waitpid(self._childpid, 0)
self._parentin.close()
self._parentout.close()
self._loggingin.close()

self._closed = True
self._log = None
self._childpid = None
self._parentin = None
self._parentout = None
self._loggingin = None
try:
try:
self._parentout.write(self._PROMPT)
self._parentout.flush()
except IOError as e:
# Ignore broken pipes.
if e.errno == errno.EPIPE:
pass
else:
raise
os.waitpid(self._childpid, 0)
self._parentin.close()
self._parentout.close()
self._loggingin.close()
finally:
self._closed = True
self._log = None
self._childpid = None
self._parentin = None
self._parentout = None
self._loggingin = None

def write(self, script):
"""Sends a script to FORM.
Expand Down

0 comments on commit a34fab1

Please sign in to comment.