Skip to content

Commit 5285c91

Browse files
author
Diego Nadares
committed
Add try/catch in remove_sid
When a user did not create faraday's database and run a faraday-manage command triggers an operational error.
1 parent 70c3cf1 commit 5285c91

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

faraday/server/websockets/dispatcher.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
# Related third party imports
1010
import itsdangerous
11+
import sqlalchemy
1112
from flask import current_app, request
1213

1314
from faraday.server.api.modules.websocket_auth import decode_agent_websocket_token
@@ -48,7 +49,11 @@ def update_executors(agent, executors):
4849

4950

5051
def remove_sid():
51-
agents = Agent.query.filter(Agent.sid!=None).all() # noqa E711
52+
try:
53+
agents = Agent.query.filter(Agent.sid!=None).all() # noqa E711
54+
except sqlalchemy.exc.OperationalError as error:
55+
logger.warning("Could not update agents table. %s", error)
56+
return
5257
logger.debug(f"Found {len(agents)} agents connected")
5358
for agent in agents:
5459
agent.sid = None

0 commit comments

Comments
 (0)