Put a try/except around socket.shutdown
This commit is contained in:
parent
97d1397f2c
commit
c181f8df82
@ -514,14 +514,19 @@ class ServerManager(util.LoggedClass):
|
|||||||
for session in self.sessions:
|
for session in self.sessions:
|
||||||
if session.is_closing():
|
if session.is_closing():
|
||||||
if session.stop <= shutdown_cutoff and session.socket:
|
if session.stop <= shutdown_cutoff and session.socket:
|
||||||
# Should trigger a call to connection_lost very soon
|
try:
|
||||||
session.socket.shutdown(socket.SHUT_RDWR)
|
# Force shut down - a call to connection_lost
|
||||||
|
# should come soon after
|
||||||
|
session.socket.shutdown(socket.SHUT_RDWR)
|
||||||
|
except socket.error:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
if session.last_recv < stale_cutoff:
|
if session.last_recv < stale_cutoff:
|
||||||
self.close_session(session)
|
self.close_session(session)
|
||||||
stale.append(session.id_)
|
stale.append(session.id_)
|
||||||
if stale:
|
if stale:
|
||||||
self.logger.info('closing stale connections {}'.format(stale))
|
self.logger.info('closing stale connections {}'.format(stale))
|
||||||
|
|
||||||
# Clear out empty groups
|
# Clear out empty groups
|
||||||
for key in [k for k, v in self.groups.items() if not v]:
|
for key in [k for k, v in self.groups.items() if not v]:
|
||||||
del self.groups[key]
|
del self.groups[key]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user