-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fixed: Queued jobs are not considered in deferring logic #7907
Changes from 10 commits
bc920a8
683420a
7d095f4
e7fc367
e272452
79d2c87
566b908
0ac46f8
7ac72dd
d1cb317
29bbb44
74393e6
43bbc97
8ed8c49
3bbc2c9
98a00b4
0536e0d
fda8d89
ed0cc01
9a35fa9
c082802
9e7f6ae
57616e9
98fa00b
c2de3e3
d5a57cf
fbff394
bf054ce
89a8b6c
b332d9c
6af94a7
c7955ca
8a86065
8f43503
959d340
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,16 +1,29 @@ | ||||||||||||||||||||||||||||||||||||||||||||
# Copyright (C) 2018-2022 Intel Corporation | ||||||||||||||||||||||||||||||||||||||||||||
# Copyright (C) 2022-2023 CVAT.ai Corporation | ||||||||||||||||||||||||||||||||||||||||||||
# Copyright (C) 2022-2024 CVAT.ai Corporation | ||||||||||||||||||||||||||||||||||||||||||||
# | ||||||||||||||||||||||||||||||||||||||||||||
# SPDX-License-Identifier: MIT | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
import os | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
import signal | ||||||||||||||||||||||||||||||||||||||||||||
from rq import Worker | ||||||||||||||||||||||||||||||||||||||||||||
from rq.worker import StopRequested | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
import cvat.utils.remote_debugger as debug | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
class CVATWorker(Worker): | ||||||||||||||||||||||||||||||||||||||||||||
def handle_job_failure(self, job, queue, **kwargs): | ||||||||||||||||||||||||||||||||||||||||||||
# pylint: disable=access-member-before-definition | ||||||||||||||||||||||||||||||||||||||||||||
if self._stopped_job_id == job.id: | ||||||||||||||||||||||||||||||||||||||||||||
self._stopped_job_id = None | ||||||||||||||||||||||||||||||||||||||||||||
self.set_current_job_id(None) | ||||||||||||||||||||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||||||||||||||||||||
# the job was stopped intentionally, we do not need update its status or put it into failed registry | ||||||||||||||||||||||||||||||||||||||||||||
# in our case the job is immediately removed after stop request | ||||||||||||||||||||||||||||||||||||||||||||
super().handle_job_failure(job, queue, **kwargs) | ||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure clarity by adding a comment explaining the check for + # Check if the job was stopped intentionally and handle accordingly Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
DefaultWorker = Worker | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
DefaultWorker = CVATWorker | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
class BaseDeathPenalty: | ||||||||||||||||||||||||||||||||||||||||||||
|
@@ -24,7 +37,7 @@ def __exit__(self, exc_type, exc_value, traceback): | |||||||||||||||||||||||||||||||||||||||||||
pass | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
class SimpleWorker(Worker): | ||||||||||||||||||||||||||||||||||||||||||||
class SimpleWorker(CVATWorker): | ||||||||||||||||||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||||||||||||||||||
Allows to work with at most 1 worker thread. Useful for debugging. | ||||||||||||||||||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||||||||||||||||||
|
@@ -46,6 +59,22 @@ def execute_job(self, *args, **kwargs): | |||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
return self.perform_job(*args, **kwargs) | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
def kill_horse(self, sig: signal.Signals = signal.SIGTERM): | ||||||||||||||||||||||||||||||||||||||||||||
# Send SIGTERM instead of default SIGKILL in debug mode as SIGKILL can't be handled | ||||||||||||||||||||||||||||||||||||||||||||
# to prevent killing debug process (rq code handles SIGTERM properly) | ||||||||||||||||||||||||||||||||||||||||||||
super().kill_horse(sig) | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
def handle_exception(self, *args, **kwargs): | ||||||||||||||||||||||||||||||||||||||||||||
# on production it sends SIGKILL to work horse process | ||||||||||||||||||||||||||||||||||||||||||||
# but for development we overrided it and it sends SIGTERM to the process | ||||||||||||||||||||||||||||||||||||||||||||
# we need to prevent exception handling as the process killed intentilnally | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
# moreover default code saves meta with exception | ||||||||||||||||||||||||||||||||||||||||||||
# and rewrites request datetime in meta with old value, as new job with the same ID may aldeady been created in a new process | ||||||||||||||||||||||||||||||||||||||||||||
is_stopped_export_job = isinstance(args[2], (StopRequested, SystemExit)) | ||||||||||||||||||||||||||||||||||||||||||||
if not is_stopped_export_job: | ||||||||||||||||||||||||||||||||||||||||||||
super().handle_exception(*args, **kwargs) | ||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clarify the exception handling logic with a detailed comment. + # Check if the exception is due to a stop request or system exit and handle accordingly Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
if debug.is_debugging_enabled(): | ||||||||||||||||||||||||||||||||||||||||||||
class RemoteDebugWorker(SimpleWorker): | ||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added these settings previously, but now it looks like they bring more problems than profit