Skip to content

Commit

Permalink
Set a 5sec timeout on mlapi requests otherwise they can hang indefini…
Browse files Browse the repository at this point in the history
…tely. Maybe Fixes #437
  • Loading branch information
Isaac Connor committed Nov 20, 2024
1 parent d547559 commit 95d1b79
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions hook/zm_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def remote_detect(stream=None, options=None, api=None, args=None):
'username': g.config['ml_user'],
'password': g.config['ml_password'],
}),
headers={'content-type': 'application/json'})
headers={'content-type': 'application/json'},
timeout=5)
data = r.json()
access_token = data.get('access_token')
if not access_token:
Expand Down Expand Up @@ -138,8 +139,8 @@ def remote_detect(stream=None, options=None, api=None, args=None):
'stream': stream,
'stream_options':options,
'ml_overrides':ml_overrides
}
)
},
timeout=5)
r.raise_for_status()
except Exception as e:
g.logger.Error('Error during remote post: {}'.format(str(e)))
Expand Down

0 comments on commit 95d1b79

Please sign in to comment.