Skip to content

Commit

Permalink
Fix outside context calls when testing
Browse files Browse the repository at this point in the history
  • Loading branch information
langdal committed Apr 26, 2023
1 parent d1e77c1 commit 4d825b7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
10 changes: 7 additions & 3 deletions optimizerapi/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ def run(body) -> dict:
dict
a JSON encodable dictionary representation of the result.
"""
if 'waitress.client_disconnected' in connexion.request.environ:
disconnect_check = connexion.request.environ['waitress.client_disconnected']
else:
try:
if 'waitress.client_disconnected' in connexion.request.environ:
disconnect_check = connexion.request.environ['waitress.client_disconnected']
else:
def disconnect_check():
return False
except RuntimeError:
def disconnect_check():
return False
print(disconnect_check())
Expand Down
4 changes: 2 additions & 2 deletions optimizerapi/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# Initialize crypto
get_crypto()
app = connexion.FlaskApp(
__name__, port=9090, specification_dir="./openapi/")
__name__, specification_dir="./openapi/")
app.add_api("specification.yml", strict_validation=True,
validate_responses=True)

Expand Down Expand Up @@ -53,6 +53,6 @@
print("CORS: disabled")

if development:
app.run()
app.run(port=9090)
else:
serve(app, listen="*:9090", channel_request_lookahead=1)
2 changes: 1 addition & 1 deletion requirements-freeze.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ itsdangerous==2.1.2
Jinja2==3.1.2
joblib==1.2.0
json-tricks==3.15.5
jsonschema==4.17.3
jsonschema==4.15.0
kiwisolver==1.4.4
MarkupSafe==2.1.2
matplotlib==3.5.3
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Flask==2.2.3
Flask-Cors==3.0.10
ProcessOptimizer[browniebee]==0.8.0
json-tricks==3.15.5
jsonschema==4.15.0
cryptography==3.4.7
waitress==2.1.2
rq==1.10.0

0 comments on commit 4d825b7

Please sign in to comment.