Fix a crash when pathoc connections fail

Use the new handler to tidy this up.
This commit is contained in:
Aldo Cortesi 2016-06-10 11:14:23 +12:00
parent 120b6c0b59
commit 11fb217191
2 changed files with 62 additions and 66 deletions

View File

@ -291,7 +291,6 @@ class Pathoc(tcp.TCPClient):
if self.use_http2 and not self.ssl:
raise NotImplementedError("HTTP2 without SSL is not supported.")
try:
ret = tcp.TCPClient.connect(self)
if connect_to:
self.http_connect(connect_to)
@ -329,9 +328,6 @@ class Pathoc(tcp.TCPClient):
if self.timeout:
self.settimeout(self.timeout)
except Exception:
self.close()
raise
return ret
def stop(self):
@ -511,13 +507,7 @@ def main(args): # pragma: no cover
)
trycount = 0
try:
p.connect(args.connect_to, args.showssl)
except TcpException as v:
print(str(v), file=sys.stderr)
continue
except PathocError as v:
print(str(v), file=sys.stderr)
sys.exit(1)
with p.connect(args.connect_to, args.showssl):
for spec in playlist:
if args.explain or args.memo:
spec = spec.freeze(p.settings)
@ -544,6 +534,13 @@ def main(args): # pragma: no cover
break
for i_ in p.wait(timeout=0.01, finish=True):
pass
except TcpException as v:
print(str(v), file=sys.stderr)
continue
except PathocError as v:
print(str(v), file=sys.stderr)
sys.exit(1)
except KeyboardInterrupt:
pass
if p:

View File

@ -218,7 +218,6 @@ def args_pathoc(argv, stdout=sys.stdout, stderr=sys.stderr):
print(v.marked(), file=stderr)
sys.exit(1)
args.requests = reqs
return args