mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 07:49:01 +08:00
update the scheduler of update_tidb_serverless_status_task to 1/10min (#11135)
This commit is contained in:
parent
33d6d26bbf
commit
41c6bf5fe4
@ -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",
|
||||
|
@ -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)
|
||||
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"))
|
||||
break
|
||||
except Exception as e:
|
||||
click.echo(click.style(f"Error: {e}", fg="red"))
|
||||
|
||||
end_at = time.perf_counter()
|
||||
click.echo(
|
||||
|
Loading…
x
Reference in New Issue
Block a user