-
Notifications
You must be signed in to change notification settings - Fork 810
Celery add support for anon tasks #1052
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
Changes from all commits
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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -77,3 +77,46 @@ def test_task(self): | |||||||||
| self.assertNotEqual(consumer.parent, producer.context) | ||||||||||
| self.assertEqual(consumer.parent.span_id, producer.context.span_id) | ||||||||||
| self.assertEqual(consumer.context.trace_id, producer.context.trace_id) | ||||||||||
|
|
||||||||||
|
|
||||||||||
| class TestCelerySignatureTask(TestBase): | ||||||||||
| def setUp(self): | ||||||||||
| super().setUp() | ||||||||||
|
|
||||||||||
| def start_app(*args, **kwargs): | ||||||||||
| # Add an additional task that will not be registered with parent thread | ||||||||||
| @app.task | ||||||||||
| def hidden_task(x): | ||||||||||
| return x * 2 | ||||||||||
|
|
||||||||||
| self._worker = app.Worker(app=app, pool="solo", concurrency=1) | ||||||||||
| return self._worker.start(*args, **kwargs) | ||||||||||
|
|
||||||||||
| self._thread = threading.Thread(target=start_app) | ||||||||||
| self._worker = app.Worker(app=app, pool="solo", concurrency=1) | ||||||||||
| self._thread.daemon = True | ||||||||||
| self._thread.start() | ||||||||||
|
|
||||||||||
| def tearDown(self): | ||||||||||
| super().tearDown() | ||||||||||
| self._worker.stop() | ||||||||||
| self._thread.join() | ||||||||||
|
|
||||||||||
| def test_hidden_task(self): | ||||||||||
| # no-op since already instrumented | ||||||||||
| CeleryInstrumentor().instrument() | ||||||||||
| import ipdb; ipdb.set_trace() | ||||||||||
|
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.
Suggested change
Member
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. pytest-ipdb is unfortunately not supported anymore. The solution is to add "--pdb --pdbcls=IPython.terminal.debugger:Pdb" with pytest command From the help command: pytest -h |
||||||||||
|
|
||||||||||
| res = app.signature("app.hidden_task", (2,)).apply_async() | ||||||||||
| while not res.ready(): | ||||||||||
| time.sleep(0.05) | ||||||||||
|
|
||||||||||
| spans = self.sorted_spans(self.memory_exporter.get_finished_spans()) | ||||||||||
| self.assertEqual(len(spans), 1) | ||||||||||
|
|
||||||||||
| producer = spans | ||||||||||
|
|
||||||||||
| self.assertEqual( | ||||||||||
| producer.name, "apply_async/app.hidden_task" | ||||||||||
| ) | ||||||||||
|
Comment on lines
+119
to
+121
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.
Suggested change
Contributor
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. Are we still working on this issue ? |
||||||||||
| self.assertEqual(producer.kind, SpanKind.PRODUCER) | ||||||||||
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'll copy the comment I wrote on the original PR in your fork for the wide discussion:
Didn't actually try to run it, so I might just not fully understand the details of what causes the "publish" span to be ended.