Skip to content

Commit

Permalink
try to fix OperationalError
Browse files Browse the repository at this point in the history
server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.
  • Loading branch information
devxpy committed Feb 15, 2024
1 parent 709331d commit 82b0de4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion celeryapp/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
from daras_ai_v2.settings import templates
from gooey_ui.pubsub import realtime_push
from gooey_ui.state import set_query_params
from gooeysite.bg_db_conn import db_middleware

# workaround for - https://code.djangoproject.com/ticket/24810
next_db_safe = db_middleware(next)


@app.task
Expand All @@ -40,6 +44,7 @@ def gui_runner(
error_msg = None
set_query_params(query_params or {})

@db_middleware
def save(done=False):
if done:
# clear run status
Expand Down Expand Up @@ -81,7 +86,7 @@ def save(done=False):
start_time = time()
try:
# advance the generator (to further progress of run())
yield_val = next(gen)
yield_val = next_db_safe(gen)
# increment total time taken after every iteration
run_time += time() - start_time
continue
Expand Down

0 comments on commit 82b0de4

Please sign in to comment.