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

An asyncio hub for eventlet #870

Merged
merged 16 commits into from Jan 11, 2024
Merged

Conversation

itamarst
Copy link
Contributor

@itamarst itamarst commented Jan 3, 2024

Fixes #869

I gave up on multi-reader support, I can't even figure out how it works and it seems like a terrible idea (though people are using it, based on quick GitHub search).

@itamarst itamarst linked an issue Jan 3, 2024 that may be closed by this pull request
Copy link

codecov bot commented Jan 3, 2024

Codecov Report

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

Comparison is base (a94a3cf) 54% compared to head (457c9d9) 55%.

Files Patch % Lines
eventlet/hubs/asyncio.py 90% 2 Missing and 6 partials ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##           master   #870    +/-   ##
======================================
  Coverage      54%    55%            
======================================
  Files          88     89     +1     
  Lines        9744   9832    +88     
  Branches     1814   1829    +15     
======================================
+ Hits         5297   5408   +111     
+ Misses       4081   4053    -28     
- Partials      366    371     +5     
Flag Coverage Δ
ipv6 22% <14%> (-1%) ⬇️
py310asyncio 51% <91%> (?)
py310epolls 52% <16%> (-1%) ⬇️
py310poll 52% <16%> (-1%) ⬇️
py310selects 52% <16%> (-1%) ⬇️
py311asyncio 51% <91%> (?)
py311epolls 52% <16%> (-1%) ⬇️
py312asyncio 49% <91%> (?)
py312epolls 50% <16%> (-1%) ⬇️
py37epolls 50% <16%> (-1%) ⬇️
py38epolls 52% <16%> (-1%) ⬇️
py38openssl 51% <16%> (-1%) ⬇️
py38poll 52% <16%> (-1%) ⬇️
py38selects 52% <16%> (-1%) ⬇️
py39dnspython1 50% <16%> (-1%) ⬇️
py39epolls 52% <16%> (-1%) ⬇️
py39poll 52% <16%> (-1%) ⬇️
py39selects 52% <16%> (-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.

@tipabu
Copy link
Contributor

tipabu commented Jan 3, 2024

FWIW, I've worked with code that needed to allow multiple readers. The long and short of it was needing to have a lock that would play nice with both greenthreads and real threads to work around #432; more details are available in openstack/swift@6d16079 / LP #1710328

Unfortunately, it also worked across forks, which seemed unnecessary and likely to impact performance. Eventually I managed to convince myself it wasn't necessary since we were always using UDP/Unix domain sockets for logging, so we wound up dropping the logging lock in openstack/swift@e09d4bc

I don't really have anything to add beyond that; I'll try to give this a spin in the near future, though. I just wanted to add some color to

I gave up on multi-reader support, I can't even figure out how it works and it seems like a terrible idea (though people are using it, based on quick GitHub search).

@itamarst
Copy link
Contributor Author

itamarst commented Jan 3, 2024

If someone can make it work, great, I just gave up because how it works at all is an utter mystery to me (notice eventlet.hubs.hub.Hub.secondaries is never accessed by anything!). Given the goal here is for people to port to asyncio, and I suspect this isn't an asyncio feature anyway, so porting would have to drop such usages anyway. And it sounds like in practice Swift doesn't need it anymore?

@4383 4383 mentioned this pull request Jan 10, 2024
10 tasks
AUTHORS Show resolved Hide resolved
Comment on lines 12 to 14
def is_available():
"""Python 3 always has asyncio."""
return True
Copy link
Member

Choose a reason for hiding this comment

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

Seems related to python 2/3 compat. As we dropped support of Python 2.7, I think we could also remove that check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, the Hub API requires this, if you don't have this it emits an warning. See https://github.com/eventlet/eventlet/blob/master/eventlet/hubs/__init__.py#L81-L88

eventlet/hubs/asyncio.py Outdated Show resolved Hide resolved
tests/greenio_test.py Show resolved Hide resolved
@4383
Copy link
Member

4383 commented Jan 10, 2024

Docstrings should be documented. If we want to encourage migration to eventlet and, hence, hope to see this feature adopted, then we need to provide a well documented hub.

Do you already plan to add docstring or should we add it to our todo list, and, add doc through a follow up patch?

Concerning gates, they seems happy, even when the asyncio hub is enabled. That's encouraging!

@itamarst
Copy link
Contributor Author

(I have implemented the start of next step, running asyncio in combination with eventlet, just to see if it actually works, and ... it does! I have a test with aiohttp talking to eventlet's WSGI server. So feeling good about this approach.)

@itamarst
Copy link
Contributor Author

Docstrings should be documented. If we want to encourage migration to eventlet and, hence, hope to see this feature adopted, then we need to provide a well documented hub.

The public APIs are the eventlet.hubs.Hub interface, so in general that documentation is the relevant one. Users won't be using this class directly much, possibly not at all.

Will see if there's anything that does need it though.

Concerning gates, they seems happy, even when the asyncio hub is enabled. That's encouraging!

Gates?

@4383
Copy link
Member

4383 commented Jan 10, 2024

Docstrings should be documented. If we want to encourage migration to eventlet and, hence, hope to see this feature adopted, then we need to provide a well documented hub.

The public APIs are the eventlet.hubs.Hub interface, so in general that documentation is the relevant one. Users won't be using this class directly much, possibly not at all.

Indeed.

Will see if there's anything that does need it though.

WFM.

Concerning gates, they seems happy, even when the asyncio hub is enabled. That's encouraging!

Gates?

jobs/tests triggered by github actions

@itamarst itamarst requested a review from 4383 January 10, 2024 16:29
@itamarst
Copy link
Contributor Author

Filed #874 for multiple reader support.

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.

As far as I can see, these changes LGTM.

That could be useful, during the squash, to indicate in the commit message, that this patch is inspired from https://gist.github.com/miguelgrinberg/829a20792d7283ae27b1f6a390c378b9 . We shouldn't skimp on the history.

@4383
Copy link
Member

4383 commented Jan 11, 2024

That could be useful, during the squash, to indicate in the commit message, that this patch is inspired from https://gist.github.com/miguelgrinberg/829a20792d7283ae27b1f6a390c378b9 . We shouldn't skimp on the history.

Oh just seen you already put a comment, awesome!

@4383
Copy link
Member

4383 commented Jan 11, 2024

I let you rewrite the commit message and drop useless info.
I let you push the merge button.

@itamarst itamarst merged commit df81d5d into master Jan 11, 2024
26 checks passed
@itamarst itamarst deleted the 869-an-asyncio-hub-for-eventlet branch January 11, 2024 16:41
@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.

An asyncio hub for eventlet
4 participants