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

fix: prevent celery from hanging due to spawned greenlet errors in greenlet drainers #9371

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
30e4d84
add .tool-versions to .gitignore
linusphan Oct 21, 2024
43d8395
propagate event drainer errors to prevent infinite loop and require m…
linusphan Oct 21, 2024
eb46270
Merge branch 'main' of github.com:linusphan/celery into fix-result-ba…
linusphan Oct 21, 2024
0cfb89d
remove typing
linusphan Oct 21, 2024
badb649
add tests
linusphan Oct 22, 2024
ac389cd
add tests and refactor implementation
linusphan Oct 22, 2024
297d6e3
remove test code and add pydoc for clarity
linusphan Oct 22, 2024
51bb91c
retrigger ci
linusphan Oct 23, 2024
29e0ea8
Merge branch 'main' into fix-result-backend-connection-error-handling
linusphan Oct 23, 2024
005f0a3
raise error in greenlet to ensure it exits, and add more test coverage
linusphan Oct 24, 2024
e65abec
calls `teardown_thread` when using `schedule_thread` in tests
linusphan Oct 24, 2024
d12c0ec
use wait() instead of while loop for clarity in teardown_thread for t…
linusphan Oct 24, 2024
87419c3
fix lint
linusphan Oct 24, 2024
7099666
Merge branch 'main' into fix-result-backend-connection-error-handling
Nusnus Nov 18, 2024
1967ab7
Merge branch 'main' into fix-result-backend-connection-error-handling
auvipy Dec 14, 2024
02e1f09
Merge branch 'main' into fix-result-backend-connection-error-handling
Nusnus Dec 17, 2024
7d0e768
Merge branch 'main' into fix-result-backend-connection-error-handling
auvipy Dec 18, 2024
75adf99
Merge branch 'main' into fix-result-backend-connection-error-handling
Nusnus Dec 19, 2024
6b83719
Merge branch 'main' into fix-result-backend-connection-error-handling
auvipy Dec 22, 2024
a9a1b4e
Merge branch 'main' into fix-result-backend-connection-error-handling
auvipy Dec 24, 2024
6f3a280
Merge branch 'main' into fix-result-backend-connection-error-handling
Nusnus Feb 11, 2025
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
Prev Previous commit
Next Next commit
add tests
  • Loading branch information
linusphan committed Oct 22, 2024
commit badb649abcaf7576928b7c3b64f60916e466844d
32 changes: 32 additions & 0 deletions t/unit/backends/test_asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,22 @@ def schedule_thread(self, thread):
def teardown_thread(self, thread):
thread.wait()

def test_drain_with_greenlet_error_raises(self):
exc_msg = "Test Exception"

# `drain_events` is called within `run`, which gets called within the greenlet
with patch.object(self.drainer.result_consumer, 'drain_events', side_effect=Exception(exc_msg)):
greenthread = self.schedule_thread(self.drainer.run)

# verify that the greenlet error is raised during event draining
with pytest.raises(Exception, match=exc_msg):
p = promise()

for _ in self.drainer.drain_events_until(p, interval=self.interval):
pass

self.teardown_thread(greenthread)


class test_Drainer(DrainerTests):
@pytest.fixture(autouse=True)
Expand Down Expand Up @@ -223,3 +239,19 @@ def schedule_thread(self, thread):
def teardown_thread(self, thread):
import gevent
gevent.wait([thread])

def test_drain_with_greenlet_error_raises(self):
exc_msg = "Test Exception"

# `drain_events` is called within `run`, which gets called within the greenlet
with patch.object(self.drainer.result_consumer, 'drain_events', side_effect=Exception(exc_msg)):
greenlet = self.schedule_thread(self.drainer.run)

# verify that the greenlet error is raised during event draining
with pytest.raises(Exception, match=exc_msg):
p = promise()

for _ in self.drainer.drain_events_until(p, interval=self.interval):
pass

self.teardown_thread(greenlet)
Loading