make connection timeout infinite by default
removes the need for eventlet and gevent checking for timeouts PYTHON-600
This commit is contained in:
@@ -345,6 +345,7 @@ class Connection(object):
|
||||
self._socket = self._ssl_impl.wrap_socket(self._socket, **self.ssl_options)
|
||||
self._socket.settimeout(self.connect_timeout)
|
||||
self._socket.connect(sockaddr)
|
||||
self._socket.settimeout(None)
|
||||
if self._check_hostname:
|
||||
ssl.match_hostname(self._socket.getpeercert(), self.host)
|
||||
sockerr = None
|
||||
|
@@ -16,13 +16,10 @@
|
||||
# Originally derived from MagnetoDB source:
|
||||
# https://github.com/stackforge/magnetodb/blob/2015.1.0b1/magnetodb/common/cassandra/io/eventletreactor.py
|
||||
|
||||
from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, EINVAL
|
||||
import eventlet
|
||||
from eventlet.green import socket
|
||||
import ssl
|
||||
from eventlet.queue import Queue
|
||||
import logging
|
||||
import os
|
||||
from threading import Event
|
||||
import time
|
||||
|
||||
@@ -34,15 +31,6 @@ from cassandra.connection import Connection, ConnectionShutdown, Timer, TimerMan
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def is_timeout(err):
|
||||
return (
|
||||
err in (EINPROGRESS, EALREADY, EWOULDBLOCK) or
|
||||
(err == EINVAL and os.name in ('nt', 'ce')) or
|
||||
(isinstance(err, ssl.SSLError) and err.args[0] == 'timed out') or
|
||||
isinstance(err, socket.timeout)
|
||||
)
|
||||
|
||||
|
||||
class EventletConnection(Connection):
|
||||
"""
|
||||
An implementation of :class:`.Connection` that utilizes ``eventlet``.
|
||||
@@ -145,8 +133,6 @@ class EventletConnection(Connection):
|
||||
buf = self._socket.recv(self.in_buffer_size)
|
||||
self._iobuf.write(buf)
|
||||
except socket.error as err:
|
||||
if is_timeout(err):
|
||||
continue
|
||||
log.debug("Exception during socket recv for %s: %s",
|
||||
self, err)
|
||||
self.defunct(err)
|
||||
|
@@ -18,26 +18,16 @@ from gevent import socket
|
||||
import gevent.ssl
|
||||
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
|
||||
from six.moves import range
|
||||
|
||||
from errno import EINVAL
|
||||
|
||||
from cassandra.connection import Connection, ConnectionShutdown, Timer, TimerManager
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def is_timeout(err):
|
||||
return (
|
||||
(err == EINVAL and os.name in ('nt', 'ce')) or
|
||||
isinstance(err, socket.timeout)
|
||||
)
|
||||
|
||||
|
||||
class GeventConnection(Connection):
|
||||
"""
|
||||
An implementation of :class:`.Connection` that utilizes ``gevent``.
|
||||
@@ -131,11 +121,9 @@ class GeventConnection(Connection):
|
||||
buf = self._socket.recv(self.in_buffer_size)
|
||||
self._iobuf.write(buf)
|
||||
except socket.error as err:
|
||||
if not is_timeout(err):
|
||||
log.debug("Exception in read for %s: %s", self, err)
|
||||
self.defunct(err)
|
||||
return # leave the read loop
|
||||
continue
|
||||
log.debug("Exception in read for %s: %s", self, err)
|
||||
self.defunct(err)
|
||||
return # leave the read loop
|
||||
|
||||
if self._iobuf.tell():
|
||||
self.process_io_buffer()
|
||||
|
Reference in New Issue
Block a user