mirror of https://github.com/celery/kombu.git
Removes kombu.utils.compat.get_errno
This commit is contained in:
parent
095ba02263
commit
f80e0c349f
|
@ -57,7 +57,6 @@
|
|||
kombu.utils
|
||||
kombu.utils.eventio
|
||||
kombu.utils.limits
|
||||
kombu.utils.compat
|
||||
kombu.utils.debug
|
||||
kombu.utils.encoding
|
||||
kombu.utils.functional
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
==========================================================
|
||||
Compat. utilities - kombu.utils.compat
|
||||
==========================================================
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
.. currentmodule:: kombu.utils.compat
|
||||
|
||||
.. automodule:: kombu.utils.compat
|
||||
:members:
|
||||
:undoc-members:
|
|
@ -20,7 +20,6 @@ from amqp import promise
|
|||
from kombu.five import Empty, range
|
||||
from kombu.log import get_logger
|
||||
from kombu.utils import cached_property, fileno
|
||||
from kombu.utils.compat import get_errno
|
||||
from kombu.utils.eventio import READ, WRITE, ERR, poll
|
||||
|
||||
from .timer import Timer
|
||||
|
@ -139,7 +138,7 @@ class Hub(object):
|
|||
except (MemoryError, AssertionError):
|
||||
raise
|
||||
except OSError as exc:
|
||||
if get_errno(exc) == errno.ENOMEM:
|
||||
if exc.errno == errno.ENOMEM:
|
||||
raise
|
||||
logger.error('Error in timer: %r', exc, exc_info=1)
|
||||
except Exception as exc:
|
||||
|
@ -313,7 +312,7 @@ class Hub(object):
|
|||
try:
|
||||
next(cb)
|
||||
except OSError as exc:
|
||||
if get_errno(exc) != errno.EBADF:
|
||||
if exc.errno != errno.EBADF:
|
||||
raise
|
||||
hub_remove(fileno)
|
||||
except StopIteration:
|
||||
|
|
|
@ -13,7 +13,6 @@ import socket
|
|||
from kombu.exceptions import ChannelError, ConnectionError
|
||||
from kombu.message import Message
|
||||
from kombu.utils import cached_property
|
||||
from kombu.utils.compat import get_errno
|
||||
|
||||
__all__ = ['Message', 'StdChannel', 'Management', 'Transport']
|
||||
|
||||
|
@ -133,8 +132,7 @@ class Transport(object):
|
|||
return True
|
||||
|
||||
def _make_reader(self, connection, timeout=socket.timeout,
|
||||
error=socket.error, get_errno=get_errno,
|
||||
_unavail=(errno.EAGAIN, errno.EINTR)):
|
||||
error=socket.error, _unavail=(errno.EAGAIN, errno.EINTR)):
|
||||
drain_events = connection.drain_events
|
||||
|
||||
def _read(loop):
|
||||
|
@ -145,7 +143,7 @@ class Transport(object):
|
|||
except timeout:
|
||||
return
|
||||
except error as exc:
|
||||
if get_errno(exc) in _unavail:
|
||||
if exc.errno in _unavail:
|
||||
return
|
||||
raise
|
||||
loop.call_soon(_read, loop)
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
"""
|
||||
kombu.utils.compat
|
||||
==================
|
||||
|
||||
Helps compatibility with older Python versions.
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
|
||||
############## socket.error.errno ############################################
|
||||
|
||||
|
||||
def get_errno(exc):
|
||||
""":exc:`socket.error` and :exc:`IOError` first got
|
||||
the ``.errno`` attribute in Py2.7"""
|
||||
try:
|
||||
return exc.errno
|
||||
except AttributeError:
|
||||
try:
|
||||
# e.args = (errno, reason)
|
||||
if isinstance(exc.args, tuple) and len(exc.args) == 2:
|
||||
return exc.args[0]
|
||||
except AttributeError:
|
||||
pass
|
||||
return 0
|
|
@ -44,7 +44,6 @@ KQ_NOTE_REVOKE = getattr(__select__, 'kQ_NOTE_REVOKE', 64)
|
|||
from kombu.syn import detect_environment
|
||||
|
||||
from . import fileno
|
||||
from .compat import get_errno
|
||||
|
||||
__all__ = ['poll']
|
||||
|
||||
|
@ -64,7 +63,7 @@ class Poller(object):
|
|||
try:
|
||||
return self._poll(timeout)
|
||||
except Exception as exc:
|
||||
if get_errno(exc) != errno.EINTR:
|
||||
if exc.errno != errno.EINTR:
|
||||
raise
|
||||
|
||||
|
||||
|
@ -77,7 +76,7 @@ class _epoll(Poller):
|
|||
try:
|
||||
self._epoll.register(fd, events)
|
||||
except Exception as exc:
|
||||
if get_errno(exc) != errno.EEXIST:
|
||||
if exc.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
def unregister(self, fd):
|
||||
|
@ -86,7 +85,7 @@ class _epoll(Poller):
|
|||
except (socket.error, ValueError, KeyError, TypeError):
|
||||
pass
|
||||
except (IOError, OSError) as exc:
|
||||
if get_errno(exc) != errno.ENOENT:
|
||||
if exc.errno != errno.ENOENT:
|
||||
raise
|
||||
|
||||
def _poll(self, timeout):
|
||||
|
@ -198,7 +197,7 @@ class _select(Poller):
|
|||
try:
|
||||
_selectf([fd], [], [], 0)
|
||||
except (_selecterr, socket.error) as exc:
|
||||
if get_errno(exc) in SELECT_BAD_FD:
|
||||
if exc.errno in SELECT_BAD_FD:
|
||||
self.unregister(fd)
|
||||
|
||||
def unregister(self, fd):
|
||||
|
@ -207,7 +206,7 @@ class _select(Poller):
|
|||
except socket.error as exc:
|
||||
# we don't know the previous fd of this object
|
||||
# but it will be removed by the next poll iteration.
|
||||
if get_errno(exc) in SELECT_BAD_FD:
|
||||
if exc.errno in SELECT_BAD_FD:
|
||||
return
|
||||
raise
|
||||
self._rfd.discard(fd)
|
||||
|
@ -220,9 +219,9 @@ class _select(Poller):
|
|||
self._rfd, self._wfd, self._efd, timeout,
|
||||
)
|
||||
except (_selecterr, socket.error) as exc:
|
||||
if get_errno(exc) == errno.EINTR:
|
||||
if exc.errno == errno.EINTR:
|
||||
return
|
||||
elif get_errno(exc) in SELECT_BAD_FD:
|
||||
elif exc.errno in SELECT_BAD_FD:
|
||||
return self._remove_bad()
|
||||
raise
|
||||
|
||||
|
|
Loading…
Reference in New Issue