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

[DNM][deprecation] deprecate non asyncio hubs #945

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions doc/source/hubs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ Eventlet has multiple hub implementations, and when you start using it, it tries
| By using this hub, Asyncio and Eventlet can be run the same thread in the same process.
| We discourage new Eventlet projects.
| We encourage existing Eventlet projects to migrate from Eventlet to Asyncio.
| We encourage using this hub at runtime.
| This hub allow you incremental and smooth migration.
| See the `migration guide <https://eventlet.readthedocs.io/en/latest/migration.html>`_ for further details.
**epolls**
**(DEPRECATED) epolls**
Linux. This is the fastest hub for Linux.
**kqueue**
**(DEPRECATED) kqueue**
FreeBSD and Mac OSX. Fastest hub for OS with kqueue.
**poll**
**(DEPRECATED) poll**
On platforms that support it.
**selects**
**(DEPRECATED) selects**
Lowest-common-denominator, available everywhere.

The only non-pure Python, pyevent hub (using libevent) was removed because it was not maintained. You are warmly welcome to contribute fast hub implementation using Cython, CFFI or other technology of your choice.
Expand Down
21 changes: 21 additions & 0 deletions eventlet/hubs/epolls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import errno
import warnings

from eventlet import patcher, support
from eventlet.hubs import hub, poll
select = patcher.original('select')
Expand All @@ -11,10 +13,29 @@ def is_available():
# NOTE: we rely on the fact that the epoll flag constants
# are identical in value to the poll constants
class Hub(poll.Hub):
"""
.. warning::
The eventlet epolls hub is now deprecated and will be removed.
Users should begin planning a migration from eventlet to asyncio.
Users are encouraged to switch to the eventlet asyncio hub in
order to start this migration.
Please find more details at https://eventlet.readthedocs.io/en/latest/migration.html
"""
def __init__(self, clock=None):
super().__init__(clock=clock)
self.poll = select.epoll()

warnings.warn(
"""
ACTION REQUIRED: The eventlet epolls hub is now deprecated and will be removed.
Users should begin planning a migration from eventlet to asyncio.
Users are encouraged to switch to the eventlet asyncio hub in
order to start this migration.
Please find more details at https://eventlet.readthedocs.io/en/latest/migration.html
""",
DeprecationWarning,
)

def add(self, evtype, fileno, cb, tb, mac):
oldlisteners = bool(self.listeners[self.READ].get(fileno) or
self.listeners[self.WRITE].get(fileno))
Expand Down
21 changes: 21 additions & 0 deletions eventlet/hubs/kqueue.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
import sys
import warnings

from eventlet import patcher, support
from eventlet.hubs import hub
select = patcher.original('select')
Expand All @@ -11,6 +13,14 @@


class Hub(hub.BaseHub):
"""
.. warning::
The eventlet kqueue hub is now deprecated and will be removed.
Users should begin planning a migration from eventlet to asyncio.
Users are encouraged to switch to the eventlet asyncio hub in
order to start this migration.
Please find more details at https://eventlet.readthedocs.io/en/latest/migration.html
"""
MAX_EVENTS = 100

def __init__(self, clock=None):
Expand All @@ -22,6 +32,17 @@
self._events = {}
self._init_kqueue()

warnings.warn(

Check warning on line 35 in eventlet/hubs/kqueue.py

View check run for this annotation

Codecov / codecov/patch

eventlet/hubs/kqueue.py#L35

Added line #L35 was not covered by tests
"""
ACTION REQUIRED: The eventlet kqueue hub is now deprecated and will be removed.
Users should begin planning a migration from eventlet to asyncio.
Users are encouraged to switch to the eventlet asyncio hub in
order to start this migration.
Please find more details at https://eventlet.readthedocs.io/en/latest/migration.html
""",
DeprecationWarning,
)

def _init_kqueue(self):
self.kqueue = select.kqueue()
self._pid = os.getpid()
Expand Down
20 changes: 20 additions & 0 deletions eventlet/hubs/poll.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import errno
import sys
import warnings

from eventlet import patcher, support
from eventlet.hubs import hub
Expand All @@ -12,13 +13,32 @@ def is_available():


class Hub(hub.BaseHub):
"""
.. warning::
The eventlet poll hub is now deprecated and will be removed.
Users should begin planning a migration from eventlet to asyncio.
Users are encouraged to switch to the eventlet asyncio hub in
order to start this migration.
Please find more details at https://eventlet.readthedocs.io/en/latest/migration.html
"""
def __init__(self, clock=None):
super().__init__(clock)
self.EXC_MASK = select.POLLERR | select.POLLHUP
self.READ_MASK = select.POLLIN | select.POLLPRI
self.WRITE_MASK = select.POLLOUT
self.poll = select.poll()

warnings.warn(
"""
ACTION REQUIRED: The eventlet poll hub is now deprecated and will be removed.
Users should begin planning a migration from eventlet to asyncio.
Users are encouraged to switch to the eventlet asyncio hub in
order to start this migration.
Please find more details at https://eventlet.readthedocs.io/en/latest/migration.html
""",
DeprecationWarning,
)

def add(self, evtype, fileno, cb, tb, mac):
listener = super().add(evtype, fileno, cb, tb, mac)
self.register(fileno, new=True)
Expand Down
24 changes: 24 additions & 0 deletions eventlet/hubs/selects.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import errno
import sys
import warnings

from eventlet import patcher, support
from eventlet.hubs import hub
select = patcher.original('select')
Expand All @@ -16,6 +18,28 @@ def is_available():


class Hub(hub.BaseHub):
"""
.. warning::
The eventlet selects hub is now deprecated and will be removed.
Users should begin planning a migration from eventlet to asyncio.
Users are encouraged to switch to the eventlet asyncio hub in
order to start this migration.
Please find more details at https://eventlet.readthedocs.io/en/latest/migration.html
"""
def __init__(self, clock=None):
super().__init__(clock=clock)

warnings.warn(
"""
ACTION REQUIRED: The eventlet selects hub is now deprecated and will be removed.
Users should begin planning a migration from eventlet to asyncio.
Users are encouraged to switch to the eventlet asyncio hub in
order to start this migration.
Please find more details at https://eventlet.readthedocs.io/en/latest/migration.html
""",
DeprecationWarning,
)

def _remove_bad_fds(self):
""" Iterate through fds, removing the ones that are bad per the
operating system.
Expand Down