-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
fix(taskworker) remove signal handler safely #88799
Conversation
There are some tests for `child_worker` that are not in child processes, and we're currently leaking signal handlers. Use a context manager to add/cancel the signal handler. Fixes #88742
src/sentry/taskworker/worker.py
Outdated
@@ -48,7 +52,22 @@ class ProcessingResult: | |||
status: TaskActivationStatus.ValueType | |||
|
|||
|
|||
AT_MOST_ONCE_TIMEOUT = 60 * 60 * 24 # 1 day | |||
@contextlib.contextmanager | |||
def timeout_alarm(seconds: int, handler: Callable[[int, Any], None]): |
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.
since the actual handler doesn't care about either of its arguments it can be Callable[[object, object], None]
and this should -> Generator[None]
next_state = TASK_ACTIVATION_STATUS_FAILURE | ||
execution_start_time = time.time() |
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.
time.time
should really never be used for timing as it is subjected to smear / etc.
you probably want time.monotonic()
https://youtu.be/hb-12mgQrzM
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.
While I can switch a few usage of time.time()
, I don't think all of them can be changed. We need to do some time differences against the message produce time which is a protobuf timestamp. These won't be precise measurements as clock times can vary from one system to another, but there aren't many other portable time representations.
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.
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #88799 +/- ##
===========================================
+ Coverage 32.97% 87.73% +54.75%
===========================================
Files 8505 10066 +1561
Lines 475082 569399 +94317
Branches 22355 22355
===========================================
+ Hits 156646 499536 +342890
+ Misses 318037 69464 -248573
Partials 399 399 |
There are some tests for `child_worker` that are not in child processes, and we're currently leaking signal handlers. Use a context manager to add/cancel the signal handler. Fixes #88742
There are some tests for
child_worker
that are not in child processes, and we're currently leaking signal handlers. Use a context manager to add/cancel the signal handler.Fixes #88742