Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged queue timeout and result timeout #406

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/saturn_engine/worker/executors/arq/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
QUEUE_TIMEOUT = 600
RESULT_TIMEOUT = 1200
TIMEOUT = 1200
EXECUTE_FUNC_NAME = "remote_execute"

healthcheck_interval = 10
Expand Down
10 changes: 4 additions & 6 deletions src/saturn_engine/worker/executors/arq/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

from .. import Executor
from . import EXECUTE_FUNC_NAME
from . import QUEUE_TIMEOUT
from . import RESULT_TIMEOUT
from . import TIMEOUT
from . import executor_healthcheck_key
from . import healthcheck_interval
from . import worker_healthcheck_key
Expand All @@ -41,8 +40,7 @@ class Options:
redis_url: str
concurrency: int
queue_name: str = "arq:queue"
queue_timeout: int = QUEUE_TIMEOUT
result_timeout: int = RESULT_TIMEOUT
timeout: int = TIMEOUT

def __init__(self, options: Options, services: Services) -> None:
self.logger = getLogger(__name__, self)
Expand Down Expand Up @@ -105,7 +103,7 @@ async def process_message(self, message: ExecutableMessage) -> PipelineResults:
job = await (await self.redis_queue).enqueue_job(
EXECUTE_FUNC_NAME,
message.message.as_remote(),
_expires=options.queue_timeout,
_expires=options.timeout + 5,
_queue_name=options.queue_name,
)
except (OSError, RedisError):
Expand All @@ -114,7 +112,7 @@ async def process_message(self, message: ExecutableMessage) -> PipelineResults:

tasks = TasksGroup(name=f"saturn.arq.process_message({message.id})")
result_task: asyncio.Task[PipelineResults] = tasks.create_task(
job.result(timeout=self.options.result_timeout)
job.result(timeout=self.options.timeout)
)
healthcheck_task = tasks.create_task(self.monitor_job_healthcheck(job))
async with tasks:
Expand Down
Loading