You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have encountered an issue with the /reconcile endpoint in the Dashboard. The endpoint works correctly on the first request but fails to load on the second and subsequent requests.
Steps to Reproduce:
Start the Flask application.
Access the /reconcile endpoint for the first time.
Observe that the endpoint responds correctly.
Access the /reconcile endpoint again.
Observe that the endpoint fails to respond or hangs indefinitely.
from flask import Flask
import asyncio
app = Flask(__name__)
# Global variable to store the cached result
cached_result = None
@app.route("/reconcile")
def reconcile():
global cached_result # Use the global variable
# Check if we have a cached result
if cached_result is not None:
return cached_result
retval = {"gateway_ok": True}
try:
asyncio.set_event_loop(asyncio.new_event_loop())
retval["optimal"] = reporting_api.table_of_optimal_positions().Body
retval["ib"] = reporting_api.table_of_ib_positions().Body
retval["my"] = reporting_api.table_of_my_positions().Body
# Reindex the position dataframes
retval["ib"].set_index(
["instrument_code", "contract_date"], inplace=True, drop=False
)
retval["my"].set_index(
["instrument_code", "contract_date"], inplace=True, drop=False
)
except:
# IB gateway connection failed
retval["gateway_ok"] = False
if "optimal" in retval["optimal"].columns:
retval["optimal"]["optimal"] = retval["optimal"]["optimal"].astype(str)
retval = dict_of_df_to_dict(retval, orient="index")
# Cache the result
cached_result = retval
return retval
Specifically it's hanging on retval["ib"] = reporting_api.table_of_ib_positions().Body
I can't replicate the issue manually in Python, but seems to be specifically with the Flask application.
The text was updated successfully, but these errors were encountered:
I have encountered an issue with the /reconcile endpoint in the Dashboard. The endpoint works correctly on the first request but fails to load on the second and subsequent requests.
Steps to Reproduce:
Specifically it's hanging on retval["ib"] = reporting_api.table_of_ib_positions().Body
I can't replicate the issue manually in Python, but seems to be specifically with the Flask application.
The text was updated successfully, but these errors were encountered: