From 430b4e2f8965a9acf1fbb7a9646639a245e7132e Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Fri, 2 Aug 2019 10:21:41 -0700 Subject: [PATCH] Bail as soon as we know there is a port error --- examples/chat/chat.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/chat/chat.py b/examples/chat/chat.py index 0b0fd43..c9e8eea 100755 --- a/examples/chat/chat.py +++ b/examples/chat/chat.py @@ -46,8 +46,6 @@ async def run(port, destination): host.set_stream_handler(PROTOCOL_ID, stream_handler) - if not port: - raise RuntimeError("was not able to find the actual local port") print( "Run './examples/chat/chat.py -p %s -d /ip4/%s/tcp/%s/p2p/%s' on another console.\n" @@ -97,6 +95,9 @@ def main(): ) args = parser.parse_args() + if not args.port: + raise RuntimeError("was not able to determine a local port") + loop = asyncio.get_event_loop() try: asyncio.ensure_future(run(args.port, args.destination))