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

Support using asyncio coroutines from inside greenlets #877

Conversation

itamarst
Copy link
Contributor

Fixes #873

Copy link

codecov bot commented Jan 11, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (df81d5d) 55% compared to head (48958b6) 54%.
Report is 2 commits behind head on master.

Files Patch % Lines
eventlet/asyncio.py 95% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##           master   #877   +/-   ##
=====================================
- Coverage      55%    54%   -1%     
=====================================
  Files          89     90    +1     
  Lines        9837   9860   +23     
  Branches     1828   1830    +2     
=====================================
- Hits         5414   5400   -14     
- Misses       4054   4089   +35     
- Partials      369    371    +2     
Flag Coverage Δ
ipv6 22% <34%> (+<1%) ⬆️
py310asyncio ?
py310epolls 52% <39%> (-1%) ⬇️
py310poll ?
py310selects 52% <39%> (-1%) ⬇️
py311asyncio 52% <86%> (+<1%) ⬆️
py311epolls 52% <39%> (-1%) ⬇️
py312asyncio 49% <86%> (+<1%) ⬆️
py312epolls 50% <39%> (-1%) ⬇️
py37epolls 50% <39%> (-1%) ⬇️
py38epolls 52% <39%> (-1%) ⬇️
py38openssl ?
py38poll 52% <39%> (-1%) ⬇️
py38selects 52% <39%> (-1%) ⬇️
py39dnspython1 ?
py39epolls ?
py39poll 52% <39%> (-1%) ⬇️
py39selects ?

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.

@itamarst itamarst changed the title Support calling asyncio using async def functions from inside greenlets Support using asyncio coroutines from inside greenlets Jan 11, 2024
@itamarst itamarst changed the title Support using asyncio coroutines from inside greenlets WIP: Support using asyncio coroutines from inside greenlets Jan 11, 2024
@itamarst itamarst changed the title WIP: Support using asyncio coroutines from inside greenlets Support using asyncio coroutines from inside greenlets Jan 11, 2024
@itamarst itamarst requested a review from a team January 11, 2024 17:48
Copy link
Member

@4383 4383 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@itamarst: Amazing work!

I just have 2 inline comments, but globally everything LGTM.

eventlet/asyncio.py Outdated Show resolved Hide resolved
@@ -72,6 +72,7 @@ deps =
py{310,311}: psycopg2-binary==2.9.5
py{310,311}: pyzmq==25.0.0
dnspython1: dnspython<2
asyncio: aiohttp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is aiohttp is only required by tests? I suppose that yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's just a testing thing.

@itamarst
Copy link
Contributor Author

Need to check if this affected by #408.

@itamarst
Copy link
Contributor Author

Looks like #408 is only an issue in Python 3.10 or earlier, so not going to worry about it.

@itamarst
Copy link
Contributor Author

@4383 if you're happy can you formally do the approval so I can merge? Thanks!

@itamarst itamarst requested a review from 4383 January 12, 2024 15:33
Copy link
Member

@4383 4383 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@4383
Copy link
Member

4383 commented Jan 12, 2024

I let you push the button and rewrite the commit message if you think that's necessary.

@itamarst
Copy link
Contributor Author

I made one final change, renaming the function to spawn_for_awaitable() since that's a more accurate description of the API.

@itamarst itamarst merged commit 3f8c1da into master Jan 16, 2024
26 checks passed
@itamarst itamarst deleted the 873-support-calling-asyncio-using-async-def-functions-from-inside-greenlets branch January 16, 2024 13:52
@4383 4383 mentioned this pull request Jan 18, 2024
openstack-mirroring pushed a commit to openstack/openstack that referenced this pull request Jan 30, 2024
* Update requirements from branch 'master'
  to 08f829d8375b4059af365191e0907069be9fb739
  - Update eventlet to 0.35.0
    
    0.35.0
    ======
    
    eventlet/eventlet#897
    
    * [fix] fix truncate size nullable eventlet/eventlet#789
    * [fix] Handle transport endpoint shutdown in conditions eventlet/eventlet#884
    * [fix] Rework reject_bad_requests option eventlet/eventlet#890
    * [fix] Fix NameError introduced by #826 eventlet/eventlet#890
    * [feature] Support awaiting GreenThread in an `async def` context eventlet/eventlet#889
    * [feature] Asyncio hub support for Python 3.7 to 3.9 eventlet/eventlet#886
    * [fix] Fix bad exceptions handlings eventlet/eventlet#883
    * [feature] Support using asyncio coroutines from inside greenlets eventlet/eventlet#877
    * [removal] Remove deprecated CGIHTTPServer and SimpleHTTPServer eventlet/eventlet#881
    * [feature] Add an asyncio hub for eventlet eventlet/eventlet#870
    
    0.34.3
    ======
    
    eventlet/eventlet#875
    
    * Fix security issue in the wsgi module related to RFC 9112 eventlet/eventlet#826
    * Fix segfault, a new approach for greening existing locks eventlet/eventlet#866
    * greendns: fix getaddrinfo parameter name eventlet/eventlet#809
    * Fix deprecation warning on ssl.PROTOCOL_TLS eventlet/eventlet#872
    * Pytests, fix error at teardown of TestGreenSocket.test_full_duplex eventlet/eventlet#871
    * Skip test which uses Py cgi module eventlet/eventlet#865
    * Drop old code based on python < 3.7.34.2
    ======
    
    eventlet/eventlet#861
    
    * Allowing inheritance of GreenSSLSocket without overriding the __new_ method eventlet/eventlet#796
    * [bug] Fix broken API related to `__version__` removal eventlet/eventlet#859
    * [doc] Fix pypi broken link eventlet/eventlet#857
    
    0.34.1
    ======
    
    eventlet/eventlet#842
    
    * [bug] Fix memory leak in greendns eventlet/eventlet#810
    * [infra] Fix OIDC authentication failure eventlet/eventlet#855
    * [bug] Ignore asyncore and asynchat for Python 3.12+ eventlet/eventlet#804
    
    0.34.0 (Not released on Pypi but landed with 0.34.1)
    ====================================================
    
    * Dropped support for Python 3.6 and earlier.
    * Fix Python 3.13 compat by adding missing attibute '_is_main_interpreter' eventlet/eventlet#847
    * Add support of Python 3.12 eventlet/eventlet#817
    * Drop unmaintained and unused stdlib tests eventlet/eventlet#820
    * Fix tests and CI for Python 3.7 and higher eventlet/eventlet#831 and eventlet/eventlet#832
    * Stop claiming to create universal wheels eventlet/eventlet#841
    * Fix green logging locks for Python versions <= 3.10 eventlet/eventlet#754
    
    Change-Id: I909be1d1812eaed574525866dbc123083684571d
openstack-mirroring pushed a commit to openstack/requirements that referenced this pull request Jan 30, 2024
0.35.0
======

eventlet/eventlet#897

* [fix] fix truncate size nullable eventlet/eventlet#789
* [fix] Handle transport endpoint shutdown in conditions eventlet/eventlet#884
* [fix] Rework reject_bad_requests option eventlet/eventlet#890
* [fix] Fix NameError introduced by #826 eventlet/eventlet#890
* [feature] Support awaiting GreenThread in an `async def` context eventlet/eventlet#889
* [feature] Asyncio hub support for Python 3.7 to 3.9 eventlet/eventlet#886
* [fix] Fix bad exceptions handlings eventlet/eventlet#883
* [feature] Support using asyncio coroutines from inside greenlets eventlet/eventlet#877
* [removal] Remove deprecated CGIHTTPServer and SimpleHTTPServer eventlet/eventlet#881
* [feature] Add an asyncio hub for eventlet eventlet/eventlet#870

0.34.3
======

eventlet/eventlet#875

* Fix security issue in the wsgi module related to RFC 9112 eventlet/eventlet#826
* Fix segfault, a new approach for greening existing locks eventlet/eventlet#866
* greendns: fix getaddrinfo parameter name eventlet/eventlet#809
* Fix deprecation warning on ssl.PROTOCOL_TLS eventlet/eventlet#872
* Pytests, fix error at teardown of TestGreenSocket.test_full_duplex eventlet/eventlet#871
* Skip test which uses Py cgi module eventlet/eventlet#865
* Drop old code based on python < 3.7.34.2
======

eventlet/eventlet#861

* Allowing inheritance of GreenSSLSocket without overriding the __new_ method eventlet/eventlet#796
* [bug] Fix broken API related to `__version__` removal eventlet/eventlet#859
* [doc] Fix pypi broken link eventlet/eventlet#857

0.34.1
======

eventlet/eventlet#842

* [bug] Fix memory leak in greendns eventlet/eventlet#810
* [infra] Fix OIDC authentication failure eventlet/eventlet#855
* [bug] Ignore asyncore and asynchat for Python 3.12+ eventlet/eventlet#804

0.34.0 (Not released on Pypi but landed with 0.34.1)
====================================================

* Dropped support for Python 3.6 and earlier.
* Fix Python 3.13 compat by adding missing attibute '_is_main_interpreter' eventlet/eventlet#847
* Add support of Python 3.12 eventlet/eventlet#817
* Drop unmaintained and unused stdlib tests eventlet/eventlet#820
* Fix tests and CI for Python 3.7 and higher eventlet/eventlet#831 and eventlet/eventlet#832
* Stop claiming to create universal wheels eventlet/eventlet#841
* Fix green logging locks for Python versions <= 3.10 eventlet/eventlet#754

Change-Id: I909be1d1812eaed574525866dbc123083684571d
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.

Support calling asyncio-using async def functions from inside greenlets
3 participants