Clean up log file output and fix some bugs. Swallows spammy and useless AMP connection errors.

This commit is contained in:
Griatch 2016-09-13 23:10:51 +02:00
parent 86c970eb62
commit 76a903119c
4 changed files with 17 additions and 5 deletions

View file

@ -118,8 +118,8 @@ class CmdShutdown(COMMAND_DEFAULT_CLASS):
announcement += "%s\n" % self.args
logger.log_info('Server shutdown by %s.' % self.caller.name)
SESSIONS.announce_all(announcement)
SESSIONS.portal_shutdown()
SESSIONS.server.shutdown(mode='shutdown')
SESSIONS.portal_shutdown()
class CmdPy(COMMAND_DEFAULT_CLASS):

View file

@ -188,7 +188,6 @@ class AmpClientFactory(protocol.ReconnectingClientFactory):
reason (str): Eventual text describing why connection failed.
"""
print ("portal retrying connection"), self.maxDelay
if hasattr(self, "server_restart_mode"):
self.maxDelay = 2
else:
@ -372,6 +371,19 @@ class AMPProtocol(amp.AMP):
if hasattr(self.factory, "server_restart_mode"):
del self.factory.server_restart_mode
def connectionLost(self, reason):
"""
We swallow connection errors here. The reason is that during a
normal reload/shutdown there will almost always be cases where
either the portal or server shuts down before a message has
returned its (empty) return, triggering a connectionLost error
that is irrelevant. If a true connection error happens, the
portal will continuously try to reconnect, showing the problem
that way.
"""
pass
# Error handling
def errback(self, e, info):

View file

@ -188,7 +188,7 @@ class PortalSessionHandler(SessionHandler):
# sessions while we are looping over them.
sessionhandler._disconnect_all = True
for session in sessionhandler.values():
session.disconnect(session)
session.disconnect()
del sessionhandler._disconnect_all
# inform Server; wait until finished sending before we continue

View file

@ -657,8 +657,8 @@ class ServerSessionHandler(SessionHandler):
message (str): Message to send.
"""
for sess in self.values():
self.data_out(sess, text=message)
for session in self.values():
self.data_out(session, text=message)
def data_out(self, session, **kwargs):
"""