clay
clay copied to clipboard
"Error closing session", because it's deleted in many places
Description
Golem Version: 0.23.0
OS: Linux
Description of the issue:
Introduced by #4111
TaskServer
:
def disconnect(self):
for node_id in list(self.sessions):
try:
task_session = self.sessions[node_id]
if task_session is None:
# Pending connection
continue
task_session.dropped()
del self.sessions[node_id]
except Exception as exc: # pylint: disable=broad-except
logger.error("Error closing session: %r", exc)
TaskSession
:
def dropped(self):
""" Close connection """
BasicSafeSession.dropped(self)
self.task_server.remove_session_by_node_id(self.key_id)
TaskMessagesQueueMixin
(which is used by TaskServer
):
def disconnect(self):
for node_id in list(self.sessions):
try:
task_session = self.sessions[node_id]
if task_session is None:
# Pending connection
continue
task_session.dropped()
del self.sessions[node_id]
except Exception as exc: # pylint: disable=broad-except
logger.error("Error closing session: %r", exc)
In conclusion: del self.sessions[node_id]
is called twice.
Actual result:
2020-04-10 13:28:30 INFO golem.client Pausing ...
2020-04-10 13:28:30 DEBUG golem.client Pausing p2pservice
2020-04-10 13:28:30 DEBUG golem.client Pausing task_server
2020-04-10 13:28:30 ERROR golem.task.taskserver Error closing session: KeyError('a999f986fb67344b94abdfd9b50ce53cc64ba6d4ebfab71968b5d15b7817402c132d7cdf2627c578b309260e4df74cc4be55a437d03233026d522e149ffe9915',)
2020-04-10 13:28:30 INFO golem.client Paused
Steps To Reproduce
- Have a node being a provider and computing something
- send rpc "ui.stop"
Expected behavior
No errors.
It's a bit similar to #4409 #4836