Fix AttributeError in __del__ for Pool(use_greenlets=True) when Gevent is not installed. PYTHON-561

This commit is contained in:
A. Jesse Jiryu Davis 2013-10-09 13:37:58 -04:00
parent 7d0240a88a
commit d38b0e1c47

View File

@ -141,12 +141,6 @@ class Pool:
# Can override for testing: 0 to always check, None to never check.
self._check_interval_seconds = 1
if use_greenlets and not thread_util.have_gevent:
raise ConfigurationError(
"The Gevent module is not available. "
"Install the gevent package from PyPI."
)
self.sockets = set()
self.lock = threading.Lock()
@ -169,11 +163,17 @@ class Pool:
if HAS_SSL and use_ssl and not ssl_cert_reqs:
self.ssl_cert_reqs = ssl.CERT_NONE
self._ident = thread_util.create_ident(use_greenlets)
# Map self._ident.get() -> request socket
self._tid_to_sock = {}
if use_greenlets and not thread_util.have_gevent:
raise ConfigurationError(
"The Gevent module is not available. "
"Install the gevent package from PyPI."
)
self._ident = thread_util.create_ident(use_greenlets)
# Count the number of calls to start_request() per thread or greenlet
self._request_counter = thread_util.Counter(use_greenlets)