Skip to content

Commit c6f1fe3

Browse files
author
Julien Danjou
authored
test(profiling): improve gevent task testing (#2994)
This tests still fails from time to time because we don't see sleep() or _nothing() in the last stack: calling gevent sleep might trigger the gevent hub switch() function which is reported as the last function called. Nevertheless, _nothing() and/or sleep() are still in the stack trace, which is what we want. We just need to look deeper.
1 parent 5190cb4 commit c6f1fe3

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

tests/profiling/collector/test_stack.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -626,13 +626,15 @@ def _nothing():
626626
pytest.fail("Task with no name detected, is it the Hub?")
627627
else:
628628
main_thread_found = True
629-
elif event.task_id in {t.ident for t in threads} and event.frames[0][2] in (
630-
"_nothing",
631-
"sleep",
632-
):
633-
# Make sure we capture the sleep call and not a gevent hub frame
634-
sleep_task_found = True
635-
636-
# Make sure we did at least one check
637-
assert main_thread_found, events
638-
assert sleep_task_found, events
629+
elif event.task_id in {t.ident for t in threads}:
630+
for filename, lineno, funcname in event.frames:
631+
if funcname in (
632+
"_nothing",
633+
"sleep",
634+
):
635+
# Make sure we capture the sleep call and not a gevent hub frame
636+
sleep_task_found = True
637+
break
638+
639+
assert main_thread_found
640+
assert sleep_task_found

0 commit comments

Comments
 (0)