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

Enable origin tracking for coroutine objects #6762

Merged
merged 1 commit into from
Feb 10, 2022

Conversation

kozlovsky
Copy link
Contributor

@kozlovsky kozlovsky commented Feb 9, 2022

Sometimes in tests, we have a situation when the task was created in one test or fixture and then crashed in a totally unrelated test during the garbage collection phase. In that case, we see the failed test, but not the test or fixture that was the originator of the unhandled task.

In this PR I enable the origin tracking for coroutine objects (a feature available in Python 3.7 and later).

As an example, right now I see the following error in a completely unrelated test:

RuntimeError: 1 Runtime Warning,
c:\dev\tribler\venv\lib\site-packages\aiohttp\test_utils.py:536:coroutine 'interval_runner' was never awaited

With this feature enabled, I can see the traceback and discover the fixture in which the unhandled task was created:

RuntimeError: 1 Runtime Warning,
c:\dev\tribler\venv\lib\site-packages\aiohttp\test_utils.py:536:coroutine 'interval_runner' was never awaited
Coroutine created at (most recent call last)
  File "C:\dev\tribler\venv\lib\site-packages\pluggy\hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "C:\dev\tribler\venv\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "C:\dev\tribler\venv\lib\site-packages\pluggy\manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "C:\dev\tribler\venv\lib\site-packages\pluggy\callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "C:\dev\tribler\venv\lib\site-packages\_pytest\fixtures.py", line 1126, in pytest_fixture_setup
    result = call_fixture_func(fixturefunc, request, kwargs)
  File "C:\dev\tribler\venv\lib\site-packages\_pytest\fixtures.py", line 932, in call_fixture_func
    fixture_result = fixturefunc(**kwargs)
  File "C:\dev\tribler\src\tribler-core\tribler_core\components\tag\rules\tests\test_tag_rules_processor.py", line 16, in tag_rules_processor
    return TagRulesProcessor(notifier=MagicMock(), db=MagicMock(), mds=MagicMock(), batch_size=TEST_BATCH_SIZE,
  File "C:\dev\tribler\src\tribler-core\tribler_core\components\tag\rules\tag_rules_processor.py", line 31, in __init__
    super().__init__()
  File "C:\dev\tribler\src\pyipv8\ipv8\taskmanager.py", line 57, in __init__
    self._checker = self.register_task('_check_tasks', self._check_tasks,
  File "C:\dev\tribler\src\pyipv8\ipv8\taskmanager.py", line 110, in register_task
    task = ensure_future(interval_runner(delay, interval, task, *args))

@kozlovsky kozlovsky requested review from a team, drew2a and devos50 and removed request for a team February 9, 2022 14:42
devos50
devos50 previously approved these changes Feb 10, 2022
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.5% 0.5% Duplication

@kozlovsky kozlovsky merged commit df5e186 into Tribler:main Feb 10, 2022
@kozlovsky kozlovsky deleted the feature/enable_origin_tracking branch February 10, 2022 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants