Skip to content

Commit

Permalink
Forgot to catch socket errors. Also don't shadown vars.
Browse files Browse the repository at this point in the history
  • Loading branch information
ionelmc committed Jan 24, 2019
1 parent be83cc7 commit ce1fced
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/hunter/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,20 @@ def connect_manhole(pid, timeout, signal):

start = time.time()
uds_path = '/tmp/manhole-%s' % pid
manhole = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
manhole.settimeout(timeout)
conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
conn.settimeout(timeout)
while time.time() - start < timeout:
try:
manhole.connect(uds_path)
except OSError as exc:
conn.connect(uds_path)
except (OSError, socket.error) as exc:
if exc.errno not in (errno.ENOENT, errno.ECONNREFUSED):
print("Failed to connect to %r: %r" % (uds_path, exc), file=sys.stderr)
else:
break
else:
print("Failed to connect to %r: Timeout" % uds_path, file=sys.stderr)
sys.exit(5)
return manhole
return conn


def activate(sink_path, isatty, encoding, options):
Expand Down

0 comments on commit ce1fced

Please sign in to comment.