Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

update the scheduler of update_tidb_serverless_status_task to 1/10min (#11135)

Jyong41c6bf5fe423
diff --git a/api/extensions/ext_celery.py b/api/extensions/ext_celery.py
index 1b78e36a573..7d0f13b3917 100644
--- a/api/extensions/ext_celery.py
+++ b/api/extensions/ext_celery.py
@@ -86,7 +86,7 @@ def init_app(app: Flask) -> Celery:
},
"update_tidb_serverless_status_task": {
"task": "schedule.update_tidb_serverless_status_task.update_tidb_serverless_status_task",
- "schedule": crontab(minute="30", hour="*"),
+ "schedule": timedelta(minutes=10),
},
"clean_messages": {
"task": "schedule.clean_messages.clean_messages",
diff --git a/api/schedule/update_tidb_serverless_status_task.py b/api/schedule/update_tidb_serverless_status_task.py
index 07eca3173b3..b2d8746f9ca 100644
--- a/api/schedule/update_tidb_serverless_status_task.py
+++ b/api/schedule/update_tidb_serverless_status_task.py
@@ -12,21 +12,18 @@ from models.dataset import TidbAuthBinding
def update_tidb_serverless_status_task():
click.echo(click.style("Update tidb serverless status task.", fg="green"))
start_at = time.perf_counter()
- while True:
- try:
- # check the number of idle tidb serverless
- tidb_serverless_list = TidbAuthBinding.query.filter(
- TidbAuthBinding.active == False, TidbAuthBinding.status == "CREATING"
- ).all()
- if len(tidb_serverless_list) == 0:
- break
- # update tidb serverless status
- iterations_per_thread = 20
- update_clusters(tidb_serverless_list)
-
- except Exception as e:
- click.echo(click.style(f"Error: {e}", fg="red"))
- break
+ try:
+ # check the number of idle tidb serverless
+ tidb_serverless_list = TidbAuthBinding.query.filter(
+ TidbAuthBinding.active == False, TidbAuthBinding.status == "CREATING"
+ ).all()
+ if len(tidb_serverless_list) == 0:
+ return
+ # update tidb serverless status
+ update_clusters(tidb_serverless_list)
+
+ except Exception as e:
+ click.echo(click.style(f"Error: {e}", fg="red"))
end_at = time.perf_counter()
click.echo(