-
Notifications
You must be signed in to change notification settings - Fork 482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new --exit-on-disconnect
flag to start lbrynet, will exit process when connection drops
#3646
base: master
Are you sure you want to change the base?
Conversation
--exit-on-disconnect
flag to start lbrynet, will exit process when connection drops
25bf9bd
to
8bd7008
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General comment about sleep_delay
and _urgent_need_reconnect
:
async def network_loop(self):
sleep_delay = 30
while self.running:
await asyncio.wait(
[asyncio.sleep(30), self._urgent_need_reconnect.wait()], return_when=asyncio.FIRST_COMPLETED #### It seems like this should be sleep(sleep_delay), or min(sleep_delay, X) not a fixed 30s.
)
if self._urgent_need_reconnect.is_set():
sleep_delay = 30
self._urgent_need_reconnect.clear() #### Should this be moved after "if not client:" so that the urgent reconnect will still be needed? When cleared here, the urgency goes away until another RPC is tried and finds the connection is not available.
if not self.is_connected:
client = await self.connect_to_fastest()
if not client:
log.warning("failed to connect to any spv servers, retrying later")
sleep_delay *= 2
sleep_delay = min(sleep_delay, 300)
continue
log.debug("get spv server features %s:%i", *client.server)
log.error("exiting on server disconnect") | ||
sys.exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should consider adding SystemExit exception handling here:
Line 281 in a334a93
except (GracefulExit, KeyboardInterrupt, asyncio.CancelledError): |
I guess the risk is that it would hang while shutting down components, but calling daemon.stop() is done in other scenarios like SIGINT, SIGTERM.
No description provided.