Skip to content

Commit

Permalink
feat: add task queue huey (#409)
Browse files Browse the repository at this point in the history
  • Loading branch information
vncsna authored Sep 29, 2023
1 parent 73ce44a commit 14ab22b
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 352 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ fabric.properties
.idea/caches/build_file_checksums.ser

*sqlite3
*sqlite3-shm
*sqlite3-wal

.vscode/
.DS_Store
Expand Down
8 changes: 8 additions & 0 deletions basedosdados_api/api/v1/tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
from huey import crontab
from huey.contrib.djhuey import periodic_task


@periodic_task(crontab(minute="*/10"))
def every_ten_mins():
print("It's been ten minutes!")
15 changes: 15 additions & 0 deletions basedosdados_api/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"health_check",
"health_check.db",
"ordered_model",
"huey.contrib.djhuey",
"basedosdados_api.account",
"basedosdados_api.core",
"basedosdados_api.api.v1",
Expand Down Expand Up @@ -405,3 +406,17 @@
CSRF_COOKIE_HTTPONLY = False

DATA_UPLOAD_MAX_NUMBER_FIELDS = 20000

HUEY = {
"name": "api.queue",
"huey_class": "huey.SqliteHuey",
"results": True,
"immediate": False,
"filename": path.join(BASE_DIR, "queue.sqlite3"),
"consumer": {
"workers": 2,
"worker_type": "thread",
"check_worker_health": True,
"periodic": True,
},
}
Loading

0 comments on commit 14ab22b

Please sign in to comment.