Skip to content

Add debug convenience helpers - asyncio, threads#925

Merged
4383 merged 1 commit intoeventlet:masterfrom
4383:eventlet_debug
Mar 7, 2024
Merged

Add debug convenience helpers - asyncio, threads#925
4383 merged 1 commit intoeventlet:masterfrom
4383:eventlet_debug

Conversation

@4383
Copy link
Copy Markdown
Member

@4383 4383 commented Mar 6, 2024

This patch aims to add some convenience helpers to help during debug session related to asyncio and threading.

Those can be used in any running context.
As example, those helper could be used during pdb sessions like this:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
PDB post_mortem (IO-capturing turned off)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /home/dev/app/tests/asyncio_test.py(235)go()
-> async def go():
(Pdb) import eventlet
(Pdb) pp eventlet.debug.format_threads_info()
('THREADS:\n'
 '{139916325074752: <_MainThread(MainThread, started
 139916325074752)>}')
(Pdb) pp eventlet.debug.format_asyncio_info()
('TASKS:\n'
 "{<Task pending name='Task-1' coro=<Hub.run.<locals>.async_run()
 running at "
  '/home/dev/app/eventlet/hubs/asyncio.py:141>
  cb=[_run_until_complete_cb() at '
   '/usr/local/lib/python3.12/asyncio/base_events.py:181] created at '
    '/usr/local/lib/python3.12/asyncio/tasks.py:695>}\n'
     'EVENTLOOP: <_UnixSelectorEventLoop running=True closed=False
     debug=True>')

The previous examples pretty print both helpers outputs.

This patch aims to add some convenience helpers
to help during debug session related to asyncio
and threading.

Those can be used in any running context.
As example, those helper could be used during pdb sessions
like this:

```
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
PDB post_mortem (IO-capturing turned off)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /home/dev/app/tests/asyncio_test.py(235)go()
-> async def go():
(Pdb) import eventlet
(Pdb) pp eventlet.debug.format_threads_info()
('THREADS:\n'
 '{139916325074752: <_MainThread(MainThread, started
 139916325074752)>}')
(Pdb) pp eventlet.debug.format_asyncio_info()
('TASKS:\n'
 "{<Task pending name='Task-1' coro=<Hub.run.<locals>.async_run()
 running at "
  '/home/dev/app/eventlet/hubs/asyncio.py:141>
  cb=[_run_until_complete_cb() at '
   '/usr/local/lib/python3.12/asyncio/base_events.py:181] created at '
    '/usr/local/lib/python3.12/asyncio/tasks.py:695>}\n'
     'EVENTLOOP: <_UnixSelectorEventLoop running=True closed=False
     debug=True>')
```

The previous examples pretty print both helpers outputs.
@4383 4383 requested review from itamarst and tipabu March 6, 2024 12:48
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 6, 2024

Codecov Report

Attention: Patch coverage is 15.38462% with 11 lines in your changes are missing coverage. Please review.

Project coverage is 56%. Comparing base (0a130e2) to head (f3d8622).

Files Patch % Lines
eventlet/debug.py 15% 11 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##           master   #925   +/-   ##
=====================================
- Coverage      56%    56%   -1%     
=====================================
  Files          89     89           
  Lines        9728   9741   +13     
  Branches     1812   1812           
=====================================
+ Hits         5461   5463    +2     
- Misses       3892   3903   +11     
  Partials      375    375           
Flag Coverage Δ
ipv6 23% <15%> (-1%) ⬇️
py310asyncio 53% <15%> (-1%) ⬇️
py310epolls 53% <15%> (-1%) ⬇️
py310poll 53% <15%> (-1%) ⬇️
py310selects 53% <15%> (-1%) ⬇️
py311asyncio 53% <15%> (-1%) ⬇️
py311epolls 53% <15%> (-1%) ⬇️
py312asyncio 50% <15%> (-1%) ⬇️
py312epolls 51% <15%> (-1%) ⬇️
py37asyncio 50% <15%> (-1%) ⬇️
py37epolls 51% <15%> (-1%) ⬇️
py38asyncio 51% <15%> (-1%) ⬇️
py38epolls 53% <15%> (-1%) ⬇️
py38openssl 52% <15%> (-1%) ⬇️
py38poll 53% <15%> (-1%) ⬇️
py38selects 53% <15%> (-1%) ⬇️
py39asyncio 51% <15%> (-1%) ⬇️
py39dnspython1 51% <15%> (-1%) ⬇️
py39epolls 53% <15%> (-1%) ⬇️
py39poll 53% <15%> (-1%) ⬇️
py39selects 53% <15%> (-1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@4383 4383 merged commit 3e36f69 into eventlet:master Mar 7, 2024
@4383 4383 mentioned this pull request Mar 15, 2024
clrpackages pushed a commit to clearlinux-pkgs/pypi-eventlet that referenced this pull request Jul 10, 2024
…rsion 0.36.1

0.36.1
======

* [fix] eventlet.websocket is not always used from eventlet.wsgi, so do not assume eventlet.set_idle exists eventlet/eventlet#949

0.36.0
======

* [fix] Make sure asyncio hub doesn't use greendns for asyncio DNS APIs eventlet/eventlet#938
* [fix] Make asyncio.to_thread work with the same semantics as normal asyncio eventlet/eventlet#930
* [fix] Refactor congruence checks based on assert at runtime eventlet/eventlet#932
* [tests] Run tests on macOS in CI, and some fixes to get it in reasonable state (#list eventlet/eventlet#934
* [fix] Fix wsgi.server shutdown for in-flight requests eventlet/eventlet#912
* [feature] Add debug convenience helpers - asyncio, threads eventlet/eventlet#925
* [fix] Handle errors better. eventlet/eventlet#923

(NEWS truncated at 15 lines)

CVEs fixed in this build:
CVE-2023-29483
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants