Skip to content

Commit

Permalink
Fixes async loop errors
Browse files Browse the repository at this point in the history
  • Loading branch information
froggleston committed Dec 5, 2024
1 parent 60a8701 commit 6ad4cf5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
3 changes: 1 addition & 2 deletions ftui/screens/dashboard_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,7 @@ def update_cumulative_profit_plot(self, bot_list=None):

worker = get_current_worker()
if not worker.is_cancelled:
self.app.call_from_thread(chart_container.refresh)
chart_container.loading = False
self.app.call_from_thread(chart_container.set_loading, False)

@on(SelectionList.SelectedChanged)
def update_cum_plot_from_list(self) -> None:
Expand Down
17 changes: 15 additions & 2 deletions ftui/screens/main_bot_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ def refresh_chart_button_pressed(self) -> None:
bot_id = self._get_bot_id_from_client_list()

chart_container = self.query_one("#bot-chart")
#worker = get_current_worker()
#if not worker.is_cancelled:
# self.app.call_from_thread(chart_container.loading, True)
chart_container.loading = True
self.update_chart(bot_id, pair=self.prev_chart_pair, refresh=True)

Expand Down Expand Up @@ -564,7 +567,10 @@ def update_chart(self, bot_id, pair=None, refresh=False):

ckey = f"{pair}_{cl.get_client_config()['timeframe']}"
if ckey not in self.chart_data or refresh:
chart_container.loading = True
worker = get_current_worker()
if not worker.is_cancelled:
self.app.call_from_thread(chart_container.set_loading, True)

data = cl.get_pair_dataframe(pair, limit=min(max(round(cw / 2), 50), 200))
if data is not None and not data.empty:
self.chart_data[ckey] = data[["date", "Open", "Close", "High", "Low"]]
Expand All @@ -588,7 +594,10 @@ def update_chart(self, bot_id, pair=None, refresh=False):
data["date"] > last_date
]
if not new_data.empty:
chart_container.loading = True
worker = get_current_worker()
if not worker.is_cancelled:
self.app.call_from_thread(chart_container.set_loading, True)

self.chart_data[ckey] = pd.concat([self.chart_data[ckey], new_data])
self.chart_data[ckey].drop(self.chart_data[ckey].head(1).index, inplace=True)

Expand Down Expand Up @@ -735,6 +744,10 @@ def _render_chart(self, ftuic, pair, data):
title=f"Error: No data available for {pair}",
severity="warning",
)

#worker = get_current_worker()
#if not worker.is_cancelled:
# self.app.call_from_thread(chart_container.loading, False)
chart_container.loading = False

# bot performance tab
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ python-rapidjson
PyYaml
textual==0.85.0
plotext==5.2.8
textual_plotext
textual_plotext==0.2.1
freqtrade-client

0 comments on commit 6ad4cf5

Please sign in to comment.