mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-30 10:53:02 +01:00
Add new operation Scheduled Job to Operation enum of ProcessLock
This commit is contained in:
parent
c28d7d3414
commit
fcf878e1f3
3 changed files with 22 additions and 2 deletions
|
@ -324,7 +324,7 @@ def update_content_index():
|
||||||
@schedule.repeat(schedule.every(22).to(25).hours)
|
@schedule.repeat(schedule.every(22).to(25).hours)
|
||||||
def update_content_index_regularly():
|
def update_content_index_regularly():
|
||||||
ProcessLockAdapters.run_with_lock(
|
ProcessLockAdapters.run_with_lock(
|
||||||
update_content_index, ProcessLock.Operation.UPDATE_EMBEDDINGS, max_duration_in_seconds=60 * 60 * 2
|
update_content_index, ProcessLock.Operation.INDEX_CONTENT, max_duration_in_seconds=60 * 60 * 2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
19
src/khoj/database/migrations/0036_alter_processlock_name.py
Normal file
19
src/khoj/database/migrations/0036_alter_processlock_name.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 4.2.10 on 2024-04-16 18:39
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("database", "0035_processlock"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="processlock",
|
||||||
|
name="name",
|
||||||
|
field=models.CharField(
|
||||||
|
choices=[("index_content", "Index Content"), ("scheduled_job", "Scheduled Job")], max_length=200
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -109,7 +109,8 @@ class Agent(BaseModel):
|
||||||
|
|
||||||
class ProcessLock(BaseModel):
|
class ProcessLock(BaseModel):
|
||||||
class Operation(models.TextChoices):
|
class Operation(models.TextChoices):
|
||||||
UPDATE_EMBEDDINGS = "update_embeddings"
|
INDEX_CONTENT = "index_content"
|
||||||
|
SCHEDULED_JOB = "scheduled_job"
|
||||||
|
|
||||||
# We need to make sure that some operations are thread-safe. To do so, add locks for potentially shared operations.
|
# We need to make sure that some operations are thread-safe. To do so, add locks for potentially shared operations.
|
||||||
# For example, we need to make sure that only one process is updating the embeddings at a time.
|
# For example, we need to make sure that only one process is updating the embeddings at a time.
|
||||||
|
|
Loading…
Reference in a new issue