/* Generated by Cython 0.22.1 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "extra_compile_args": [
            "-Wno-unused-function"
        ]
    }
}
END: Cython Metadata */

#define PY_SSIZE_T_CLEAN
#ifndef CYTHON_USE_PYLONG_INTERNALS
#ifdef PYLONG_BITS_IN_DIGIT
#define CYTHON_USE_PYLONG_INTERNALS 0
#else
#include "pyconfig.h"
#ifdef PYLONG_BITS_IN_DIGIT
#define CYTHON_USE_PYLONG_INTERNALS 1
#else
#define CYTHON_USE_PYLONG_INTERNALS 0
#endif
#endif
#endif
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
    #error Cython requires Python 2.6+ or Python 3.2+.
#else
#define CYTHON_ABI "0_22_1"
#include <stddef.h>
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
#define CYTHON_COMPILING_IN_PYPY 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
#define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ? \
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
#else
  #define CYTHON_PEP393_ENABLED 0
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
  #define __Pyx_PyFrozenSet_Size(s)         PyObject_Size(s)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  #define __Pyx_PyFrozenSet_Size(s)         PySet_Size(s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and
   a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is
   a quiet NaN. */
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#define __Pyx_void_to_None(void_result) (void_result, Py_INCREF(Py_None), Py_None)
#ifdef __cplusplus
template<typename T>
void __Pyx_call_destructor(T* x) {
    x->~T();
}
template<typename T>
class __Pyx_FakeReference {
  public:
    __Pyx_FakeReference() : ptr(NULL) { }
    __Pyx_FakeReference(T& ref) : ptr(&ref) { }
    T *operator->() { return ptr; }
    operator T&() { return *ptr; }
  private:
    T *ptr;
};
#endif


#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE__cassandra__connection
#define __PYX_HAVE_API__cassandra__connection
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif

#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (    \
    (sizeof(type) < sizeof(Py_ssize_t))  ||             \
    (sizeof(type) > sizeof(Py_ssize_t) &&               \
          likely(v < (type)PY_SSIZE_T_MAX ||            \
                 v == (type)PY_SSIZE_T_MAX)  &&         \
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||       \
                                v == (type)PY_SSIZE_T_MIN)))  ||  \
    (sizeof(type) == sizeof(Py_ssize_t) &&              \
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||        \
                               v == (type)PY_SSIZE_T_MAX)))  )
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyObject_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
#if PY_MAJOR_VERSION < 3
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
{
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#else
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
#endif
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_COMPILING_IN_CPYTHON
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */

static PyObject *__pyx_m;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "cassandra/connection.py",
};

/*--- Type declarations ---*/
struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error;
struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async;
struct __pyx_defaults;
typedef struct __pyx_defaults __pyx_defaults;
struct __pyx_defaults1;
typedef struct __pyx_defaults1 __pyx_defaults1;
struct __pyx_defaults {
  PyObject *__pyx_arg_protocol_version;
};
struct __pyx_defaults1 {
  PyObject *__pyx_arg_encoder;
  PyObject *__pyx_arg_decoder;
};

/* "cassandra/connection.py":148
 * 
 * 
 * def defunct_on_error(f):             # <<<<<<<<<<<<<<
 * 
 *     @wraps(f)
 */
struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error {
  PyObject_HEAD
  PyObject *__pyx_v_f;
};


/* "cassandra/connection.py":717
 *             raise conn_exc
 * 
 *     def set_keyspace_async(self, keyspace, callback):             # <<<<<<<<<<<<<<
 *         """
 *         Use this in order to avoid deadlocking the event loop thread.
 */
struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async {
  PyObject_HEAD
  PyObject *__pyx_v_callback;
  PyObject *__pyx_v_keyspace;
  PyObject *__pyx_v_self;
};


/* --- Runtime support code (head) --- */
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
          if (acquire_gil) { \
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
              PyGILState_Release(__pyx_gilstate_save); \
          } else { \
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext() \
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {                            \
        PyObject *tmp = (PyObject *) r;                         \
        r = v; __Pyx_XDECREF(tmp);                              \
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {                             \
        PyObject *tmp = (PyObject *) r;                         \
        r = v; __Pyx_DECREF(tmp);                               \
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

static PyObject *__Pyx_GetBuiltinName(PyObject *name);

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
        PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
        int has_cstart, int has_cstop, int wraparound);

#include <string.h>

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);

#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);

static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
    const char* function_name);

#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL)
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_setattro))
        return tp->tp_setattro(obj, attr_name, value);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_setattr))
        return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
#endif
    return PyObject_SetAttr(obj, attr_name, value);
}
#else
#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
#endif

static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb);
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb);

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);

static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

#define __Pyx_CyFunction_USED 1
#include <structmember.h>
#define __Pyx_CYFUNCTION_STATICMETHOD  0x01
#define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
#define __Pyx_CYFUNCTION_CCLASS        0x04
#define __Pyx_CyFunction_GetClosure(f) \
    (((__pyx_CyFunctionObject *) (f))->func_closure)
#define __Pyx_CyFunction_GetClassObj(f) \
    (((__pyx_CyFunctionObject *) (f))->func_classobj)
#define __Pyx_CyFunction_Defaults(type, f) \
    ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
#define __Pyx_CyFunction_SetDefaultsGetter(f, g) \
    ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
typedef struct {
    PyCFunctionObject func;
#if PY_VERSION_HEX < 0x030500A0
    PyObject *func_weakreflist;
#endif
    PyObject *func_dict;
    PyObject *func_name;
    PyObject *func_qualname;
    PyObject *func_doc;
    PyObject *func_globals;
    PyObject *func_code;
    PyObject *func_closure;
    PyObject *func_classobj;
    void *defaults;
    int defaults_pyobjects;
    int flags;
    PyObject *defaults_tuple;
    PyObject *defaults_kwdict;
    PyObject *(*defaults_getter)(PyObject *);
    PyObject *func_annotations;
} __pyx_CyFunctionObject;
static PyTypeObject *__pyx_CyFunctionType = 0;
#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code) \
    __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *self,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
                                                         size_t size,
                                                         int pyobjects);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
                                                            PyObject *tuple);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
                                                             PyObject *dict);
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
                                                              PyObject *dict);
static int __Pyx_CyFunction_init(void);

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb);

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE int __Pyx_IterFinish(void);

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len)) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
#endif

#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) : \
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000
static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) {
    PyObject *res;
    PyTypeObject *tp = Py_TYPE(obj);
#if PY_MAJOR_VERSION < 3
    if (unlikely(PyInstance_Check(obj)))
        return __Pyx_PyObject_GetAttrStr(obj, attr_name);
#endif
    res = _PyType_Lookup(tp, attr_name);
    if (likely(res)) {
        descrgetfunc f = Py_TYPE(res)->tp_descr_get;
        if (!f) {
            Py_INCREF(res);
        } else {
            res = f(res, obj, (PyObject *)tp);
        }
    } else {
        PyErr_SetObject(PyExc_AttributeError, attr_name);
    }
    return res;
}
#else
#define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n)
#endif

static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);

static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value);

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);

static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);

static CYTHON_INLINE int __Pyx_PySequence_Contains(PyObject* item, PyObject* seq, int eq) {
    int result = PySequence_Contains(seq, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);

#define __Pyx_PyObject_Pop(L) (PyList_CheckExact(L) ? \
    __Pyx_PyList_Pop(L) : __Pyx__PyObject_Pop(L))
static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L);
static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L);

static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);

static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
                                           PyObject *mkw, PyObject *modname, PyObject *doc);
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
                                      PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);

typedef struct {
    int code_line;
    PyCodeObject* code_object;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

#include "descrobject.h"
static PyObject* __Pyx_Method_ClassMethod(PyObject *method);

static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

static int __Pyx_check_binary_version(void);

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);


/* Module declarations from 'cassandra.connection' */
static PyTypeObject *__pyx_ptype_9cassandra_10connection___pyx_scope_struct__defunct_on_error = 0;
static PyTypeObject *__pyx_ptype_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async = 0;
#define __Pyx_MODULE_NAME "cassandra.connection"
int __pyx_module_is_main_cassandra__connection = 0;

/* Implementation of 'cassandra.connection' */
static PyObject *__pyx_builtin_ImportError;
static PyObject *__pyx_builtin_Exception;
static PyObject *__pyx_builtin_object;
static PyObject *__pyx_builtin_property;
static PyObject *__pyx_builtin_super;
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_id;
static PyObject *__pyx_builtin_IndexError;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_pf_9cassandra_10connection_lz4_compress(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_byts); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_2lz4_decompress(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_byts); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_4decompress(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_byts); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_19ConnectionException___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_message, PyObject *__pyx_v_host); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_26ProtocolVersionUnsupported___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_host, PyObject *__pyx_v_startup_version); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_16defunct_on_error_wrapper(PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_6defunct_on_error(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_f); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_62__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_host, PyObject *__pyx_v_port, PyObject *__pyx_v_authenticator, PyObject *__pyx_v_ssl_options, PyObject *__pyx_v_sockopts, PyObject *__pyx_v_compression, PyObject *__pyx_v_cql_version, PyObject *__pyx_v_protocol_version, PyObject *__pyx_v_is_control_connection, PyObject *__pyx_v_user_type_map); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_2initialize_reactor(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_4handle_fork(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_6create_timer(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_cls, CYTHON_UNUSED PyObject *__pyx_v_timeout, CYTHON_UNUSED PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_8factory(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_host, PyObject *__pyx_v_timeout, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_10_connect_socket(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_12close(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_14defunct(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_exc); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_16error_all_requests(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_exc); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_18get_request_id(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_20handle_pushed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_response); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_64__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_22send_msg(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_msg, PyObject *__pyx_v_request_id, PyObject *__pyx_v_cb, PyObject *__pyx_v_encoder, PyObject *__pyx_v_decoder); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_24wait_for_response(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_msg, PyObject *__pyx_v_timeout); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_26wait_for_responses(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_msgs, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_28register_watcher(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_event_type, PyObject *__pyx_v_callback, PyObject *__pyx_v_register_timeout); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_30register_watchers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_type_callback_dict, PyObject *__pyx_v_register_timeout); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_32control_conn_disposed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_34_read_frame_header(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_36_reset_frame(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_38process_io_buffer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_40process_msg(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_header, PyObject *__pyx_v_body); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_42_send_options_message(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_44_handle_options_response(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_options_response); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_46_send_startup_message(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_compression); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_48_handle_startup_response(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_startup_response, PyObject *__pyx_v_did_authenticate); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_50_handle_auth_response(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_auth_response); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_52set_keyspace_blocking(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_keyspace); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_18set_keyspace_async_process_result(PyObject *__pyx_self, PyObject *__pyx_v_result); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_54set_keyspace_async(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_keyspace, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_56is_idle(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_58reset_idle(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_10Connection_60__str__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_14ResponseWaiter___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_connection, PyObject *__pyx_v_num_responses, PyObject *__pyx_v_fail_on_error); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_14ResponseWaiter_2got_response(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_response, PyObject *__pyx_v_index); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_14ResponseWaiter_4deliver(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_15HeartbeatFuture___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_connection, PyObject *__pyx_v_owner); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_15HeartbeatFuture_2wait(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_15HeartbeatFuture_4_options_callback(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_response); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_19ConnectionHeartbeat___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_interval_sec, PyObject *__pyx_v_get_connection_holders); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_19ConnectionHeartbeat_2run(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_19ConnectionHeartbeat_4stop(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_19ConnectionHeartbeat_6_raise_if_stopped(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_5Timer___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_timeout, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_5Timer_2cancel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_5Timer_4finish(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_time_now); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_12TimerManager___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_12TimerManager_2add_timer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_timer); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_12TimerManager_4service_timeouts(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_9cassandra_10connection_12TimerManager_6next_timeout(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_tp_new_9cassandra_10connection___pyx_scope_struct__defunct_on_error(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static char __pyx_k_a[] = "a";
static char __pyx_k_f[] = "f";
static char __pyx_k_i[] = "i";
static char __pyx_k_k[] = "k";
static char __pyx_k_o[] = "o";
static char __pyx_k__4[] = "\000";
static char __pyx_k__5[] = "";
static char __pyx_k_af[] = "af";
static char __pyx_k_cb[] = "cb";
static char __pyx_k_cm[] = "cm";
static char __pyx_k_id[] = "id";
static char __pyx_k_io[] = "io";
static char __pyx_k_op[] = "op";
static char __pyx_k_sm[] = "sm";
static char __pyx_k_ONE[] = "ONE";
static char __pyx_k__67[] = "_";
static char __pyx_k_add[] = "add";
static char __pyx_k_buf[] = "buf";
static char __pyx_k_cls[] = "cls";
static char __pyx_k_doc[] = "__doc__";
static char __pyx_k_end[] = "end";
static char __pyx_k_err[] = "err";
static char __pyx_k_exc[] = "exc";
static char __pyx_k_get[] = "get";
static char __pyx_k_ire[] = "ire";
static char __pyx_k_log[] = "log";
static char __pyx_k_lz4[] = "lz4";
static char __pyx_k_msg[] = "msg";
static char __pyx_k_now[] = "now";
static char __pyx_k_pop[] = "pop";
static char __pyx_k_pos[] = "pos";
static char __pyx_k_run[] = "run";
static char __pyx_k_set[] = "set";
static char __pyx_k_six[] = "six";
static char __pyx_k_ssl[] = "ssl";
static char __pyx_k_str[] = "__str__";
static char __pyx_k_sys[] = "sys";
static char __pyx_k_BbBi[] = ">BbBi";
static char __pyx_k_BhBi[] = ">BhBi";
static char __pyx_k_args[] = "args";
static char __pyx_k_body[] = "body";
static char __pyx_k_byts[] = "byts";
static char __pyx_k_conn[] = "conn";
static char __pyx_k_exit[] = "__exit__";
static char __pyx_k_host[] = "host";
static char __pyx_k_init[] = "__init__";
static char __pyx_k_join[] = "join";
static char __pyx_k_keys[] = "keys";
static char __pyx_k_lock[] = "lock";
static char __pyx_k_main[] = "__main__";
static char __pyx_k_msgs[] = "msgs";
static char __pyx_k_name[] = "__name__";
static char __pyx_k_opts[] = "opts";
static char __pyx_k_port[] = "port";
static char __pyx_k_push[] = "push";
static char __pyx_k_read[] = "read";
static char __pyx_k_repr[] = "__repr__";
static char __pyx_k_seek[] = "seek";
static char __pyx_k_self[] = "self";
static char __pyx_k_size[] = "size";
static char __pyx_k_stop[] = "stop";
static char __pyx_k_tell[] = "tell";
static char __pyx_k_test[] = "__test__";
static char __pyx_k_time[] = "time";
static char __pyx_k_wait[] = "wait";
static char __pyx_k_3_0_0[] = "3.0.0";
static char __pyx_k_Empty[] = "Empty";
static char __pyx_k_Event[] = "Event";
static char __pyx_k_Frame[] = "_Frame";
static char __pyx_k_Queue[] = "Queue";
static char __pyx_k_RLock[] = "RLock";
static char __pyx_k_Timer[] = "Timer";
static char __pyx_k_USE_s[] = "USE \"%s\"";
static char __pyx_k_class[] = "__class__";
static char __pyx_k_close[] = "close";
static char __pyx_k_creds[] = "creds";
static char __pyx_k_debug[] = "debug";
static char __pyx_k_deque[] = "deque";
static char __pyx_k_enter[] = "__enter__";
static char __pyx_k_errno[] = "errno";
static char __pyx_k_error[] = "error";
static char __pyx_k_event[] = "event";
static char __pyx_k_flags[] = "flags";
static char __pyx_k_frame[] = "frame";
static char __pyx_k_heapq[] = "heapq";
static char __pyx_k_index[] = "index";
static char __pyx_k_iobuf[] = "_iobuf";
static char __pyx_k_items[] = "items";
static char __pyx_k_owner[] = "owner";
static char __pyx_k_proto[] = "proto";
static char __pyx_k_query[] = "query";
static char __pyx_k_queue[] = "_queue";
static char __pyx_k_range[] = "range";
static char __pyx_k_sleep[] = "sleep";
static char __pyx_k_start[] = "start";
static char __pyx_k_super[] = "super";
static char __pyx_k_timer[] = "timer";
static char __pyx_k_token[] = "token";
static char __pyx_k_wraps[] = "wraps";
static char __pyx_k_write[] = "write";
static char __pyx_k_EAGAIN[] = "EAGAIN";
static char __pyx_k_Struct[] = "Struct";
static char __pyx_k_Thread[] = "Thread";
static char __pyx_k_append[] = "append";
static char __pyx_k_cancel[] = "cancel";
static char __pyx_k_closed[] = " (closed)";
static char __pyx_k_daemon[] = "daemon";
static char __pyx_k_finish[] = "finish";
static char __pyx_k_header[] = "header";
static char __pyx_k_import[] = "__import__";
static char __pyx_k_is_set[] = "is_set";
static char __pyx_k_kwargs[] = "kwargs";
static char __pyx_k_module[] = "__module__";
static char __pyx_k_name_2[] = "name";
static char __pyx_k_needed[] = "needed";
static char __pyx_k_object[] = "object";
static char __pyx_k_opcode[] = "opcode";
static char __pyx_k_result[] = "result";
static char __pyx_k_snappy[] = "snappy";
static char __pyx_k_socket[] = "socket";
static char __pyx_k_status[] = "status";
static char __pyx_k_stream[] = "stream";
static char __pyx_k_struct[] = "struct";
static char __pyx_k_unpack[] = "unpack";
static char __pyx_k_values[] = "values";
static char __pyx_k_waiter[] = "waiter";
static char __pyx_k_BytesIO[] = "BytesIO";
static char __pyx_k_Frame_2[] = "Frame";
static char __pyx_k_connect[] = "connect";
static char __pyx_k_decoder[] = "decoder";
static char __pyx_k_defunct[] = "defunct";
static char __pyx_k_deliver[] = "deliver";
static char __pyx_k_elapsed[] = "elapsed";
static char __pyx_k_encoder[] = "encoder";
static char __pyx_k_end_pos[] = "end_pos";
static char __pyx_k_event_2[] = "_event";
static char __pyx_k_factory[] = "factory";
static char __pyx_k_futures[] = "futures";
static char __pyx_k_heappop[] = "heappop";
static char __pyx_k_is_idle[] = "is_idle";
static char __pyx_k_logging[] = "logging";
static char __pyx_k_message[] = "message";
static char __pyx_k_modules[] = "modules";
static char __pyx_k_new_exc[] = "new_exc";
static char __pyx_k_options[] = "options";
static char __pyx_k_overlap[] = "overlap";
static char __pyx_k_partial[] = "partial";
static char __pyx_k_pending[] = "pending";
static char __pyx_k_popleft[] = "popleft";
static char __pyx_k_prepare[] = "__prepare__";
static char __pyx_k_queue_2[] = "queue";
static char __pyx_k_sockerr[] = "sockerr";
static char __pyx_k_timeout[] = "timeout";
static char __pyx_k_version[] = "version";
static char __pyx_k_warning[] = "warning";
static char __pyx_k_wrapper[] = "wrapper";
static char __pyx_k_body_len[] = "body_len";
static char __pyx_k_callback[] = "callback";
static char __pyx_k_canceled[] = "canceled";
static char __pyx_k_compress[] = "compress";
static char __pyx_k_conn_exc[] = "conn_exc";
static char __pyx_k_exc_info[] = "exc_info";
static char __pyx_k_heappush[] = "heappush";
static char __pyx_k_interval[] = "_interval";
static char __pyx_k_keyspace[] = "keyspace";
static char __pyx_k_leftover[] = "leftover";
static char __pyx_k_property[] = "property";
static char __pyx_k_qualname[] = "__qualname__";
static char __pyx_k_requests[] = "_requests";
static char __pyx_k_response[] = "response";
static char __pyx_k_send_msg[] = "send_msg";
static char __pyx_k_sockaddr[] = "sockaddr";
static char __pyx_k_socket_2[] = "_socket";
static char __pyx_k_sockopts[] = "sockopts";
static char __pyx_k_socktype[] = "socktype";
static char __pyx_k_ssl_impl[] = "_ssl_impl";
static char __pyx_k_strerror[] = "strerror";
static char __pyx_k_time_now[] = "time_now";
static char __pyx_k_127_0_0_1[] = "127.0.0.1";
static char __pyx_k_AF_UNSPEC[] = "AF_UNSPEC";
static char __pyx_k_Exception[] = "Exception";
static char __pyx_k_add_timer[] = "add_timer";
static char __pyx_k_addresses[] = "addresses";
static char __pyx_k_available[] = "available";
static char __pyx_k_canonname[] = "canonname";
static char __pyx_k_cassandra[] = "cassandra";
static char __pyx_k_challenge[] = "challenge";
static char __pyx_k_defunct_2[] = " (defunct)";
static char __pyx_k_enumerate[] = "enumerate";
static char __pyx_k_exception[] = "exception";
static char __pyx_k_functools[] = "functools";
static char __pyx_k_getLogger[] = "getLogger";
static char __pyx_k_in_flight[] = "in_flight";
static char __pyx_k_is_closed[] = "is_closed";
static char __pyx_k_metaclass[] = "__metaclass__";
static char __pyx_k_responses[] = "responses";
static char __pyx_k_s_r_s_d_s[] = "<%s(%r) %s:%d%s>";
static char __pyx_k_six_moves[] = "six.moves";
static char __pyx_k_stream_id[] = "stream_id";
static char __pyx_k_threading[] = "threading";
static char __pyx_k_Connection[] = "Connection";
static char __pyx_k_IndexError[] = "IndexError";
static char __pyx_k_compressor[] = "compressor";
static char __pyx_k_connection[] = "connection";
static char __pyx_k_cqlversion[] = "cqlversion";
static char __pyx_k_decompress[] = "decompress";
static char __pyx_k_event_args[] = "event_args";
static char __pyx_k_event_list[] = "event_list";
static char __pyx_k_event_type[] = "event_type";
static char __pyx_k_int32_pack[] = "int32_pack";
static char __pyx_k_is_defunct[] = "is_defunct";
static char __pyx_k_last_error[] = "last_error";
static char __pyx_k_namedtuple[] = "namedtuple";
static char __pyx_k_new_timers[] = "_new_timers";
static char __pyx_k_request_id[] = "request_id";
static char __pyx_k_requests_2[] = "requests";
static char __pyx_k_reset_idle[] = "reset_idle";
static char __pyx_k_setsockopt[] = "setsockopt";
static char __pyx_k_settimeout[] = "settimeout";
static char __pyx_k_start_time[] = "start_time";
static char __pyx_k_COMPRESSION[] = "COMPRESSION";
static char __pyx_k_EWOULDBLOCK[] = "EWOULDBLOCK";
static char __pyx_k_ImportError[] = "ImportError";
static char __pyx_k_NONBLOCKING[] = "NONBLOCKING";
static char __pyx_k_OrderedDict[] = "OrderedDict";
static char __pyx_k_SOCK_STREAM[] = "SOCK_STREAM";
static char __pyx_k_body_offset[] = "body_offset";
static char __pyx_k_collections[] = "collections";
static char __pyx_k_compression[] = "compression";
static char __pyx_k_connections[] = "connections";
static char __pyx_k_cql_version[] = "cql_version";
static char __pyx_k_defaultdict[] = "defaultdict";
static char __pyx_k_exception_2[] = "_exception";
static char __pyx_k_getaddrinfo[] = "getaddrinfo";
static char __pyx_k_handle_fork[] = "handle_fork";
static char __pyx_k_header_size[] = "header_size";
static char __pyx_k_process_msg[] = "process_msg";
static char __pyx_k_request_ids[] = "request_ids";
static char __pyx_k_reset_frame[] = "_reset_frame";
static char __pyx_k_socket_impl[] = "_socket_impl";
static char __pyx_k_ssl_options[] = "ssl_options";
static char __pyx_k_summary_msg[] = "summary_msg";
static char __pyx_k_wrap_socket[] = "wrap_socket";
static char __pyx_k_ErrorMessage[] = "ErrorMessage";
static char __pyx_k_QueryMessage[] = "QueryMessage";
static char __pyx_k_ReadyMessage[] = "ReadyMessage";
static char __pyx_k_TimerManager[] = "TimerManager";
static char __pyx_k_Timer___init[] = "Timer.__init__";
static char __pyx_k_Timer_cancel[] = "Timer.cancel";
static char __pyx_k_Timer_finish[] = "Timer.finish";
static char __pyx_k_compressor_2[] = "_compressor";
static char __pyx_k_cql_versions[] = "cql_versions";
static char __pyx_k_create_timer[] = "create_timer";
static char __pyx_k_decompressor[] = "decompressor";
static char __pyx_k_frame_header[] = "frame_header";
static char __pyx_k_gevent_queue[] = "gevent.queue";
static char __pyx_k_got_response[] = "got_response";
static char __pyx_k_interval_sec[] = "interval_sec";
static char __pyx_k_lz4_compress[] = "lz4_compress";
static char __pyx_k_msg_received[] = "msg_received";
static char __pyx_k_new_timers_2[] = "new_timers";
static char __pyx_k_next_timeout[] = "next_timeout";
static char __pyx_k_string_types[] = "string_types";
static char __pyx_k_to_exception[] = "to_exception";
static char __pyx_k_uint8_unpack[] = "uint8_unpack";
static char __pyx_k_ProtocolError[] = "ProtocolError";
static char __pyx_k_ResultMessage[] = "ResultMessage";
static char __pyx_k_auth_response[] = "auth_response";
static char __pyx_k_authenticator[] = "authenticator";
static char __pyx_k_current_frame[] = "_current_frame";
static char __pyx_k_fail_on_error[] = "fail_on_error";
static char __pyx_k_gevent_monkey[] = "gevent.monkey";
static char __pyx_k_handle_pushed[] = "handle_pushed";
static char __pyx_k_messages_sent[] = "messages_sent";
static char __pyx_k_num_responses[] = "num_responses";
static char __pyx_k_push_watchers[] = "_push_watchers";
static char __pyx_k_user_type_map[] = "user_type_map";
static char __pyx_k_ConnectionBusy[] = "ConnectionBusy";
static char __pyx_k_OptionsMessage[] = "OptionsMessage";
static char __pyx_k_ResponseWaiter[] = "ResponseWaiter";
static char __pyx_k_StartupMessage[] = "StartupMessage";
static char __pyx_k_cassandra_util[] = "cassandra.util";
static char __pyx_k_connect_socket[] = "_connect_socket";
static char __pyx_k_decode_message[] = "decode_message";
static char __pyx_k_encode_message[] = "encode_message";
static char __pyx_k_get_request_id[] = "get_request_id";
static char __pyx_k_in_buffer_size[] = "in_buffer_size";
static char __pyx_k_lz4_decompress[] = "lz4_decompress";
static char __pyx_k_max_request_id[] = "max_request_id";
static char __pyx_k_process_result[] = "process_result";
static char __pyx_k_shutdown_event[] = "_shutdown_event";
static char __pyx_k_HeartbeatFuture[] = "HeartbeatFuture";
static char __pyx_k_ProtocolHandler[] = "ProtocolHandler";
static char __pyx_k_RegisterMessage[] = "RegisterMessage";
static char __pyx_k_connected_event[] = "connected_event";
static char __pyx_k_frame_header_v3[] = "frame_header_v3";
static char __pyx_k_get_connections[] = "get_connections";
static char __pyx_k_out_buffer_size[] = "out_buffer_size";
static char __pyx_k_six_moves_queue[] = "six.moves.queue";
static char __pyx_k_startup_version[] = "startup_version";
static char __pyx_k_Connection___str[] = "Connection.__str__";
static char __pyx_k_Connection_close[] = "Connection.close";
static char __pyx_k_ConsistencyLevel[] = "ConsistencyLevel";
static char __pyx_k_SupportedMessage[] = "SupportedMessage";
static char __pyx_k_compression_type[] = "compression_type";
static char __pyx_k_defunct_on_error[] = "defunct_on_error";
static char __pyx_k_did_authenticate[] = "did_authenticate";
static char __pyx_k_initial_response[] = "initial_response";
static char __pyx_k_options_callback[] = "_options_callback";
static char __pyx_k_options_response[] = "options_response";
static char __pyx_k_protocol_version[] = "protocol_version";
static char __pyx_k_raise_if_stopped[] = "_raise_if_stopped";
static char __pyx_k_register_timeout[] = "register_timeout";
static char __pyx_k_register_watcher[] = "register_watcher";
static char __pyx_k_service_timeouts[] = "service_timeouts";
static char __pyx_k_startup_response[] = "startup_response";
static char __pyx_k_Connection___init[] = "Connection.__init__";
static char __pyx_k_OperationTimedOut[] = "OperationTimedOut";
static char __pyx_k_ProtocolException[] = "ProtocolException";
static char __pyx_k_ShutdownException[] = "ShutdownException";
static char __pyx_k_cassandra_marshal[] = "cassandra.marshal";
static char __pyx_k_consistency_level[] = "consistency_level";
static char __pyx_k_process_io_buffer[] = "process_io_buffer";
static char __pyx_k_read_frame_header[] = "_read_frame_header";
static char __pyx_k_register_watchers[] = "register_watchers";
static char __pyx_k_return_connection[] = "return_connection";
static char __pyx_k_wait_for_response[] = "wait_for_response";
static char __pyx_k_AuthSuccessMessage[] = "AuthSuccessMessage";
static char __pyx_k_ConnectionShutdown[] = "ConnectionShutdown";
static char __pyx_k_Connection_defunct[] = "Connection.defunct";
static char __pyx_k_Connection_factory[] = "Connection.factory";
static char __pyx_k_Connection_is_idle[] = "Connection.is_idle";
static char __pyx_k_CredentialsMessage[] = "CredentialsMessage";
static char __pyx_k_cassandra_protocol[] = "cassandra.protocol";
static char __pyx_k_error_all_requests[] = "error_all_requests";
static char __pyx_k_evaluate_challenge[] = "evaluate_challenge";
static char __pyx_k_failed_connections[] = "failed_connections";
static char __pyx_k_frame_header_v1_v2[] = "frame_header_v1_v2";
static char __pyx_k_highest_request_id[] = "highest_request_id";
static char __pyx_k_initialize_reactor[] = "initialize_reactor";
static char __pyx_k_set_keyspace_async[] = "set_keyspace_async";
static char __pyx_k_type_callback_dict[] = "type_callback_dict";
static char __pyx_k_wait_for_responses[] = "wait_for_responses";
static char __pyx_k_AuthResponseMessage[] = "AuthResponseMessage";
static char __pyx_k_AuthenticateMessage[] = "AuthenticateMessage";
static char __pyx_k_ConnectionException[] = "ConnectionException";
static char __pyx_k_ConnectionHeartbeat[] = "ConnectionHeartbeat";
static char __pyx_k_Connection_send_msg[] = "Connection.send_msg";
static char __pyx_k_DEFAULT_CQL_VERSION[] = "DEFAULT_CQL_VERSION";
static char __pyx_k_NotImplementedError[] = "NotImplementedError";
static char __pyx_k_TimerManager___init[] = "TimerManager.__init__";
static char __pyx_k_authenticator_class[] = "authenticator_class";
static char __pyx_k_AuthChallengeMessage[] = "AuthChallengeMessage";
static char __pyx_k_AuthenticationFailed[] = "AuthenticationFailed";
static char __pyx_k_Connection_heartbeat[] = "Connection heartbeat";
static char __pyx_k_HeartbeatFuture_wait[] = "HeartbeatFuture.wait";
static char __pyx_k_cassandra_connection[] = "cassandra.connection";
static char __pyx_k_handle_auth_response[] = "_handle_auth_response";
static char __pyx_k_send_options_message[] = "_send_options_message";
static char __pyx_k_send_startup_message[] = "_send_startup_message";
static char __pyx_k_Connection_reset_idle[] = "Connection.reset_idle";
static char __pyx_k_HEADER_DIRECTION_MASK[] = "HEADER_DIRECTION_MASK";
static char __pyx_k_MAX_SUPPORTED_VERSION[] = "MAX_SUPPORTED_VERSION";
static char __pyx_k_PROTOCOL_VERSION_MASK[] = "PROTOCOL_VERSION_MASK";
static char __pyx_k_ResponseWaiter___init[] = "ResponseWaiter.__init__";
static char __pyx_k_control_conn_disposed[] = "control_conn_disposed";
static char __pyx_k_is_control_connection[] = "is_control_connection";
static char __pyx_k_set_keyspace_blocking[] = "set_keyspace_blocking";
static char __pyx_k_Connection_handle_fork[] = "Connection.handle_fork";
static char __pyx_k_Connection_process_msg[] = "Connection.process_msg";
static char __pyx_k_HeartbeatFuture___init[] = "HeartbeatFuture.__init__";
static char __pyx_k_ResponseWaiter_deliver[] = "ResponseWaiter.deliver";
static char __pyx_k_TimerManager_add_timer[] = "TimerManager.add_timer";
static char __pyx_k_get_connection_holders[] = "get_connection_holders";
static char __pyx_k_supported_cql_versions[] = "supported_cql_versions";
static char __pyx_k_ConnectionHeartbeat_run[] = "ConnectionHeartbeat.run";
static char __pyx_k_Connection__reset_frame[] = "Connection._reset_frame";
static char __pyx_k_Connection_create_timer[] = "Connection.create_timer";
static char __pyx_k_InvalidRequestException[] = "InvalidRequestException";
static char __pyx_k_handle_options_response[] = "_handle_options_response";
static char __pyx_k_handle_startup_response[] = "_handle_startup_response";
static char __pyx_k_ConnectionHeartbeat_stop[] = "ConnectionHeartbeat.stop";
static char __pyx_k_Connection_handle_pushed[] = "Connection.handle_pushed";
static char __pyx_k_Sent_StartupMessage_on_s[] = "Sent StartupMessage on %s";
static char __pyx_k_get_connection_holders_2[] = "_get_connection_holders";
static char __pyx_k_Connection_get_request_id[] = "Connection.get_request_id";
static char __pyx_k_Connection_to_s_is_closed[] = "Connection to %s is closed";
static char __pyx_k_TimerManager_next_timeout[] = "TimerManager.next_timeout";
static char __pyx_k_on_authentication_success[] = "on_authentication_success";
static char __pyx_k_ConnectionException___init[] = "ConnectionException.__init__";
static char __pyx_k_ConnectionHeartbeat___init[] = "ConnectionHeartbeat.__init__";
static char __pyx_k_Connection__connect_socket[] = "Connection._connect_socket";
static char __pyx_k_Connection_to_s_is_defunct[] = "Connection to %s is defunct";
static char __pyx_k_HEADER_DIRECTION_TO_CLIENT[] = "HEADER_DIRECTION_TO_CLIENT";
static char __pyx_k_ProtocolVersionUnsupported[] = "ProtocolVersionUnsupported";
static char __pyx_k_Connection_register_watcher[] = "Connection.register_watcher";
static char __pyx_k_Failed_connection_heartbeat[] = "Failed connection heartbeat";
static char __pyx_k_ResponseWaiter_got_response[] = "ResponseWaiter.got_response";
static char __pyx_k_Sending_StartupMessage_on_s[] = "Sending StartupMessage on %s";
static char __pyx_k_Connection_heartbeat_failure[] = "Connection heartbeat failure";
static char __pyx_k_Connection_process_io_buffer[] = "Connection.process_io_buffer";
static char __pyx_k_Connection_register_watchers[] = "Connection.register_watchers";
static char __pyx_k_Connection_wait_for_response[] = "Connection.wait_for_response";
static char __pyx_k_Defuncting_connection_s_to_s[] = "Defuncting connection (%s) to %s:";
static char __pyx_k_HEADER_DIRECTION_FROM_CLIENT[] = "HEADER_DIRECTION_FROM_CLIENT";
static char __pyx_k_Message_pushed_from_server_r[] = "Message pushed from server: %r";
static char __pyx_k_is_unsupported_proto_version[] = "is_unsupported_proto_version";
static char __pyx_k_unsupported_protocol_version[] = "unsupported protocol version";
static char __pyx_k_Connection__read_frame_header[] = "Connection._read_frame_header";
static char __pyx_k_Connection_error_all_requests[] = "Connection.error_all_requests";
static char __pyx_k_Connection_initialize_reactor[] = "Connection.initialize_reactor";
static char __pyx_k_Connection_set_keyspace_async[] = "Connection.set_keyspace_async";
static char __pyx_k_Connection_wait_for_responses[] = "Connection.wait_for_responses";
static char __pyx_k_Failed_to_authenticate_to_s_s[] = "Failed to authenticate to %s: %s";
static char __pyx_k_TimerManager_service_timeouts[] = "TimerManager.service_timeouts";
static char __pyx_k_remote_supported_compressions[] = "remote_supported_compressions";
static char __pyx_k_An_unrecoverable_error_was_hit[] = "\n    An unrecoverable error was hit when attempting to use a connection,\n    or the connection was already closed or defunct.\n    ";
static char __pyx_k_Connection_s_is_already_closed[] = "Connection %s is already closed";
static char __pyx_k_locally_supported_compressions[] = "locally_supported_compressions";
static char __pyx_k_An_attempt_was_made_to_send_a_m[] = "\n    An attempt was made to send a message through a :class:`.Connection` that\n    was already at the max number of in-flight operations.\n    ";
static char __pyx_k_Communication_did_not_match_the[] = "\n    Communication did not match the protocol that this driver expects.\n    ";
static char __pyx_k_Heartbeat_failed_for_connection[] = "Heartbeat failed for connection (%s) to %s";
static char __pyx_k_Not_sending_options_message_for[] = "Not sending options message for new connection(%s) to %s because compression is disabled and a cql version was not specified";
static char __pyx_k_Raised_when_a_connection_has_be[] = "\n    Raised when a connection has been marked as defunct or has been closed.\n    ";
static char __pyx_k_Received_negative_body_length_r[] = "Received negative body length: %r";
static char __pyx_k_Received_unexpected_response_to[] = "Received unexpected response to OptionsMessage: %s";
static char __pyx_k_Responding_to_auth_challenge_on[] = "Responding to auth challenge on %s";
static char __pyx_k_Sending_initial_options_message[] = "Sending initial options message for new connection (%s) to %s";
static char __pyx_k_Server_rejected_startup_message[] = "\n    Server rejected startup message due to unsupported protocol version\n    ";
static char __pyx_k_This_version_of_the_driver_does[] = "This version of the driver does not support protocol version %d";
static char __pyx_k_Timed_out_creating_connection_s[] = "Timed out creating connection (%s seconds)";
static char __pyx_k_Unsupported_protocol_version_on[] = "Unsupported protocol version on %s: %d";
static char __pyx_k_Users_adamholmberg_git_python_m[] = "/Users/adamholmberg/git/python-master/cassandra/connection.py";
static char __pyx_k_defunct_on_error_locals_wrapper[] = "defunct_on_error.<locals>.wrapper";
static char __pyx_k_Callback_handler_errored_ignorin[] = "Callback handler errored, ignoring:";
static char __pyx_k_Closing_connection_s_due_to_prot[] = "Closing connection %s due to protocol error: %s";
static char __pyx_k_ConnectionHeartbeat_ShutdownExce[] = "ConnectionHeartbeat.ShutdownException";
static char __pyx_k_ConnectionHeartbeat__raise_if_st[] = "ConnectionHeartbeat._raise_if_stopped";
static char __pyx_k_Connection__handle_auth_response[] = "Connection._handle_auth_response";
static char __pyx_k_Connection__handle_options_respo[] = "Connection._handle_options_response";
static char __pyx_k_Connection__handle_startup_respo[] = "Connection._handle_startup_response";
static char __pyx_k_Connection__send_options_message[] = "Connection._send_options_message";
static char __pyx_k_Connection__send_startup_message[] = "Connection._send_startup_message";
static char __pyx_k_Connection_control_conn_disposed[] = "Connection.control_conn_disposed";
static char __pyx_k_Connection_s_successfully_authen[] = "Connection %s successfully authenticated";
static char __pyx_k_Connection_set_keyspace_async_lo[] = "Connection.set_keyspace_async.<locals>.process_result";
static char __pyx_k_Connection_set_keyspace_blocking[] = "Connection.set_keyspace_blocking";
static char __pyx_k_Connection_to_s_was_closed_durin[] = "Connection to %s was closed during the startup handshake";
static char __pyx_k_Did_not_get_expected_SupportedMe[] = "Did not get expected SupportedMessage response; instead, got: %s";
static char __pyx_k_Error_decoding_response_from_Cas[] = "Error decoding response from Cassandra. opcode: %04x; message contents: %r";
static char __pyx_k_Exception_while_servicing_timeou[] = "Exception while servicing timeout callback: ";
static char __pyx_k_Failed_sending_heartbeat_message[] = "Failed sending heartbeat message on connection (%s) to %s";
static char __pyx_k_Failed_to_initialize_new_connect[] = "Failed to initialize new connection to %s: %s";
static char __pyx_k_Failed_to_send_heartbeat_because[] = "Failed to send heartbeat because connection 'in_flight' exceeds threshold";
static char __pyx_k_Got_AuthenticateMessage_on_new_c[] = "Got AuthenticateMessage on new connection (%s) from %s: %s";
static char __pyx_k_Got_ReadyMessage_on_new_connecti[] = "Got ReadyMessage on new connection (%s) from %s";
static char __pyx_k_HeartbeatFuture__options_callbac[] = "HeartbeatFuture._options_callback";
static char __pyx_k_Ignoring_unhandled_exception_whi[] = "Ignoring unhandled exception while erroring requests for a failed connection (%s) to host %s:";
static char __pyx_k_No_available_compression_types_s[] = "No available compression types supported on both ends. locally supported: %r. remotely supported: %r";
static char __pyx_k_Problem_while_setting_keyspace_r[] = "Problem while setting keyspace: %r";
static char __pyx_k_ProtocolVersionUnsupported___ini[] = "ProtocolVersionUnsupported.__init__";
static char __pyx_k_Pushed_event_handler_errored_ign[] = "Pushed event handler errored, ignoring:";
static char __pyx_k_Received_ErrorMessage_on_new_con[] = "Received ErrorMessage on new connection (%s) from %s: %s";
static char __pyx_k_Received_options_response_on_con[] = "Received options response on connection (%s) from %s";
static char __pyx_k_Received_options_response_on_new[] = "Received options response on new connection (%s) from %s";
static char __pyx_k_Remote_end_requires_authenticati[] = "Remote end requires authentication.";
static char __pyx_k_Sending_SASL_based_auth_response[] = "Sending SASL-based auth response on %s";
static char __pyx_k_Sending_credentials_based_auth_r[] = "Sending credentials-based auth response on %s";
static char __pyx_k_Sending_options_message_heartbea[] = "Sending options message heartbeat on idle connection (%s) %s";
static char __pyx_k_The_requested_compression_type_s[] = "The requested compression type (%s) is not supported by the Cassandra server at %s";
static char __pyx_k_This_version_of_Python_was_not_c[] = "This version of Python was not compiled with SSL support";
static char __pyx_k_Tried_connecting_to_s_Last_error[] = "Tried connecting to %s. Last error: %s";
static char __pyx_k_Unexpected_response_during_Conne[] = "Unexpected response during Connection setup: %r";
static char __pyx_k_cql_version_r_is_not_supported_b[] = "cql_version %r is not supported by remote (w/ native protocol). Supported versions: %r";
static char __pyx_k_Connection_to_s_was_closed_durin_2[] = "Connection to %s was closed during the authentication process";
static char __pyx_k_Unexpected_response_during_Conne_2[] = "Unexpected response during Connection authentication to %s: %r";
static PyObject *__pyx_kp_s_127_0_0_1;
static PyObject *__pyx_kp_s_3_0_0;
static PyObject *__pyx_n_s_AF_UNSPEC;
static PyObject *__pyx_kp_s_An_attempt_was_made_to_send_a_m;
static PyObject *__pyx_kp_s_An_unrecoverable_error_was_hit;
static PyObject *__pyx_n_s_AuthChallengeMessage;
static PyObject *__pyx_n_s_AuthResponseMessage;
static PyObject *__pyx_n_s_AuthSuccessMessage;
static PyObject *__pyx_n_s_AuthenticateMessage;
static PyObject *__pyx_n_s_AuthenticationFailed;
static PyObject *__pyx_kp_s_BbBi;
static PyObject *__pyx_kp_s_BhBi;
static PyObject *__pyx_n_s_BytesIO;
static PyObject *__pyx_n_s_COMPRESSION;
static PyObject *__pyx_kp_s_Callback_handler_errored_ignorin;
static PyObject *__pyx_kp_s_Closing_connection_s_due_to_prot;
static PyObject *__pyx_kp_s_Communication_did_not_match_the;
static PyObject *__pyx_n_s_Connection;
static PyObject *__pyx_n_s_ConnectionBusy;
static PyObject *__pyx_n_s_ConnectionException;
static PyObject *__pyx_n_s_ConnectionException___init;
static PyObject *__pyx_n_s_ConnectionHeartbeat;
static PyObject *__pyx_n_s_ConnectionHeartbeat_ShutdownExce;
static PyObject *__pyx_n_s_ConnectionHeartbeat___init;
static PyObject *__pyx_n_s_ConnectionHeartbeat__raise_if_st;
static PyObject *__pyx_n_s_ConnectionHeartbeat_run;
static PyObject *__pyx_n_s_ConnectionHeartbeat_stop;
static PyObject *__pyx_n_s_ConnectionShutdown;
static PyObject *__pyx_n_s_Connection___init;
static PyObject *__pyx_n_s_Connection___str;
static PyObject *__pyx_n_s_Connection__connect_socket;
static PyObject *__pyx_n_s_Connection__handle_auth_response;
static PyObject *__pyx_n_s_Connection__handle_options_respo;
static PyObject *__pyx_n_s_Connection__handle_startup_respo;
static PyObject *__pyx_n_s_Connection__read_frame_header;
static PyObject *__pyx_n_s_Connection__reset_frame;
static PyObject *__pyx_n_s_Connection__send_options_message;
static PyObject *__pyx_n_s_Connection__send_startup_message;
static PyObject *__pyx_n_s_Connection_close;
static PyObject *__pyx_n_s_Connection_control_conn_disposed;
static PyObject *__pyx_n_s_Connection_create_timer;
static PyObject *__pyx_n_s_Connection_defunct;
static PyObject *__pyx_n_s_Connection_error_all_requests;
static PyObject *__pyx_n_s_Connection_factory;
static PyObject *__pyx_n_s_Connection_get_request_id;
static PyObject *__pyx_n_s_Connection_handle_fork;
static PyObject *__pyx_n_s_Connection_handle_pushed;
static PyObject *__pyx_kp_s_Connection_heartbeat;
static PyObject *__pyx_kp_s_Connection_heartbeat_failure;
static PyObject *__pyx_n_s_Connection_initialize_reactor;
static PyObject *__pyx_n_s_Connection_is_idle;
static PyObject *__pyx_n_s_Connection_process_io_buffer;
static PyObject *__pyx_n_s_Connection_process_msg;
static PyObject *__pyx_n_s_Connection_register_watcher;
static PyObject *__pyx_n_s_Connection_register_watchers;
static PyObject *__pyx_n_s_Connection_reset_idle;
static PyObject *__pyx_kp_s_Connection_s_is_already_closed;
static PyObject *__pyx_kp_s_Connection_s_successfully_authen;
static PyObject *__pyx_n_s_Connection_send_msg;
static PyObject *__pyx_n_s_Connection_set_keyspace_async;
static PyObject *__pyx_n_s_Connection_set_keyspace_async_lo;
static PyObject *__pyx_n_s_Connection_set_keyspace_blocking;
static PyObject *__pyx_kp_s_Connection_to_s_is_closed;
static PyObject *__pyx_kp_s_Connection_to_s_is_defunct;
static PyObject *__pyx_kp_s_Connection_to_s_was_closed_durin;
static PyObject *__pyx_kp_s_Connection_to_s_was_closed_durin_2;
static PyObject *__pyx_n_s_Connection_wait_for_response;
static PyObject *__pyx_n_s_Connection_wait_for_responses;
static PyObject *__pyx_n_s_ConsistencyLevel;
static PyObject *__pyx_n_s_CredentialsMessage;
static PyObject *__pyx_n_s_DEFAULT_CQL_VERSION;
static PyObject *__pyx_kp_s_Defuncting_connection_s_to_s;
static PyObject *__pyx_kp_s_Did_not_get_expected_SupportedMe;
static PyObject *__pyx_n_s_EAGAIN;
static PyObject *__pyx_n_s_EWOULDBLOCK;
static PyObject *__pyx_n_s_Empty;
static PyObject *__pyx_n_s_ErrorMessage;
static PyObject *__pyx_kp_s_Error_decoding_response_from_Cas;
static PyObject *__pyx_n_s_Event;
static PyObject *__pyx_n_s_Exception;
static PyObject *__pyx_kp_s_Exception_while_servicing_timeou;
static PyObject *__pyx_kp_s_Failed_connection_heartbeat;
static PyObject *__pyx_kp_s_Failed_sending_heartbeat_message;
static PyObject *__pyx_kp_s_Failed_to_authenticate_to_s_s;
static PyObject *__pyx_kp_s_Failed_to_initialize_new_connect;
static PyObject *__pyx_kp_s_Failed_to_send_heartbeat_because;
static PyObject *__pyx_n_s_Frame;
static PyObject *__pyx_n_s_Frame_2;
static PyObject *__pyx_kp_s_Got_AuthenticateMessage_on_new_c;
static PyObject *__pyx_kp_s_Got_ReadyMessage_on_new_connecti;
static PyObject *__pyx_n_s_HEADER_DIRECTION_FROM_CLIENT;
static PyObject *__pyx_n_s_HEADER_DIRECTION_MASK;
static PyObject *__pyx_n_s_HEADER_DIRECTION_TO_CLIENT;
static PyObject *__pyx_n_s_HeartbeatFuture;
static PyObject *__pyx_n_s_HeartbeatFuture___init;
static PyObject *__pyx_n_s_HeartbeatFuture__options_callbac;
static PyObject *__pyx_n_s_HeartbeatFuture_wait;
static PyObject *__pyx_kp_s_Heartbeat_failed_for_connection;
static PyObject *__pyx_kp_s_Ignoring_unhandled_exception_whi;
static PyObject *__pyx_n_s_ImportError;
static PyObject *__pyx_n_s_IndexError;
static PyObject *__pyx_n_s_InvalidRequestException;
static PyObject *__pyx_n_s_MAX_SUPPORTED_VERSION;
static PyObject *__pyx_kp_s_Message_pushed_from_server_r;
static PyObject *__pyx_n_s_NONBLOCKING;
static PyObject *__pyx_kp_s_No_available_compression_types_s;
static PyObject *__pyx_n_s_NotImplementedError;
static PyObject *__pyx_kp_s_Not_sending_options_message_for;
static PyObject *__pyx_n_s_ONE;
static PyObject *__pyx_n_s_OperationTimedOut;
static PyObject *__pyx_n_s_OptionsMessage;
static PyObject *__pyx_n_s_OrderedDict;
static PyObject *__pyx_n_s_PROTOCOL_VERSION_MASK;
static PyObject *__pyx_kp_s_Problem_while_setting_keyspace_r;
static PyObject *__pyx_n_s_ProtocolError;
static PyObject *__pyx_n_s_ProtocolException;
static PyObject *__pyx_n_s_ProtocolHandler;
static PyObject *__pyx_n_s_ProtocolVersionUnsupported;
static PyObject *__pyx_n_s_ProtocolVersionUnsupported___ini;
static PyObject *__pyx_kp_s_Pushed_event_handler_errored_ign;
static PyObject *__pyx_n_s_QueryMessage;
static PyObject *__pyx_n_s_Queue;
static PyObject *__pyx_n_s_RLock;
static PyObject *__pyx_kp_s_Raised_when_a_connection_has_be;
static PyObject *__pyx_n_s_ReadyMessage;
static PyObject *__pyx_kp_s_Received_ErrorMessage_on_new_con;
static PyObject *__pyx_kp_s_Received_negative_body_length_r;
static PyObject *__pyx_kp_s_Received_options_response_on_con;
static PyObject *__pyx_kp_s_Received_options_response_on_new;
static PyObject *__pyx_kp_s_Received_unexpected_response_to;
static PyObject *__pyx_n_s_RegisterMessage;
static PyObject *__pyx_kp_s_Remote_end_requires_authenticati;
static PyObject *__pyx_kp_s_Responding_to_auth_challenge_on;
static PyObject *__pyx_n_s_ResponseWaiter;
static PyObject *__pyx_n_s_ResponseWaiter___init;
static PyObject *__pyx_n_s_ResponseWaiter_deliver;
static PyObject *__pyx_n_s_ResponseWaiter_got_response;
static PyObject *__pyx_n_s_ResultMessage;
static PyObject *__pyx_n_s_SOCK_STREAM;
static PyObject *__pyx_kp_s_Sending_SASL_based_auth_response;
static PyObject *__pyx_kp_s_Sending_StartupMessage_on_s;
static PyObject *__pyx_kp_s_Sending_credentials_based_auth_r;
static PyObject *__pyx_kp_s_Sending_initial_options_message;
static PyObject *__pyx_kp_s_Sending_options_message_heartbea;
static PyObject *__pyx_kp_s_Sent_StartupMessage_on_s;
static PyObject *__pyx_kp_s_Server_rejected_startup_message;
static PyObject *__pyx_n_s_ShutdownException;
static PyObject *__pyx_n_s_StartupMessage;
static PyObject *__pyx_n_s_Struct;
static PyObject *__pyx_n_s_SupportedMessage;
static PyObject *__pyx_kp_s_The_requested_compression_type_s;
static PyObject *__pyx_kp_s_This_version_of_Python_was_not_c;
static PyObject *__pyx_kp_s_This_version_of_the_driver_does;
static PyObject *__pyx_n_s_Thread;
static PyObject *__pyx_kp_s_Timed_out_creating_connection_s;
static PyObject *__pyx_n_s_Timer;
static PyObject *__pyx_n_s_TimerManager;
static PyObject *__pyx_n_s_TimerManager___init;
static PyObject *__pyx_n_s_TimerManager_add_timer;
static PyObject *__pyx_n_s_TimerManager_next_timeout;
static PyObject *__pyx_n_s_TimerManager_service_timeouts;
static PyObject *__pyx_n_s_Timer___init;
static PyObject *__pyx_n_s_Timer_cancel;
static PyObject *__pyx_n_s_Timer_finish;
static PyObject *__pyx_kp_s_Tried_connecting_to_s_Last_error;
static PyObject *__pyx_kp_s_USE_s;
static PyObject *__pyx_kp_s_Unexpected_response_during_Conne;
static PyObject *__pyx_kp_s_Unexpected_response_during_Conne_2;
static PyObject *__pyx_kp_s_Unsupported_protocol_version_on;
static PyObject *__pyx_kp_s_Users_adamholmberg_git_python_m;
static PyObject *__pyx_kp_s__4;
static PyObject *__pyx_kp_s__5;
static PyObject *__pyx_n_s__67;
static PyObject *__pyx_n_s_a;
static PyObject *__pyx_n_s_add;
static PyObject *__pyx_n_s_add_timer;
static PyObject *__pyx_n_s_addresses;
static PyObject *__pyx_n_s_af;
static PyObject *__pyx_n_s_append;
static PyObject *__pyx_n_s_args;
static PyObject *__pyx_n_s_auth_response;
static PyObject *__pyx_n_s_authenticator;
static PyObject *__pyx_n_s_authenticator_class;
static PyObject *__pyx_n_s_available;
static PyObject *__pyx_n_s_body;
static PyObject *__pyx_n_s_body_len;
static PyObject *__pyx_n_s_body_offset;
static PyObject *__pyx_n_s_buf;
static PyObject *__pyx_n_s_byts;
static PyObject *__pyx_n_s_callback;
static PyObject *__pyx_n_s_cancel;
static PyObject *__pyx_n_s_canceled;
static PyObject *__pyx_n_s_canonname;
static PyObject *__pyx_n_s_cassandra;
static PyObject *__pyx_n_s_cassandra_connection;
static PyObject *__pyx_n_s_cassandra_marshal;
static PyObject *__pyx_n_s_cassandra_protocol;
static PyObject *__pyx_n_s_cassandra_util;
static PyObject *__pyx_n_s_cb;
static PyObject *__pyx_n_s_challenge;
static PyObject *__pyx_n_s_class;
static PyObject *__pyx_n_s_close;
static PyObject *__pyx_kp_s_closed;
static PyObject *__pyx_n_s_cls;
static PyObject *__pyx_n_s_cm;
static PyObject *__pyx_n_s_collections;
static PyObject *__pyx_n_s_compress;
static PyObject *__pyx_n_s_compression;
static PyObject *__pyx_n_s_compression_type;
static PyObject *__pyx_n_s_compressor;
static PyObject *__pyx_n_s_compressor_2;
static PyObject *__pyx_n_s_conn;
static PyObject *__pyx_n_s_conn_exc;
static PyObject *__pyx_n_s_connect;
static PyObject *__pyx_n_s_connect_socket;
static PyObject *__pyx_n_s_connected_event;
static PyObject *__pyx_n_s_connection;
static PyObject *__pyx_n_s_connections;
static PyObject *__pyx_n_s_consistency_level;
static PyObject *__pyx_n_s_control_conn_disposed;
static PyObject *__pyx_n_s_cql_version;
static PyObject *__pyx_kp_s_cql_version_r_is_not_supported_b;
static PyObject *__pyx_n_s_cql_versions;
static PyObject *__pyx_n_s_cqlversion;
static PyObject *__pyx_n_s_create_timer;
static PyObject *__pyx_n_s_creds;
static PyObject *__pyx_n_s_current_frame;
static PyObject *__pyx_n_s_daemon;
static PyObject *__pyx_n_s_debug;
static PyObject *__pyx_n_s_decode_message;
static PyObject *__pyx_n_s_decoder;
static PyObject *__pyx_n_s_decompress;
static PyObject *__pyx_n_s_decompressor;
static PyObject *__pyx_n_s_defaultdict;
static PyObject *__pyx_n_s_defunct;
static PyObject *__pyx_kp_s_defunct_2;
static PyObject *__pyx_n_s_defunct_on_error;
static PyObject *__pyx_n_s_defunct_on_error_locals_wrapper;
static PyObject *__pyx_n_s_deliver;
static PyObject *__pyx_n_s_deque;
static PyObject *__pyx_n_s_did_authenticate;
static PyObject *__pyx_n_s_doc;
static PyObject *__pyx_n_s_elapsed;
static PyObject *__pyx_n_s_encode_message;
static PyObject *__pyx_n_s_encoder;
static PyObject *__pyx_n_s_end;
static PyObject *__pyx_n_s_end_pos;
static PyObject *__pyx_n_s_enter;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_n_s_err;
static PyObject *__pyx_n_s_errno;
static PyObject *__pyx_n_s_error;
static PyObject *__pyx_n_s_error_all_requests;
static PyObject *__pyx_n_s_evaluate_challenge;
static PyObject *__pyx_n_s_event;
static PyObject *__pyx_n_s_event_2;
static PyObject *__pyx_n_s_event_args;
static PyObject *__pyx_n_s_event_list;
static PyObject *__pyx_n_s_event_type;
static PyObject *__pyx_n_s_exc;
static PyObject *__pyx_n_s_exc_info;
static PyObject *__pyx_n_s_exception;
static PyObject *__pyx_n_s_exception_2;
static PyObject *__pyx_n_s_exit;
static PyObject *__pyx_n_s_f;
static PyObject *__pyx_n_s_factory;
static PyObject *__pyx_n_s_fail_on_error;
static PyObject *__pyx_n_s_failed_connections;
static PyObject *__pyx_n_s_finish;
static PyObject *__pyx_n_s_flags;
static PyObject *__pyx_n_s_frame;
static PyObject *__pyx_n_s_frame_header;
static PyObject *__pyx_n_s_frame_header_v1_v2;
static PyObject *__pyx_n_s_frame_header_v3;
static PyObject *__pyx_n_s_functools;
static PyObject *__pyx_n_s_futures;
static PyObject *__pyx_n_s_get;
static PyObject *__pyx_n_s_getLogger;
static PyObject *__pyx_n_s_get_connection_holders;
static PyObject *__pyx_n_s_get_connection_holders_2;
static PyObject *__pyx_n_s_get_connections;
static PyObject *__pyx_n_s_get_request_id;
static PyObject *__pyx_n_s_getaddrinfo;
static PyObject *__pyx_kp_s_gevent_monkey;
static PyObject *__pyx_n_s_gevent_queue;
static PyObject *__pyx_n_s_got_response;
static PyObject *__pyx_n_s_handle_auth_response;
static PyObject *__pyx_n_s_handle_fork;
static PyObject *__pyx_n_s_handle_options_response;
static PyObject *__pyx_n_s_handle_pushed;
static PyObject *__pyx_n_s_handle_startup_response;
static PyObject *__pyx_n_s_header;
static PyObject *__pyx_n_s_header_size;
static PyObject *__pyx_n_s_heappop;
static PyObject *__pyx_n_s_heappush;
static PyObject *__pyx_n_s_heapq;
static PyObject *__pyx_n_s_highest_request_id;
static PyObject *__pyx_n_s_host;
static PyObject *__pyx_n_s_i;
static PyObject *__pyx_n_s_id;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_in_buffer_size;
static PyObject *__pyx_n_s_in_flight;
static PyObject *__pyx_n_s_index;
static PyObject *__pyx_n_s_init;
static PyObject *__pyx_n_s_initial_response;
static PyObject *__pyx_n_s_initialize_reactor;
static PyObject *__pyx_n_s_int32_pack;
static PyObject *__pyx_n_s_interval;
static PyObject *__pyx_n_s_interval_sec;
static PyObject *__pyx_n_s_io;
static PyObject *__pyx_n_s_iobuf;
static PyObject *__pyx_n_s_ire;
static PyObject *__pyx_n_s_is_closed;
static PyObject *__pyx_n_s_is_control_connection;
static PyObject *__pyx_n_s_is_defunct;
static PyObject *__pyx_n_s_is_idle;
static PyObject *__pyx_n_s_is_set;
static PyObject *__pyx_n_s_is_unsupported_proto_version;
static PyObject *__pyx_n_s_items;
static PyObject *__pyx_n_s_join;
static PyObject *__pyx_n_s_k;
static PyObject *__pyx_n_s_keys;
static PyObject *__pyx_n_s_keyspace;
static PyObject *__pyx_n_s_kwargs;
static PyObject *__pyx_n_s_last_error;
static PyObject *__pyx_n_s_leftover;
static PyObject *__pyx_n_s_locally_supported_compressions;
static PyObject *__pyx_n_s_lock;
static PyObject *__pyx_n_s_log;
static PyObject *__pyx_n_s_logging;
static PyObject *__pyx_n_s_lz4;
static PyObject *__pyx_n_s_lz4_compress;
static PyObject *__pyx_n_s_lz4_decompress;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_max_request_id;
static PyObject *__pyx_n_s_message;
static PyObject *__pyx_n_s_messages_sent;
static PyObject *__pyx_n_s_metaclass;
static PyObject *__pyx_n_s_module;
static PyObject *__pyx_n_s_modules;
static PyObject *__pyx_n_s_msg;
static PyObject *__pyx_n_s_msg_received;
static PyObject *__pyx_n_s_msgs;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_name_2;
static PyObject *__pyx_n_s_namedtuple;
static PyObject *__pyx_n_s_needed;
static PyObject *__pyx_n_s_new_exc;
static PyObject *__pyx_n_s_new_timers;
static PyObject *__pyx_n_s_new_timers_2;
static PyObject *__pyx_n_s_next_timeout;
static PyObject *__pyx_n_s_now;
static PyObject *__pyx_n_s_num_responses;
static PyObject *__pyx_n_s_o;
static PyObject *__pyx_n_s_object;
static PyObject *__pyx_n_s_on_authentication_success;
static PyObject *__pyx_n_s_op;
static PyObject *__pyx_n_s_opcode;
static PyObject *__pyx_n_s_options;
static PyObject *__pyx_n_s_options_callback;
static PyObject *__pyx_n_s_options_response;
static PyObject *__pyx_n_s_opts;
static PyObject *__pyx_n_s_out_buffer_size;
static PyObject *__pyx_n_s_overlap;
static PyObject *__pyx_n_s_owner;
static PyObject *__pyx_n_s_partial;
static PyObject *__pyx_n_s_pending;
static PyObject *__pyx_n_s_pop;
static PyObject *__pyx_n_s_popleft;
static PyObject *__pyx_n_s_port;
static PyObject *__pyx_n_s_pos;
static PyObject *__pyx_n_s_prepare;
static PyObject *__pyx_n_s_process_io_buffer;
static PyObject *__pyx_n_s_process_msg;
static PyObject *__pyx_n_s_process_result;
static PyObject *__pyx_n_s_property;
static PyObject *__pyx_n_s_proto;
static PyObject *__pyx_n_s_protocol_version;
static PyObject *__pyx_n_s_push;
static PyObject *__pyx_n_s_push_watchers;
static PyObject *__pyx_n_s_qualname;
static PyObject *__pyx_n_s_query;
static PyObject *__pyx_n_s_queue;
static PyObject *__pyx_n_s_queue_2;
static PyObject *__pyx_n_s_raise_if_stopped;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_read;
static PyObject *__pyx_n_s_read_frame_header;
static PyObject *__pyx_n_s_register_timeout;
static PyObject *__pyx_n_s_register_watcher;
static PyObject *__pyx_n_s_register_watchers;
static PyObject *__pyx_n_s_remote_supported_compressions;
static PyObject *__pyx_n_s_repr;
static PyObject *__pyx_n_s_request_id;
static PyObject *__pyx_n_s_request_ids;
static PyObject *__pyx_n_s_requests;
static PyObject *__pyx_n_s_requests_2;
static PyObject *__pyx_n_s_reset_frame;
static PyObject *__pyx_n_s_reset_idle;
static PyObject *__pyx_n_s_response;
static PyObject *__pyx_n_s_responses;
static PyObject *__pyx_n_s_result;
static PyObject *__pyx_n_s_return_connection;
static PyObject *__pyx_n_s_run;
static PyObject *__pyx_kp_s_s_r_s_d_s;
static PyObject *__pyx_n_s_seek;
static PyObject *__pyx_n_s_self;
static PyObject *__pyx_n_s_send_msg;
static PyObject *__pyx_n_s_send_options_message;
static PyObject *__pyx_n_s_send_startup_message;
static PyObject *__pyx_n_s_service_timeouts;
static PyObject *__pyx_n_s_set;
static PyObject *__pyx_n_s_set_keyspace_async;
static PyObject *__pyx_n_s_set_keyspace_blocking;
static PyObject *__pyx_n_s_setsockopt;
static PyObject *__pyx_n_s_settimeout;
static PyObject *__pyx_n_s_shutdown_event;
static PyObject *__pyx_n_s_six;
static PyObject *__pyx_n_s_six_moves;
static PyObject *__pyx_n_s_six_moves_queue;
static PyObject *__pyx_n_s_size;
static PyObject *__pyx_n_s_sleep;
static PyObject *__pyx_n_s_sm;
static PyObject *__pyx_n_s_snappy;
static PyObject *__pyx_n_s_sockaddr;
static PyObject *__pyx_n_s_sockerr;
static PyObject *__pyx_n_s_socket;
static PyObject *__pyx_n_s_socket_2;
static PyObject *__pyx_n_s_socket_impl;
static PyObject *__pyx_n_s_sockopts;
static PyObject *__pyx_n_s_socktype;
static PyObject *__pyx_n_s_ssl;
static PyObject *__pyx_n_s_ssl_impl;
static PyObject *__pyx_n_s_ssl_options;
static PyObject *__pyx_n_s_start;
static PyObject *__pyx_n_s_start_time;
static PyObject *__pyx_n_s_startup_response;
static PyObject *__pyx_n_s_startup_version;
static PyObject *__pyx_n_s_status;
static PyObject *__pyx_n_s_stop;
static PyObject *__pyx_n_s_str;
static PyObject *__pyx_n_s_stream;
static PyObject *__pyx_n_s_stream_id;
static PyObject *__pyx_n_s_strerror;
static PyObject *__pyx_n_s_string_types;
static PyObject *__pyx_n_s_struct;
static PyObject *__pyx_n_s_summary_msg;
static PyObject *__pyx_n_s_super;
static PyObject *__pyx_n_s_supported_cql_versions;
static PyObject *__pyx_n_s_sys;
static PyObject *__pyx_n_s_tell;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_threading;
static PyObject *__pyx_n_s_time;
static PyObject *__pyx_n_s_time_now;
static PyObject *__pyx_n_s_timeout;
static PyObject *__pyx_n_s_timer;
static PyObject *__pyx_n_s_to_exception;
static PyObject *__pyx_n_s_token;
static PyObject *__pyx_n_s_type_callback_dict;
static PyObject *__pyx_n_s_uint8_unpack;
static PyObject *__pyx_n_s_unpack;
static PyObject *__pyx_kp_s_unsupported_protocol_version;
static PyObject *__pyx_n_s_user_type_map;
static PyObject *__pyx_n_s_values;
static PyObject *__pyx_n_s_version;
static PyObject *__pyx_n_s_wait;
static PyObject *__pyx_n_s_wait_for_response;
static PyObject *__pyx_n_s_wait_for_responses;
static PyObject *__pyx_n_s_waiter;
static PyObject *__pyx_n_s_warning;
static PyObject *__pyx_n_s_wrap_socket;
static PyObject *__pyx_n_s_wrapper;
static PyObject *__pyx_n_s_wraps;
static PyObject *__pyx_n_s_write;
static PyObject *__pyx_float_0_0;
static PyObject *__pyx_float_1_0;
static PyObject *__pyx_float_0_01;
static PyObject *__pyx_float_0_001;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_4;
static PyObject *__pyx_int_127;
static PyObject *__pyx_int_128;
static PyObject *__pyx_int_299;
static PyObject *__pyx_int_300;
static PyObject *__pyx_int_4096;
static PyObject *__pyx_int_9042;
static PyObject *__pyx_int_32767;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_slice_;
static PyObject *__pyx_slice__2;
static PyObject *__pyx_slice__3;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__13;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__19;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__22;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__27;
static PyObject *__pyx_tuple__28;
static PyObject *__pyx_tuple__29;
static PyObject *__pyx_tuple__30;
static PyObject *__pyx_tuple__31;
static PyObject *__pyx_tuple__32;
static PyObject *__pyx_tuple__33;
static PyObject *__pyx_tuple__34;
static PyObject *__pyx_tuple__36;
static PyObject *__pyx_tuple__38;
static PyObject *__pyx_tuple__40;
static PyObject *__pyx_tuple__41;
static PyObject *__pyx_tuple__42;
static PyObject *__pyx_tuple__43;
static PyObject *__pyx_tuple__44;
static PyObject *__pyx_tuple__46;
static PyObject *__pyx_tuple__47;
static PyObject *__pyx_tuple__49;
static PyObject *__pyx_tuple__51;
static PyObject *__pyx_tuple__53;
static PyObject *__pyx_tuple__55;
static PyObject *__pyx_tuple__57;
static PyObject *__pyx_tuple__59;
static PyObject *__pyx_tuple__61;
static PyObject *__pyx_tuple__63;
static PyObject *__pyx_tuple__65;
static PyObject *__pyx_tuple__68;
static PyObject *__pyx_tuple__70;
static PyObject *__pyx_tuple__72;
static PyObject *__pyx_tuple__74;
static PyObject *__pyx_tuple__76;
static PyObject *__pyx_tuple__78;
static PyObject *__pyx_tuple__79;
static PyObject *__pyx_tuple__81;
static PyObject *__pyx_tuple__83;
static PyObject *__pyx_tuple__84;
static PyObject *__pyx_tuple__86;
static PyObject *__pyx_tuple__87;
static PyObject *__pyx_tuple__89;
static PyObject *__pyx_tuple__91;
static PyObject *__pyx_tuple__93;
static PyObject *__pyx_tuple__95;
static PyObject *__pyx_tuple__97;
static PyObject *__pyx_tuple__99;
static PyObject *__pyx_codeobj__7;
static PyObject *__pyx_tuple__101;
static PyObject *__pyx_tuple__103;
static PyObject *__pyx_tuple__104;
static PyObject *__pyx_tuple__106;
static PyObject *__pyx_tuple__107;
static PyObject *__pyx_tuple__109;
static PyObject *__pyx_tuple__111;
static PyObject *__pyx_tuple__113;
static PyObject *__pyx_tuple__115;
static PyObject *__pyx_tuple__117;
static PyObject *__pyx_tuple__119;
static PyObject *__pyx_tuple__121;
static PyObject *__pyx_tuple__123;
static PyObject *__pyx_tuple__125;
static PyObject *__pyx_tuple__126;
static PyObject *__pyx_tuple__128;
static PyObject *__pyx_tuple__130;
static PyObject *__pyx_tuple__132;
static PyObject *__pyx_tuple__134;
static PyObject *__pyx_tuple__136;
static PyObject *__pyx_tuple__138;
static PyObject *__pyx_tuple__140;
static PyObject *__pyx_tuple__142;
static PyObject *__pyx_tuple__144;
static PyObject *__pyx_tuple__146;
static PyObject *__pyx_tuple__148;
static PyObject *__pyx_tuple__150;
static PyObject *__pyx_tuple__152;
static PyObject *__pyx_codeobj__23;
static PyObject *__pyx_codeobj__35;
static PyObject *__pyx_codeobj__37;
static PyObject *__pyx_codeobj__39;
static PyObject *__pyx_codeobj__45;
static PyObject *__pyx_codeobj__48;
static PyObject *__pyx_codeobj__50;
static PyObject *__pyx_codeobj__52;
static PyObject *__pyx_codeobj__54;
static PyObject *__pyx_codeobj__56;
static PyObject *__pyx_codeobj__58;
static PyObject *__pyx_codeobj__60;
static PyObject *__pyx_codeobj__62;
static PyObject *__pyx_codeobj__64;
static PyObject *__pyx_codeobj__66;
static PyObject *__pyx_codeobj__69;
static PyObject *__pyx_codeobj__71;
static PyObject *__pyx_codeobj__73;
static PyObject *__pyx_codeobj__75;
static PyObject *__pyx_codeobj__77;
static PyObject *__pyx_codeobj__80;
static PyObject *__pyx_codeobj__82;
static PyObject *__pyx_codeobj__85;
static PyObject *__pyx_codeobj__88;
static PyObject *__pyx_codeobj__90;
static PyObject *__pyx_codeobj__92;
static PyObject *__pyx_codeobj__94;
static PyObject *__pyx_codeobj__96;
static PyObject *__pyx_codeobj__98;
static PyObject *__pyx_codeobj__100;
static PyObject *__pyx_codeobj__102;
static PyObject *__pyx_codeobj__105;
static PyObject *__pyx_codeobj__108;
static PyObject *__pyx_codeobj__110;
static PyObject *__pyx_codeobj__112;
static PyObject *__pyx_codeobj__114;
static PyObject *__pyx_codeobj__116;
static PyObject *__pyx_codeobj__118;
static PyObject *__pyx_codeobj__120;
static PyObject *__pyx_codeobj__122;
static PyObject *__pyx_codeobj__124;
static PyObject *__pyx_codeobj__127;
static PyObject *__pyx_codeobj__129;
static PyObject *__pyx_codeobj__131;
static PyObject *__pyx_codeobj__133;
static PyObject *__pyx_codeobj__135;
static PyObject *__pyx_codeobj__137;
static PyObject *__pyx_codeobj__139;
static PyObject *__pyx_codeobj__141;
static PyObject *__pyx_codeobj__143;
static PyObject *__pyx_codeobj__145;
static PyObject *__pyx_codeobj__147;
static PyObject *__pyx_codeobj__149;
static PyObject *__pyx_codeobj__151;
static PyObject *__pyx_codeobj__153;

/* "cassandra/connection.py":70
 *     # functions to handle that
 * 
 *     def lz4_compress(byts):             # <<<<<<<<<<<<<<
 *         # write length in big-endian instead of little-endian
 *         return int32_pack(len(byts)) + lz4.compress(byts)[4:]
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_1lz4_compress(PyObject *__pyx_self, PyObject *__pyx_v_byts); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_1lz4_compress = {"lz4_compress", (PyCFunction)__pyx_pw_9cassandra_10connection_1lz4_compress, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_1lz4_compress(PyObject *__pyx_self, PyObject *__pyx_v_byts) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lz4_compress (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_lz4_compress(__pyx_self, ((PyObject *)__pyx_v_byts));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_lz4_compress(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_byts) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lz4_compress", 0);

  /* "cassandra/connection.py":72
 *     def lz4_compress(byts):
 *         # write length in big-endian instead of little-endian
 *         return int32_pack(len(byts)) + lz4.compress(byts)[4:]             # <<<<<<<<<<<<<<
 * 
 *     def lz4_decompress(byts):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_int32_pack); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_Length(__pyx_v_byts); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_lz4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_compress); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_byts); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
    __Pyx_INCREF(__pyx_v_byts);
    __Pyx_GIVEREF(__pyx_v_byts);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_byts);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_t_2, 4, 0, NULL, NULL, &__pyx_slice_, 1, 0, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cassandra/connection.py":70
 *     # functions to handle that
 * 
 *     def lz4_compress(byts):             # <<<<<<<<<<<<<<
 *         # write length in big-endian instead of little-endian
 *         return int32_pack(len(byts)) + lz4.compress(byts)[4:]
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cassandra.connection.lz4_compress", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":74
 *         return int32_pack(len(byts)) + lz4.compress(byts)[4:]
 * 
 *     def lz4_decompress(byts):             # <<<<<<<<<<<<<<
 *         # flip from big-endian to little-endian
 *         return lz4.decompress(byts[3::-1] + byts[4:])
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_3lz4_decompress(PyObject *__pyx_self, PyObject *__pyx_v_byts); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_3lz4_decompress = {"lz4_decompress", (PyCFunction)__pyx_pw_9cassandra_10connection_3lz4_decompress, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_3lz4_decompress(PyObject *__pyx_self, PyObject *__pyx_v_byts) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lz4_decompress (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_2lz4_decompress(__pyx_self, ((PyObject *)__pyx_v_byts));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_2lz4_decompress(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_byts) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lz4_decompress", 0);

  /* "cassandra/connection.py":76
 *     def lz4_decompress(byts):
 *         # flip from big-endian to little-endian
 *         return lz4.decompress(byts[3::-1] + byts[4:])             # <<<<<<<<<<<<<<
 * 
 *     locally_supported_compressions['lz4'] = (lz4_compress, lz4_decompress)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_lz4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_decompress); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetItem(__pyx_v_byts, __pyx_slice__2); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_byts, 4, 0, NULL, NULL, &__pyx_slice__3, 1, 0, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyNumber_Add(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cassandra/connection.py":74
 *         return int32_pack(len(byts)) + lz4.compress(byts)[4:]
 * 
 *     def lz4_decompress(byts):             # <<<<<<<<<<<<<<
 *         # flip from big-endian to little-endian
 *         return lz4.decompress(byts[3::-1] + byts[4:])
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cassandra.connection.lz4_decompress", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":86
 * else:
 *     # work around apparently buggy snappy decompress
 *     def decompress(byts):             # <<<<<<<<<<<<<<
 *         if byts == '\x00':
 *             return ''
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_5decompress(PyObject *__pyx_self, PyObject *__pyx_v_byts); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_5decompress = {"decompress", (PyCFunction)__pyx_pw_9cassandra_10connection_5decompress, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_5decompress(PyObject *__pyx_self, PyObject *__pyx_v_byts) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("decompress (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_4decompress(__pyx_self, ((PyObject *)__pyx_v_byts));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_4decompress(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_byts) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("decompress", 0);

  /* "cassandra/connection.py":87
 *     # work around apparently buggy snappy decompress
 *     def decompress(byts):
 *         if byts == '\x00':             # <<<<<<<<<<<<<<
 *             return ''
 *         return snappy.decompress(byts)
 */
  __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_byts, __pyx_kp_s__4, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "cassandra/connection.py":88
 *     def decompress(byts):
 *         if byts == '\x00':
 *             return ''             # <<<<<<<<<<<<<<
 *         return snappy.decompress(byts)
 *     locally_supported_compressions['snappy'] = (snappy.compress, decompress)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_kp_s__5);
    __pyx_r = __pyx_kp_s__5;
    goto __pyx_L0;
  }

  /* "cassandra/connection.py":89
 *         if byts == '\x00':
 *             return ''
 *         return snappy.decompress(byts)             # <<<<<<<<<<<<<<
 *     locally_supported_compressions['snappy'] = (snappy.compress, decompress)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_snappy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_decompress); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_byts); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_byts);
    __Pyx_GIVEREF(__pyx_v_byts);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_byts);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "cassandra/connection.py":86
 * else:
 *     # work around apparently buggy snappy decompress
 *     def decompress(byts):             # <<<<<<<<<<<<<<
 *         if byts == '\x00':
 *             return ''
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cassandra.connection.decompress", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":113
 *     """
 * 
 *     def __init__(self, message, host=None):             # <<<<<<<<<<<<<<
 *         Exception.__init__(self, message)
 *         self.host = host
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_19ConnectionException_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_19ConnectionException_1__init__ = {"__init__", (PyCFunction)__pyx_pw_9cassandra_10connection_19ConnectionException_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_19ConnectionException_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_message = 0;
  PyObject *__pyx_v_host = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_message,&__pyx_n_s_host,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_host);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_message = values[1];
    __pyx_v_host = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.ConnectionException.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_19ConnectionException___init__(__pyx_self, __pyx_v_self, __pyx_v_message, __pyx_v_host);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_19ConnectionException___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_message, PyObject *__pyx_v_host) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cassandra/connection.py":114
 * 
 *     def __init__(self, message, host=None):
 *         Exception.__init__(self, message)             # <<<<<<<<<<<<<<
 *         self.host = host
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_builtin_Exception, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_3) {
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  }
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_self);
  __Pyx_INCREF(__pyx_v_message);
  __Pyx_GIVEREF(__pyx_v_message);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_message);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":115
 *     def __init__(self, message, host=None):
 *         Exception.__init__(self, message)
 *         self.host = host             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_host, __pyx_v_host) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":113
 *     """
 * 
 *     def __init__(self, message, host=None):             # <<<<<<<<<<<<<<
 *         Exception.__init__(self, message)
 *         self.host = host
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cassandra.connection.ConnectionException.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":128
 *     Server rejected startup message due to unsupported protocol version
 *     """
 *     def __init__(self, host, startup_version):             # <<<<<<<<<<<<<<
 *         super(ProtocolVersionUnsupported, self).__init__("Unsupported protocol version on %s: %d",
 *                                                          (host, startup_version))
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_26ProtocolVersionUnsupported_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_26ProtocolVersionUnsupported_1__init__ = {"__init__", (PyCFunction)__pyx_pw_9cassandra_10connection_26ProtocolVersionUnsupported_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_26ProtocolVersionUnsupported_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_host = 0;
  PyObject *__pyx_v_startup_version = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_host,&__pyx_n_s_startup_version,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_host)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_startup_version)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_host = values[1];
    __pyx_v_startup_version = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.ProtocolVersionUnsupported.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_26ProtocolVersionUnsupported___init__(__pyx_self, __pyx_v_self, __pyx_v_host, __pyx_v_startup_version);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_26ProtocolVersionUnsupported___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_host, PyObject *__pyx_v_startup_version) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cassandra/connection.py":129
 *     """
 *     def __init__(self, host, startup_version):
 *         super(ProtocolVersionUnsupported, self).__init__("Unsupported protocol version on %s: %d",             # <<<<<<<<<<<<<<
 *                                                          (host, startup_version))
 *         self.startup_version = startup_version
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_ProtocolVersionUnsupported); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_init); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":130
 *     def __init__(self, host, startup_version):
 *         super(ProtocolVersionUnsupported, self).__init__("Unsupported protocol version on %s: %d",
 *                                                          (host, startup_version))             # <<<<<<<<<<<<<<
 *         self.startup_version = startup_version
 * 
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_host);
  __Pyx_GIVEREF(__pyx_v_host);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_host);
  __Pyx_INCREF(__pyx_v_startup_version);
  __Pyx_GIVEREF(__pyx_v_startup_version);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_startup_version);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_4) {
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  }
  __Pyx_INCREF(__pyx_kp_s_Unsupported_protocol_version_on);
  __Pyx_GIVEREF(__pyx_kp_s_Unsupported_protocol_version_on);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_kp_s_Unsupported_protocol_version_on);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":131
 *         super(ProtocolVersionUnsupported, self).__init__("Unsupported protocol version on %s: %d",
 *                                                          (host, startup_version))
 *         self.startup_version = startup_version             # <<<<<<<<<<<<<<
 * 
 * class ConnectionBusy(Exception):
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_startup_version, __pyx_v_startup_version) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":128
 *     Server rejected startup message due to unsupported protocol version
 *     """
 *     def __init__(self, host, startup_version):             # <<<<<<<<<<<<<<
 *         super(ProtocolVersionUnsupported, self).__init__("Unsupported protocol version on %s: %d",
 *                                                          (host, startup_version))
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cassandra.connection.ProtocolVersionUnsupported.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":148
 * 
 * 
 * def defunct_on_error(f):             # <<<<<<<<<<<<<<
 * 
 *     @wraps(f)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_7defunct_on_error(PyObject *__pyx_self, PyObject *__pyx_v_f); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_7defunct_on_error = {"defunct_on_error", (PyCFunction)__pyx_pw_9cassandra_10connection_7defunct_on_error, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_7defunct_on_error(PyObject *__pyx_self, PyObject *__pyx_v_f) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("defunct_on_error (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_6defunct_on_error(__pyx_self, ((PyObject *)__pyx_v_f));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":151
 * 
 *     @wraps(f)
 *     def wrapper(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         try:
 *             return f(self, *args, **kwargs)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_16defunct_on_error_1wrapper(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_16defunct_on_error_1wrapper = {"wrapper", (PyCFunction)__pyx_pw_9cassandra_10connection_16defunct_on_error_1wrapper, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_16defunct_on_error_1wrapper(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("wrapper (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_args)) {
      __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_args);
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        default:
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "wrapper") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("wrapper", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("cassandra.connection.defunct_on_error.wrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_16defunct_on_error_wrapper(__pyx_self, __pyx_v_self, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_16defunct_on_error_wrapper(PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error *__pyx_cur_scope;
  struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error *__pyx_outer_scope;
  PyObject *__pyx_v_exc = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("wrapper", 0);
  __pyx_outer_scope = (struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "cassandra/connection.py":152
 *     @wraps(f)
 *     def wrapper(self, *args, **kwargs):
 *         try:             # <<<<<<<<<<<<<<
 *             return f(self, *args, **kwargs)
 *         except Exception as exc:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "cassandra/connection.py":153
 *     def wrapper(self, *args, **kwargs):
 *         try:
 *             return f(self, *args, **kwargs)             # <<<<<<<<<<<<<<
 *         except Exception as exc:
 *             self.defunct(exc)
 */
      __Pyx_XDECREF(__pyx_r);
      if (unlikely(!__pyx_cur_scope->__pyx_v_f)) { __Pyx_RaiseClosureNameError("f"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;} }
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_self);
      __Pyx_GIVEREF(__pyx_v_self);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self);
      __pyx_t_5 = PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyNumber_Add(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __pyx_v_kwargs;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_v_f, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L7_try_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cassandra/connection.py":154
 *         try:
 *             return f(self, *args, **kwargs)
 *         except Exception as exc:             # <<<<<<<<<<<<<<
 *             self.defunct(exc)
 *     return wrapper
 */
    __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("cassandra.connection.defunct_on_error.wrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_5);
      __pyx_v_exc = __pyx_t_5;

      /* "cassandra/connection.py":155
 *             return f(self, *args, **kwargs)
 *         except Exception as exc:
 *             self.defunct(exc)             # <<<<<<<<<<<<<<
 *     return wrapper
 * 
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_defunct); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_exc); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
        __Pyx_GOTREF(__pyx_t_8);
      } else {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_INCREF(__pyx_v_exc);
        __Pyx_GIVEREF(__pyx_v_exc);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_v_exc);
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  }

  /* "cassandra/connection.py":151
 * 
 *     @wraps(f)
 *     def wrapper(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         try:
 *             return f(self, *args, **kwargs)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cassandra.connection.defunct_on_error.wrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_exc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":148
 * 
 * 
 * def defunct_on_error(f):             # <<<<<<<<<<<<<<
 * 
 *     @wraps(f)
 */

static PyObject *__pyx_pf_9cassandra_10connection_6defunct_on_error(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_f) {
  struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error *__pyx_cur_scope;
  PyObject *__pyx_v_wrapper = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("defunct_on_error", 0);
  __pyx_cur_scope = (struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error *)__pyx_tp_new_9cassandra_10connection___pyx_scope_struct__defunct_on_error(__pyx_ptype_9cassandra_10connection___pyx_scope_struct__defunct_on_error, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_v_f = __pyx_v_f;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_f);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_f);

  /* "cassandra/connection.py":150
 * def defunct_on_error(f):
 * 
 *     @wraps(f)             # <<<<<<<<<<<<<<
 *     def wrapper(self, *args, **kwargs):
 *         try:
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_wraps); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_cur_scope->__pyx_v_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_f);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_f);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_cur_scope->__pyx_v_f);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cassandra/connection.py":151
 * 
 *     @wraps(f)
 *     def wrapper(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         try:
 *             return f(self, *args, **kwargs)
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_16defunct_on_error_1wrapper, 0, __pyx_n_s_defunct_on_error_locals_wrapper, ((PyObject*)__pyx_cur_scope), __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__7)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_wrapper = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cassandra/connection.py":156
 *         except Exception as exc:
 *             self.defunct(exc)
 *     return wrapper             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_wrapper);
  __pyx_r = __pyx_v_wrapper;
  goto __pyx_L0;

  /* "cassandra/connection.py":148
 * 
 * 
 * def defunct_on_error(f):             # <<<<<<<<<<<<<<
 * 
 *     @wraps(f)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cassandra.connection.defunct_on_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_wrapper);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":209
 *     _ssl_impl = ssl
 * 
 *     def __init__(self, host='127.0.0.1', port=9042, authenticator=None,             # <<<<<<<<<<<<<<
 *                  ssl_options=None, sockopts=None, compression=True,
 *                  cql_version=None, protocol_version=MAX_SUPPORTED_VERSION, is_control_connection=False,
 */

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_62__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__defaults__", 0);
  __Pyx_XDECREF(__pyx_r);

  /* "cassandra/connection.py":212
 *                  ssl_options=None, sockopts=None, compression=True,
 *                  cql_version=None, protocol_version=MAX_SUPPORTED_VERSION, is_control_connection=False,
 *                  user_type_map=None):             # <<<<<<<<<<<<<<
 *         self.host = host
 *         self.port = port
 */
  __pyx_t_1 = PyTuple_New(10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject*)__pyx_kp_s_127_0_0_1));
  __Pyx_GIVEREF(((PyObject*)__pyx_kp_s_127_0_0_1));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject*)__pyx_kp_s_127_0_0_1));
  __Pyx_INCREF(((PyObject *)__pyx_int_9042));
  __Pyx_GIVEREF(((PyObject *)__pyx_int_9042));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_int_9042));
  __Pyx_INCREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)Py_None));
  __Pyx_INCREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)Py_None));
  __Pyx_INCREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)Py_None));
  __Pyx_INCREF(((PyObject *)Py_True));
  __Pyx_GIVEREF(((PyObject *)Py_True));
  PyTuple_SET_ITEM(__pyx_t_1, 5, ((PyObject *)Py_True));
  __Pyx_INCREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_t_1, 6, ((PyObject *)Py_None));
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_protocol_version);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_protocol_version);
  PyTuple_SET_ITEM(__pyx_t_1, 7, __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_protocol_version);
  __Pyx_INCREF(((PyObject *)Py_False));
  __Pyx_GIVEREF(((PyObject *)Py_False));
  PyTuple_SET_ITEM(__pyx_t_1, 8, ((PyObject *)Py_False));
  __Pyx_INCREF(((PyObject *)Py_None));
  __Pyx_GIVEREF(((PyObject *)Py_None));
  PyTuple_SET_ITEM(__pyx_t_1, 9, ((PyObject *)Py_None));

  /* "cassandra/connection.py":209
 *     _ssl_impl = ssl
 * 
 *     def __init__(self, host='127.0.0.1', port=9042, authenticator=None,             # <<<<<<<<<<<<<<
 *                  ssl_options=None, sockopts=None, compression=True,
 *                  cql_version=None, protocol_version=MAX_SUPPORTED_VERSION, is_control_connection=False,
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cassandra.connection.Connection.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_1__init__ = {"__init__", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_host = 0;
  PyObject *__pyx_v_port = 0;
  PyObject *__pyx_v_authenticator = 0;
  PyObject *__pyx_v_ssl_options = 0;
  PyObject *__pyx_v_sockopts = 0;
  PyObject *__pyx_v_compression = 0;
  PyObject *__pyx_v_cql_version = 0;
  PyObject *__pyx_v_protocol_version = 0;
  PyObject *__pyx_v_is_control_connection = 0;
  PyObject *__pyx_v_user_type_map = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_host,&__pyx_n_s_port,&__pyx_n_s_authenticator,&__pyx_n_s_ssl_options,&__pyx_n_s_sockopts,&__pyx_n_s_compression,&__pyx_n_s_cql_version,&__pyx_n_s_protocol_version,&__pyx_n_s_is_control_connection,&__pyx_n_s_user_type_map,0};
    PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0};
    __pyx_defaults *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self);
    values[1] = ((PyObject *)((PyObject*)__pyx_kp_s_127_0_0_1));
    values[2] = ((PyObject *)((PyObject *)__pyx_int_9042));
    values[3] = ((PyObject *)((PyObject *)Py_None));
    values[4] = ((PyObject *)((PyObject *)Py_None));
    values[5] = ((PyObject *)((PyObject *)Py_None));
    values[6] = ((PyObject *)((PyObject *)Py_True));
    values[7] = ((PyObject *)((PyObject *)Py_None));
    values[8] = __pyx_dynamic_args->__pyx_arg_protocol_version;
    values[9] = ((PyObject *)((PyObject *)Py_False));
    values[10] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_host);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_port);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_authenticator);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ssl_options);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sockopts);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compression);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cql_version);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_protocol_version);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_is_control_connection);
          if (value) { values[9] = value; kw_args--; }
        }
        case 10:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_user_type_map);
          if (value) { values[10] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_host = values[1];
    __pyx_v_port = values[2];
    __pyx_v_authenticator = values[3];
    __pyx_v_ssl_options = values[4];
    __pyx_v_sockopts = values[5];
    __pyx_v_compression = values[6];
    __pyx_v_cql_version = values[7];
    __pyx_v_protocol_version = values[8];
    __pyx_v_is_control_connection = values[9];
    __pyx_v_user_type_map = values[10];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 11, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Connection.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection___init__(__pyx_self, __pyx_v_self, __pyx_v_host, __pyx_v_port, __pyx_v_authenticator, __pyx_v_ssl_options, __pyx_v_sockopts, __pyx_v_compression, __pyx_v_cql_version, __pyx_v_protocol_version, __pyx_v_is_control_connection, __pyx_v_user_type_map);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_host, PyObject *__pyx_v_port, PyObject *__pyx_v_authenticator, PyObject *__pyx_v_ssl_options, PyObject *__pyx_v_sockopts, PyObject *__pyx_v_compression, PyObject *__pyx_v_cql_version, PyObject *__pyx_v_protocol_version, PyObject *__pyx_v_is_control_connection, PyObject *__pyx_v_user_type_map) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cassandra/connection.py":213
 *                  cql_version=None, protocol_version=MAX_SUPPORTED_VERSION, is_control_connection=False,
 *                  user_type_map=None):
 *         self.host = host             # <<<<<<<<<<<<<<
 *         self.port = port
 *         self.authenticator = authenticator
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_host, __pyx_v_host) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":214
 *                  user_type_map=None):
 *         self.host = host
 *         self.port = port             # <<<<<<<<<<<<<<
 *         self.authenticator = authenticator
 *         self.ssl_options = ssl_options
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_port, __pyx_v_port) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":215
 *         self.host = host
 *         self.port = port
 *         self.authenticator = authenticator             # <<<<<<<<<<<<<<
 *         self.ssl_options = ssl_options
 *         self.sockopts = sockopts
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_authenticator, __pyx_v_authenticator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":216
 *         self.port = port
 *         self.authenticator = authenticator
 *         self.ssl_options = ssl_options             # <<<<<<<<<<<<<<
 *         self.sockopts = sockopts
 *         self.compression = compression
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_ssl_options, __pyx_v_ssl_options) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":217
 *         self.authenticator = authenticator
 *         self.ssl_options = ssl_options
 *         self.sockopts = sockopts             # <<<<<<<<<<<<<<
 *         self.compression = compression
 *         self.cql_version = cql_version
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_sockopts, __pyx_v_sockopts) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":218
 *         self.ssl_options = ssl_options
 *         self.sockopts = sockopts
 *         self.compression = compression             # <<<<<<<<<<<<<<
 *         self.cql_version = cql_version
 *         self.protocol_version = protocol_version
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_compression, __pyx_v_compression) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":219
 *         self.sockopts = sockopts
 *         self.compression = compression
 *         self.cql_version = cql_version             # <<<<<<<<<<<<<<
 *         self.protocol_version = protocol_version
 *         self.is_control_connection = is_control_connection
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_cql_version, __pyx_v_cql_version) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":220
 *         self.compression = compression
 *         self.cql_version = cql_version
 *         self.protocol_version = protocol_version             # <<<<<<<<<<<<<<
 *         self.is_control_connection = is_control_connection
 *         self.user_type_map = user_type_map
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_protocol_version, __pyx_v_protocol_version) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":221
 *         self.cql_version = cql_version
 *         self.protocol_version = protocol_version
 *         self.is_control_connection = is_control_connection             # <<<<<<<<<<<<<<
 *         self.user_type_map = user_type_map
 *         self._push_watchers = defaultdict(set)
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_is_control_connection, __pyx_v_is_control_connection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":222
 *         self.protocol_version = protocol_version
 *         self.is_control_connection = is_control_connection
 *         self.user_type_map = user_type_map             # <<<<<<<<<<<<<<
 *         self._push_watchers = defaultdict(set)
 *         self._requests = {}
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_user_type_map, __pyx_v_user_type_map) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":223
 *         self.is_control_connection = is_control_connection
 *         self.user_type_map = user_type_map
 *         self._push_watchers = defaultdict(set)             # <<<<<<<<<<<<<<
 *         self._requests = {}
 *         self._iobuf = io.BytesIO()
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_defaultdict); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)((PyObject*)(&PySet_Type)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(((PyObject *)((PyObject*)(&PySet_Type))));
    __Pyx_GIVEREF(((PyObject *)((PyObject*)(&PySet_Type))));
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)((PyObject*)(&PySet_Type))));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_push_watchers, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":224
 *         self.user_type_map = user_type_map
 *         self._push_watchers = defaultdict(set)
 *         self._requests = {}             # <<<<<<<<<<<<<<
 *         self._iobuf = io.BytesIO()
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_requests, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":225
 *         self._push_watchers = defaultdict(set)
 *         self._requests = {}
 *         self._iobuf = io.BytesIO()             # <<<<<<<<<<<<<<
 * 
 *         if protocol_version >= 3:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_io); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_BytesIO); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_iobuf, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":227
 *         self._iobuf = io.BytesIO()
 * 
 *         if protocol_version >= 3:             # <<<<<<<<<<<<<<
 *             self.max_request_id = (2 ** 15) - 1
 *             # Don't fill the deque with 2**15 items right away. Start with 300 and add
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_protocol_version, __pyx_int_3, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "cassandra/connection.py":228
 * 
 *         if protocol_version >= 3:
 *             self.max_request_id = (2 ** 15) - 1             # <<<<<<<<<<<<<<
 *             # Don't fill the deque with 2**15 items right away. Start with 300 and add
 *             # more if needed.
 */
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_max_request_id, __pyx_int_32767) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cassandra/connection.py":231
 *             # Don't fill the deque with 2**15 items right away. Start with 300 and add
 *             # more if needed.
 *             self.request_ids = deque(range(300))             # <<<<<<<<<<<<<<
 *             self.highest_request_id = 299
 *         else:
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_deque); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_range); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_2) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_request_ids, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cassandra/connection.py":232
 *             # more if needed.
 *             self.request_ids = deque(range(300))
 *             self.highest_request_id = 299             # <<<<<<<<<<<<<<
 *         else:
 *             self.max_request_id = (2 ** 7) - 1
 */
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_highest_request_id, __pyx_int_299) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  /*else*/ {

    /* "cassandra/connection.py":234
 *             self.highest_request_id = 299
 *         else:
 *             self.max_request_id = (2 ** 7) - 1             # <<<<<<<<<<<<<<
 *             self.request_ids = deque(range(self.max_request_id + 1))
 *             self.highest_request_id = self.max_request_id
 */
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_max_request_id, __pyx_int_127) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cassandra/connection.py":235
 *         else:
 *             self.max_request_id = (2 ** 7) - 1
 *             self.request_ids = deque(range(self.max_request_id + 1))             # <<<<<<<<<<<<<<
 *             self.highest_request_id = self.max_request_id
 * 
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_deque); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_range); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_max_request_id); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = PyNumber_Add(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_2) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_request_ids, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cassandra/connection.py":236
 *             self.max_request_id = (2 ** 7) - 1
 *             self.request_ids = deque(range(self.max_request_id + 1))
 *             self.highest_request_id = self.max_request_id             # <<<<<<<<<<<<<<
 * 
 *         self.lock = RLock()
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_max_request_id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_highest_request_id, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "cassandra/connection.py":238
 *             self.highest_request_id = self.max_request_id
 * 
 *         self.lock = RLock()             # <<<<<<<<<<<<<<
 *         self.connected_event = Event()
 * 
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_RLock); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_8) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_lock, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":239
 * 
 *         self.lock = RLock()
 *         self.connected_event = Event()             # <<<<<<<<<<<<<<
 * 
 *     @classmethod
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_Event); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_8) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_connected_event, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":209
 *     _ssl_impl = ssl
 * 
 *     def __init__(self, host='127.0.0.1', port=9042, authenticator=None,             # <<<<<<<<<<<<<<
 *                  ssl_options=None, sockopts=None, compression=True,
 *                  cql_version=None, protocol_version=MAX_SUPPORTED_VERSION, is_control_connection=False,
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cassandra.connection.Connection.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":242
 * 
 *     @classmethod
 *     def initialize_reactor(self):             # <<<<<<<<<<<<<<
 *         """
 *         Called once by Cluster.connect().  This should be used by implementations
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_3initialize_reactor(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_9cassandra_10connection_10Connection_2initialize_reactor[] = "\n        Called once by Cluster.connect().  This should be used by implementations\n        to set up any resources that will be shared across connections.\n        ";
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_3initialize_reactor = {"initialize_reactor", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_3initialize_reactor, METH_O, __pyx_doc_9cassandra_10connection_10Connection_2initialize_reactor};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_3initialize_reactor(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("initialize_reactor (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_2initialize_reactor(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_2initialize_reactor(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("initialize_reactor", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":250
 * 
 *     @classmethod
 *     def handle_fork(self):             # <<<<<<<<<<<<<<
 *         """
 *         Called after a forking.  This should cleanup any remaining reactor state
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_5handle_fork(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_9cassandra_10connection_10Connection_4handle_fork[] = "\n        Called after a forking.  This should cleanup any remaining reactor state\n        from the parent process.\n        ";
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_5handle_fork = {"handle_fork", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_5handle_fork, METH_O, __pyx_doc_9cassandra_10connection_10Connection_4handle_fork};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_5handle_fork(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_fork (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_4handle_fork(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_4handle_fork(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_fork", 0);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":258
 * 
 *     @classmethod
 *     def create_timer(cls, timeout, callback):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_7create_timer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_7create_timer = {"create_timer", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_7create_timer, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_7create_timer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_cls = 0;
  CYTHON_UNUSED PyObject *__pyx_v_timeout = 0;
  CYTHON_UNUSED PyObject *__pyx_v_callback = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_timer (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cls,&__pyx_n_s_timeout,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_timer", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_timer", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_timer") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_cls = values[0];
    __pyx_v_timeout = values[1];
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_timer", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Connection.create_timer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_6create_timer(__pyx_self, __pyx_v_cls, __pyx_v_timeout, __pyx_v_callback);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_6create_timer(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_cls, CYTHON_UNUSED PyObject *__pyx_v_timeout, CYTHON_UNUSED PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_timer", 0);

  /* "cassandra/connection.py":259
 *     @classmethod
 *     def create_timer(cls, timeout, callback):
 *         raise NotImplementedError()             # <<<<<<<<<<<<<<
 * 
 *     @classmethod
 */
  __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":258
 * 
 *     @classmethod
 *     def create_timer(cls, timeout, callback):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError()
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cassandra.connection.Connection.create_timer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":262
 * 
 *     @classmethod
 *     def factory(cls, host, timeout, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """
 *         A factory function which returns connections which have
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_9factory(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9cassandra_10connection_10Connection_8factory[] = "\n        A factory function which returns connections which have\n        succeeded in connecting and are ready for service (or\n        raises an exception otherwise).\n        ";
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_9factory = {"factory", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_9factory, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9cassandra_10connection_10Connection_8factory};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_9factory(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_cls = 0;
  PyObject *__pyx_v_host = 0;
  PyObject *__pyx_v_timeout = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("factory (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  if (PyTuple_GET_SIZE(__pyx_args) > 3) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 3, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_args)) {
      __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_args);
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cls,&__pyx_n_s_host,&__pyx_n_s_timeout,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        default:
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_host)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("factory", 0, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("factory", 0, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 3) ? pos_args : 3;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "factory") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) < 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_cls = values[0];
    __pyx_v_host = values[1];
    __pyx_v_timeout = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("factory", 0, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("cassandra.connection.Connection.factory", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_8factory(__pyx_self, __pyx_v_cls, __pyx_v_host, __pyx_v_timeout, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_8factory(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_host, PyObject *__pyx_v_timeout, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_conn = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("factory", 0);

  /* "cassandra/connection.py":268
 *         raises an exception otherwise).
 *         """
 *         conn = cls(host, *args, **kwargs)             # <<<<<<<<<<<<<<
 *         conn.connected_event.wait(timeout)
 *         if conn.last_error:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_host);
  __Pyx_GIVEREF(__pyx_v_host);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_host);
  __pyx_t_2 = PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __pyx_v_kwargs;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_cls, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_conn = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cassandra/connection.py":269
 *         """
 *         conn = cls(host, *args, **kwargs)
 *         conn.connected_event.wait(timeout)             # <<<<<<<<<<<<<<
 *         if conn.last_error:
 *             if conn.is_unsupported_proto_version:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_conn, __pyx_n_s_connected_event); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_wait); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_timeout); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_timeout);
    __Pyx_GIVEREF(__pyx_v_timeout);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_timeout);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":270
 *         conn = cls(host, *args, **kwargs)
 *         conn.connected_event.wait(timeout)
 *         if conn.last_error:             # <<<<<<<<<<<<<<
 *             if conn.is_unsupported_proto_version:
 *                 raise ProtocolVersionUnsupported(host, conn.protocol_version)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_conn, __pyx_n_s_last_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "cassandra/connection.py":271
 *         conn.connected_event.wait(timeout)
 *         if conn.last_error:
 *             if conn.is_unsupported_proto_version:             # <<<<<<<<<<<<<<
 *                 raise ProtocolVersionUnsupported(host, conn.protocol_version)
 *             raise conn.last_error
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_conn, __pyx_n_s_is_unsupported_proto_version); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_5) {

      /* "cassandra/connection.py":272
 *         if conn.last_error:
 *             if conn.is_unsupported_proto_version:
 *                 raise ProtocolVersionUnsupported(host, conn.protocol_version)             # <<<<<<<<<<<<<<
 *             raise conn.last_error
 *         elif not conn.connected_event.is_set():
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ProtocolVersionUnsupported); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_conn, __pyx_n_s_protocol_version); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_INCREF(__pyx_v_host);
      __Pyx_GIVEREF(__pyx_v_host);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_host);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cassandra/connection.py":273
 *             if conn.is_unsupported_proto_version:
 *                 raise ProtocolVersionUnsupported(host, conn.protocol_version)
 *             raise conn.last_error             # <<<<<<<<<<<<<<
 *         elif not conn.connected_event.is_set():
 *             conn.close()
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_conn, __pyx_n_s_last_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cassandra/connection.py":274
 *                 raise ProtocolVersionUnsupported(host, conn.protocol_version)
 *             raise conn.last_error
 *         elif not conn.connected_event.is_set():             # <<<<<<<<<<<<<<
 *             conn.close()
 *             raise OperationTimedOut("Timed out creating connection (%s seconds)" % timeout)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_conn, __pyx_n_s_connected_event); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_is_set); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_8 = ((!__pyx_t_5) != 0);
  if (__pyx_t_8) {

    /* "cassandra/connection.py":275
 *             raise conn.last_error
 *         elif not conn.connected_event.is_set():
 *             conn.close()             # <<<<<<<<<<<<<<
 *             raise OperationTimedOut("Timed out creating connection (%s seconds)" % timeout)
 *         else:
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_conn, __pyx_n_s_close); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cassandra/connection.py":276
 *         elif not conn.connected_event.is_set():
 *             conn.close()
 *             raise OperationTimedOut("Timed out creating connection (%s seconds)" % timeout)             # <<<<<<<<<<<<<<
 *         else:
 *             return conn
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_OperationTimedOut); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Timed_out_creating_connection_s, __pyx_v_timeout); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  /*else*/ {

    /* "cassandra/connection.py":278
 *             raise OperationTimedOut("Timed out creating connection (%s seconds)" % timeout)
 *         else:
 *             return conn             # <<<<<<<<<<<<<<
 * 
 *     def _connect_socket(self):
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_conn);
    __pyx_r = __pyx_v_conn;
    goto __pyx_L0;
  }

  /* "cassandra/connection.py":262
 * 
 *     @classmethod
 *     def factory(cls, host, timeout, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """
 *         A factory function which returns connections which have
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cassandra.connection.Connection.factory", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_conn);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":280
 *             return conn
 * 
 *     def _connect_socket(self):             # <<<<<<<<<<<<<<
 *         sockerr = None
 *         addresses = socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_11_connect_socket(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_11_connect_socket = {"_connect_socket", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_11_connect_socket, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_11_connect_socket(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_connect_socket (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_10_connect_socket(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_10_connect_socket(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_sockerr = NULL;
  PyObject *__pyx_v_addresses = NULL;
  PyObject *__pyx_v_af = NULL;
  PyObject *__pyx_v_socktype = NULL;
  PyObject *__pyx_v_proto = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_canonname = NULL;
  PyObject *__pyx_v_sockaddr = NULL;
  PyObject *__pyx_v_err = NULL;
  PyObject *__pyx_v_args = NULL;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  Py_ssize_t __pyx_t_15;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_connect_socket", 0);

  /* "cassandra/connection.py":281
 * 
 *     def _connect_socket(self):
 *         sockerr = None             # <<<<<<<<<<<<<<
 *         addresses = socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM)
 *         for (af, socktype, proto, canonname, sockaddr) in addresses:
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_sockerr = Py_None;

  /* "cassandra/connection.py":282
 *     def _connect_socket(self):
 *         sockerr = None
 *         addresses = socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM)             # <<<<<<<<<<<<<<
 *         for (af, socktype, proto, canonname, sockaddr) in addresses:
 *             try:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_getaddrinfo); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_port); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_AF_UNSPEC); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_SOCK_STREAM); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_8 = 1;
    }
  }
  __pyx_t_9 = PyTuple_New(4+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  if (__pyx_t_5) {
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); __pyx_t_5 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_9, 3+__pyx_t_8, __pyx_t_7);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_addresses = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cassandra/connection.py":283
 *         sockerr = None
 *         addresses = socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM)
 *         for (af, socktype, proto, canonname, sockaddr) in addresses:             # <<<<<<<<<<<<<<
 *             try:
 *                 self._socket = self._socket_impl.socket(af, socktype, proto)
 */
  if (likely(PyList_CheckExact(__pyx_v_addresses)) || PyTuple_CheckExact(__pyx_v_addresses)) {
    __pyx_t_1 = __pyx_v_addresses; __Pyx_INCREF(__pyx_t_1); __pyx_t_8 = 0;
    __pyx_t_10 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_addresses); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (likely(!__pyx_t_10)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_10(__pyx_t_1);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
      PyObject* sequence = __pyx_t_3;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 5)) {
        if (size > 5) __Pyx_RaiseTooManyValuesError(5);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 3); 
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 4); 
      } else {
        __pyx_t_9 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 2); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 3); 
        __pyx_t_2 = PyList_GET_ITEM(sequence, 4); 
      }
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      #else
      {
        Py_ssize_t i;
        PyObject** temps[5] = {&__pyx_t_9,&__pyx_t_7,&__pyx_t_6,&__pyx_t_4,&__pyx_t_2};
        for (i=0; i < 5; i++) {
          PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(item);
          *(temps[i]) = item;
        }
      }
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      Py_ssize_t index = -1;
      PyObject** temps[5] = {&__pyx_t_9,&__pyx_t_7,&__pyx_t_6,&__pyx_t_4,&__pyx_t_2};
      __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_11 = Py_TYPE(__pyx_t_5)->tp_iternext;
      for (index=0; index < 5; index++) {
        PyObject* item = __pyx_t_11(__pyx_t_5); if (unlikely(!item)) goto __pyx_L5_unpacking_failed;
        __Pyx_GOTREF(item);
        *(temps[index]) = item;
      }
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_5), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = NULL;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_11 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_af, __pyx_t_9);
    __pyx_t_9 = 0;
    __Pyx_XDECREF_SET(__pyx_v_socktype, __pyx_t_7);
    __pyx_t_7 = 0;
    __Pyx_XDECREF_SET(__pyx_v_proto, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_canonname, __pyx_t_4);
    __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_sockaddr, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "cassandra/connection.py":284
 *         addresses = socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM)
 *         for (af, socktype, proto, canonname, sockaddr) in addresses:
 *             try:             # <<<<<<<<<<<<<<
 *                 self._socket = self._socket_impl.socket(af, socktype, proto)
 *                 if self.ssl_options:
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      /*try:*/ {

        /* "cassandra/connection.py":285
 *         for (af, socktype, proto, canonname, sockaddr) in addresses:
 *             try:
 *                 self._socket = self._socket_impl.socket(af, socktype, proto)             # <<<<<<<<<<<<<<
 *                 if self.ssl_options:
 *                     if not self._ssl_impl:
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_socket_impl); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_socket); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = NULL;
        __pyx_t_15 = 0;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_2)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_2);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
            __pyx_t_15 = 1;
          }
        }
        __pyx_t_6 = PyTuple_New(3+__pyx_t_15); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_2) {
          __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL;
        }
        __Pyx_INCREF(__pyx_v_af);
        __Pyx_GIVEREF(__pyx_v_af);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_15, __pyx_v_af);
        __Pyx_INCREF(__pyx_v_socktype);
        __Pyx_GIVEREF(__pyx_v_socktype);
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_15, __pyx_v_socktype);
        __Pyx_INCREF(__pyx_v_proto);
        __Pyx_GIVEREF(__pyx_v_proto);
        PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_15, __pyx_v_proto);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_socket_2, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "cassandra/connection.py":286
 *             try:
 *                 self._socket = self._socket_impl.socket(af, socktype, proto)
 *                 if self.ssl_options:             # <<<<<<<<<<<<<<
 *                     if not self._ssl_impl:
 *                         raise Exception("This version of Python was not compiled with SSL support")
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ssl_options); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (__pyx_t_16) {

          /* "cassandra/connection.py":287
 *                 self._socket = self._socket_impl.socket(af, socktype, proto)
 *                 if self.ssl_options:
 *                     if not self._ssl_impl:             # <<<<<<<<<<<<<<
 *                         raise Exception("This version of Python was not compiled with SSL support")
 *                     self._socket = self._ssl_impl.wrap_socket(self._socket, **self.ssl_options)
 */
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ssl_impl); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_17 = ((!__pyx_t_16) != 0);
          if (__pyx_t_17) {

            /* "cassandra/connection.py":288
 *                 if self.ssl_options:
 *                     if not self._ssl_impl:
 *                         raise Exception("This version of Python was not compiled with SSL support")             # <<<<<<<<<<<<<<
 *                     self._socket = self._ssl_impl.wrap_socket(self._socket, **self.ssl_options)
 *                 self._socket.settimeout(1.0)
 */
            __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_Exception, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_Raise(__pyx_t_3, 0, 0, 0);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          }

          /* "cassandra/connection.py":289
 *                     if not self._ssl_impl:
 *                         raise Exception("This version of Python was not compiled with SSL support")
 *                     self._socket = self._ssl_impl.wrap_socket(self._socket, **self.ssl_options)             # <<<<<<<<<<<<<<
 *                 self._socket.settimeout(1.0)
 *                 self._socket.connect(sockaddr)
 */
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ssl_impl); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_wrap_socket); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_socket_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ssl_options); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_2);
          if (unlikely(__pyx_t_2 == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          }
          if (likely(PyDict_Check(__pyx_t_2))) {
            __pyx_t_3 = __pyx_t_2;
            __Pyx_INCREF(__pyx_t_3);
          } else {
            __pyx_t_3 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_3);
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_socket_2, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          goto __pyx_L15;
        }
        __pyx_L15:;

        /* "cassandra/connection.py":290
 *                         raise Exception("This version of Python was not compiled with SSL support")
 *                     self._socket = self._ssl_impl.wrap_socket(self._socket, **self.ssl_options)
 *                 self._socket.settimeout(1.0)             # <<<<<<<<<<<<<<
 *                 self._socket.connect(sockaddr)
 *                 sockerr = None
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_socket_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_settimeout); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "cassandra/connection.py":291
 *                     self._socket = self._ssl_impl.wrap_socket(self._socket, **self.ssl_options)
 *                 self._socket.settimeout(1.0)
 *                 self._socket.connect(sockaddr)             # <<<<<<<<<<<<<<
 *                 sockerr = None
 *                 break
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_socket_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_connect); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = NULL;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_3)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
          }
        }
        if (!__pyx_t_3) {
          __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_sockaddr); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_2);
        } else {
          __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
          __Pyx_INCREF(__pyx_v_sockaddr);
          __Pyx_GIVEREF(__pyx_v_sockaddr);
          PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_sockaddr);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "cassandra/connection.py":292
 *                 self._socket.settimeout(1.0)
 *                 self._socket.connect(sockaddr)
 *                 sockerr = None             # <<<<<<<<<<<<<<
 *                 break
 *             except socket.error as err:
 */
        __Pyx_INCREF(Py_None);
        __Pyx_DECREF_SET(__pyx_v_sockerr, Py_None);

        /* "cassandra/connection.py":293
 *                 self._socket.connect(sockaddr)
 *                 sockerr = None
 *                 break             # <<<<<<<<<<<<<<
 *             except socket.error as err:
 *                 if self._socket:
 */
        goto __pyx_L12_try_break;
      }
      __pyx_L7_error:;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cassandra/connection.py":294
 *                 sockerr = None
 *                 break
 *             except socket.error as err:             # <<<<<<<<<<<<<<
 *                 if self._socket:
 *                     self._socket.close()
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_error); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_18 = PyErr_ExceptionMatches(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (__pyx_t_18) {
        __Pyx_AddTraceback("cassandra.connection.Connection._connect_socket", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_2, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_XDECREF_SET(__pyx_v_err, __pyx_t_2);

        /* "cassandra/connection.py":295
 *                 break
 *             except socket.error as err:
 *                 if self._socket:             # <<<<<<<<<<<<<<
 *                     self._socket.close()
 *                     self._socket = None
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_socket_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_17 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (__pyx_t_17) {

          /* "cassandra/connection.py":296
 *             except socket.error as err:
 *                 if self._socket:
 *                     self._socket.close()             # <<<<<<<<<<<<<<
 *                     self._socket = None
 *                 sockerr = err
 */
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_socket_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_close); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_7 = NULL;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
            __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
            if (likely(__pyx_t_7)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
              __Pyx_INCREF(__pyx_t_7);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_9, function);
            }
          }
          if (__pyx_t_7) {
            __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          } else {
            __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          }
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "cassandra/connection.py":297
 *                 if self._socket:
 *                     self._socket.close()
 *                     self._socket = None             # <<<<<<<<<<<<<<
 *                 sockerr = err
 * 
 */
          if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_socket_2, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          goto __pyx_L19;
        }
        __pyx_L19:;

        /* "cassandra/connection.py":298
 *                     self._socket.close()
 *                     self._socket = None
 *                 sockerr = err             # <<<<<<<<<<<<<<
 * 
 *         if sockerr:
 */
        __Pyx_INCREF(__pyx_v_err);
        __Pyx_DECREF_SET(__pyx_v_sockerr, __pyx_v_err);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L8_exception_handled;
      }
      goto __pyx_L9_except_error;
      __pyx_L9_except_error:;
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_14);
      __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
      goto __pyx_L1_error;
      __pyx_L12_try_break:;
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_14);
      __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
      goto __pyx_L4_break;
      __pyx_L8_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_14);
      __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
    }

    /* "cassandra/connection.py":283
 *         sockerr = None
 *         addresses = socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM)
 *         for (af, socktype, proto, canonname, sockaddr) in addresses:             # <<<<<<<<<<<<<<
 *             try:
 *                 self._socket = self._socket_impl.socket(af, socktype, proto)
 */
  }
  __pyx_L4_break:;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":300
 *                 sockerr = err
 * 
 *         if sockerr:             # <<<<<<<<<<<<<<
 *             raise socket.error(sockerr.errno, "Tried connecting to %s. Last error: %s" % ([a[4] for a in addresses], sockerr.strerror))
 * 
 */
  __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_v_sockerr); if (unlikely(__pyx_t_17 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_17) {

    /* "cassandra/connection.py":301
 * 
 *         if sockerr:
 *             raise socket.error(sockerr.errno, "Tried connecting to %s. Last error: %s" % ([a[4] for a in addresses], sockerr.strerror))             # <<<<<<<<<<<<<<
 * 
 *         if self.sockopts:
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_sockerr, __pyx_n_s_errno); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (likely(PyList_CheckExact(__pyx_v_addresses)) || PyTuple_CheckExact(__pyx_v_addresses)) {
      __pyx_t_3 = __pyx_v_addresses; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0;
      __pyx_t_10 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_addresses); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    for (;;) {
      if (likely(!__pyx_t_10)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_9); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_9); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_10(__pyx_t_3);
        if (unlikely(!__pyx_t_9)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_a, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_9);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_9))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_sockerr, __pyx_n_s_strerror); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_3);
    __pyx_t_6 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Tried_connecting_to_s_Last_error, __pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_8 = 1;
      }
    }
    __pyx_t_6 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_9) {
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); __pyx_t_9 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_8, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_8, __pyx_t_3);
    __pyx_t_4 = 0;
    __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cassandra/connection.py":303
 *             raise socket.error(sockerr.errno, "Tried connecting to %s. Last error: %s" % ([a[4] for a in addresses], sockerr.strerror))
 * 
 *         if self.sockopts:             # <<<<<<<<<<<<<<
 *             for args in self.sockopts:
 *                 self._socket.setsockopt(*args)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sockopts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_17 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_17) {

    /* "cassandra/connection.py":304
 * 
 *         if self.sockopts:
 *             for args in self.sockopts:             # <<<<<<<<<<<<<<
 *                 self._socket.setsockopt(*args)
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sockopts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = 0;
      __pyx_t_10 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_10 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (likely(!__pyx_t_10)) {
        if (likely(PyList_CheckExact(__pyx_t_2))) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        } else {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          #endif
        }
      } else {
        __pyx_t_1 = __pyx_t_10(__pyx_t_2);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF_SET(__pyx_v_args, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "cassandra/connection.py":305
 *         if self.sockopts:
 *             for args in self.sockopts:
 *                 self._socket.setsockopt(*args)             # <<<<<<<<<<<<<<
 * 
 *     def close(self):
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_socket_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_setsockopt); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "cassandra/connection.py":304
 * 
 *         if self.sockopts:
 *             for args in self.sockopts:             # <<<<<<<<<<<<<<
 *                 self._socket.setsockopt(*args)
 * 
 */
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L23;
  }
  __pyx_L23:;

  /* "cassandra/connection.py":280
 *             return conn
 * 
 *     def _connect_socket(self):             # <<<<<<<<<<<<<<
 *         sockerr = None
 *         addresses = socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cassandra.connection.Connection._connect_socket", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_sockerr);
  __Pyx_XDECREF(__pyx_v_addresses);
  __Pyx_XDECREF(__pyx_v_af);
  __Pyx_XDECREF(__pyx_v_socktype);
  __Pyx_XDECREF(__pyx_v_proto);
  __Pyx_XDECREF(__pyx_v_canonname);
  __Pyx_XDECREF(__pyx_v_sockaddr);
  __Pyx_XDECREF(__pyx_v_err);
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":307
 *                 self._socket.setsockopt(*args)
 * 
 *     def close(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_13close(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_13close = {"close", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_13close, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_13close(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("close (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_12close(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_12close(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("close", 0);

  /* "cassandra/connection.py":308
 * 
 *     def close(self):
 *         raise NotImplementedError()             # <<<<<<<<<<<<<<
 * 
 *     def defunct(self, exc):
 */
  __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":307
 *                 self._socket.setsockopt(*args)
 * 
 *     def close(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError()
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cassandra.connection.Connection.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":310
 *         raise NotImplementedError()
 * 
 *     def defunct(self, exc):             # <<<<<<<<<<<<<<
 *         with self.lock:
 *             if self.is_defunct or self.is_closed:
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_15defunct(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_15defunct = {"defunct", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_15defunct, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_15defunct(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_exc = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("defunct (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_exc,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_exc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("defunct", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "defunct") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_exc = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("defunct", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Connection.defunct", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_14defunct(__pyx_self, __pyx_v_self, __pyx_v_exc);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_14defunct(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_exc) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("defunct", 0);

  /* "cassandra/connection.py":311
 * 
 *     def defunct(self, exc):
 *         with self.lock:             # <<<<<<<<<<<<<<
 *             if self.is_defunct or self.is_closed:
 *                 return
 */
  /*with:*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lock); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    /*try:*/ {
      {
        __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_6);
        __Pyx_XGOTREF(__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_8);
        /*try:*/ {

          /* "cassandra/connection.py":312
 *     def defunct(self, exc):
 *         with self.lock:
 *             if self.is_defunct or self.is_closed:             # <<<<<<<<<<<<<<
 *                 return
 *             self.is_defunct = True
 */
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_is_defunct); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (!__pyx_t_10) {
          } else {
            __pyx_t_9 = __pyx_t_10;
            goto __pyx_L16_bool_binop_done;
          }
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_is_closed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_9 = __pyx_t_10;
          __pyx_L16_bool_binop_done:;
          if (__pyx_t_9) {

            /* "cassandra/connection.py":313
 *         with self.lock:
 *             if self.is_defunct or self.is_closed:
 *                 return             # <<<<<<<<<<<<<<
 *             self.is_defunct = True
 * 
 */
            __Pyx_XDECREF(__pyx_r);
            __pyx_r = Py_None; __Pyx_INCREF(Py_None);
            goto __pyx_L11_try_return;
          }

          /* "cassandra/connection.py":314
 *             if self.is_defunct or self.is_closed:
 *                 return
 *             self.is_defunct = True             # <<<<<<<<<<<<<<
 * 
 *         log.debug("Defuncting connection (%s) to %s:",
 */
          if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_is_defunct, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
        }
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L14_try_end;
        __pyx_L7_error:;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "cassandra/connection.py":311
 * 
 *     def defunct(self, exc):
 *         with self.lock:             # <<<<<<<<<<<<<<
 *             if self.is_defunct or self.is_closed:
 *                 return
 */
        /*except:*/ {
          __Pyx_AddTraceback("cassandra.connection.Connection.defunct", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_5 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (__pyx_t_9 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __pyx_t_10 = ((!(__pyx_t_9 != 0)) != 0);
          if (__pyx_t_10) {
            __Pyx_GIVEREF(__pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_3);
            __Pyx_XGIVEREF(__pyx_t_4);
            __Pyx_ErrRestore(__pyx_t_1, __pyx_t_3, __pyx_t_4);
            __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_4 = 0; 
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          goto __pyx_L8_exception_handled;
        }
        __pyx_L9_except_error:;
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
        goto __pyx_L1_error;
        __pyx_L11_try_return:;
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
        goto __pyx_L4_return;
        __pyx_L8_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
        __pyx_L14_try_end:;
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_2) {
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__11, NULL);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
        goto __pyx_L6;
      }
      __pyx_L4_return: {
        __pyx_t_8 = __pyx_r;
        __pyx_r = 0;
        if (__pyx_t_2) {
          __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__12, NULL);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        }
        __pyx_r = __pyx_t_8;
        __pyx_t_8 = 0;
        goto __pyx_L0;
      }
      __pyx_L6:;
    }
    goto __pyx_L21;
    __pyx_L3_error:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L1_error;
    __pyx_L21:;
  }

  /* "cassandra/connection.py":316
 *             self.is_defunct = True
 * 
 *         log.debug("Defuncting connection (%s) to %s:",             # <<<<<<<<<<<<<<
 *                   id(self), self.host, exc_info=exc)
 * 
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cassandra/connection.py":317
 * 
 *         log.debug("Defuncting connection (%s) to %s:",
 *                   id(self), self.host, exc_info=exc)             # <<<<<<<<<<<<<<
 * 
 *         self.last_error = exc
 */
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "cassandra/connection.py":316
 *             self.is_defunct = True
 * 
 *         log.debug("Defuncting connection (%s) to %s:",             # <<<<<<<<<<<<<<
 *                   id(self), self.host, exc_info=exc)
 * 
 */
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_kp_s_Defuncting_connection_s_to_s);
  __Pyx_GIVEREF(__pyx_kp_s_Defuncting_connection_s_to_s);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_s_Defuncting_connection_s_to_s);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __pyx_t_1 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "cassandra/connection.py":317
 * 
 *         log.debug("Defuncting connection (%s) to %s:",
 *                   id(self), self.host, exc_info=exc)             # <<<<<<<<<<<<<<
 * 
 *         self.last_error = exc
 */
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_exc_info, __pyx_v_exc) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":316
 *             self.is_defunct = True
 * 
 *         log.debug("Defuncting connection (%s) to %s:",             # <<<<<<<<<<<<<<
 *                   id(self), self.host, exc_info=exc)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":319
 *                   id(self), self.host, exc_info=exc)
 * 
 *         self.last_error = exc             # <<<<<<<<<<<<<<
 *         self.close()
 *         self.error_all_requests(exc)
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_last_error, __pyx_v_exc) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":320
 * 
 *         self.last_error = exc
 *         self.close()             # <<<<<<<<<<<<<<
 *         self.error_all_requests(exc)
 *         self.connected_event.set()
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_close); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":321
 *         self.last_error = exc
 *         self.close()
 *         self.error_all_requests(exc)             # <<<<<<<<<<<<<<
 *         self.connected_event.set()
 *         return exc
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_error_all_requests); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_exc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = NULL;
    __Pyx_INCREF(__pyx_v_exc);
    __Pyx_GIVEREF(__pyx_v_exc);
    PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_exc);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":322
 *         self.close()
 *         self.error_all_requests(exc)
 *         self.connected_event.set()             # <<<<<<<<<<<<<<
 *         return exc
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_connected_event); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_set); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":323
 *         self.error_all_requests(exc)
 *         self.connected_event.set()
 *         return exc             # <<<<<<<<<<<<<<
 * 
 *     def error_all_requests(self, exc):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_exc);
  __pyx_r = __pyx_v_exc;
  goto __pyx_L0;

  /* "cassandra/connection.py":310
 *         raise NotImplementedError()
 * 
 *     def defunct(self, exc):             # <<<<<<<<<<<<<<
 *         with self.lock:
 *             if self.is_defunct or self.is_closed:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cassandra.connection.Connection.defunct", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":325
 *         return exc
 * 
 *     def error_all_requests(self, exc):             # <<<<<<<<<<<<<<
 *         with self.lock:
 *             requests = self._requests
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_17error_all_requests(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_17error_all_requests = {"error_all_requests", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_17error_all_requests, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_17error_all_requests(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_exc = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("error_all_requests (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_exc,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_exc)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("error_all_requests", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "error_all_requests") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_exc = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("error_all_requests", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Connection.error_all_requests", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_16error_all_requests(__pyx_self, __pyx_v_self, __pyx_v_exc);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_16error_all_requests(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_exc) {
  PyObject *__pyx_v_requests = NULL;
  PyObject *__pyx_v_new_exc = NULL;
  PyObject *__pyx_v_cb = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  Py_ssize_t __pyx_t_13;
  PyObject *(*__pyx_t_14)(PyObject *);
  PyObject *(*__pyx_t_15)(PyObject *);
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("error_all_requests", 0);

  /* "cassandra/connection.py":326
 * 
 *     def error_all_requests(self, exc):
 *         with self.lock:             # <<<<<<<<<<<<<<
 *             requests = self._requests
 *             self._requests = {}
 */
  /*with:*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lock); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    /*try:*/ {
      {
        __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_6);
        __Pyx_XGOTREF(__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_8);
        /*try:*/ {

          /* "cassandra/connection.py":327
 *     def error_all_requests(self, exc):
 *         with self.lock:
 *             requests = self._requests             # <<<<<<<<<<<<<<
 *             self._requests = {}
 *         new_exc = ConnectionShutdown(str(exc))
 */
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_requests); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_v_requests = __pyx_t_1;
          __pyx_t_1 = 0;

          /* "cassandra/connection.py":328
 *         with self.lock:
 *             requests = self._requests
 *             self._requests = {}             # <<<<<<<<<<<<<<
 *         new_exc = ConnectionShutdown(str(exc))
 *         for cb, _ in requests.values():
 */
          __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_1);
          if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_requests, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        }
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L14_try_end;
        __pyx_L7_error:;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "cassandra/connection.py":326
 * 
 *     def error_all_requests(self, exc):
 *         with self.lock:             # <<<<<<<<<<<<<<
 *             requests = self._requests
 *             self._requests = {}
 */
        /*except:*/ {
          __Pyx_AddTraceback("cassandra.connection.Connection.error_all_requests", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_5 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (__pyx_t_10 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __pyx_t_11 = ((!(__pyx_t_10 != 0)) != 0);
          if (__pyx_t_11) {
            __Pyx_GIVEREF(__pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_3);
            __Pyx_XGIVEREF(__pyx_t_4);
            __Pyx_ErrRestore(__pyx_t_1, __pyx_t_3, __pyx_t_4);
            __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_4 = 0; 
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          goto __pyx_L8_exception_handled;
        }
        __pyx_L9_except_error:;
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
        goto __pyx_L1_error;
        __pyx_L8_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
        __pyx_L14_try_end:;
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_2) {
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__13, NULL);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
        goto __pyx_L6;
      }
      __pyx_L6:;
    }
    goto __pyx_L18;
    __pyx_L3_error:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L1_error;
    __pyx_L18:;
  }

  /* "cassandra/connection.py":329
 *             requests = self._requests
 *             self._requests = {}
 *         new_exc = ConnectionShutdown(str(exc))             # <<<<<<<<<<<<<<
 *         for cb, _ in requests.values():
 *             try:
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConnectionShutdown); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_exc);
  __Pyx_GIVEREF(__pyx_v_exc);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_exc);
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_1); __pyx_t_1 = NULL;
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_new_exc = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "cassandra/connection.py":330
 *             self._requests = {}
 *         new_exc = ConnectionShutdown(str(exc))
 *         for cb, _ in requests.values():             # <<<<<<<<<<<<<<
 *             try:
 *                 cb(new_exc)
 */
  if (unlikely(!__pyx_v_requests)) { __Pyx_RaiseUnboundLocalError("requests"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_requests, __pyx_n_s_values); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_12 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_12) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_12); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
    __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3); __pyx_t_13 = 0;
    __pyx_t_14 = NULL;
  } else {
    __pyx_t_13 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_14 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  for (;;) {
    if (likely(!__pyx_t_14)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_13); __Pyx_INCREF(__pyx_t_4); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_13); __Pyx_INCREF(__pyx_t_4); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_14(__pyx_t_3);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_12 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_12 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_5);
      #else
      __pyx_t_12 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_1 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_15 = Py_TYPE(__pyx_t_1)->tp_iternext;
      index = 0; __pyx_t_12 = __pyx_t_15(__pyx_t_1); if (unlikely(!__pyx_t_12)) goto __pyx_L21_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_12);
      index = 1; __pyx_t_5 = __pyx_t_15(__pyx_t_1); if (unlikely(!__pyx_t_5)) goto __pyx_L21_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_1), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_15 = NULL;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L22_unpacking_done;
      __pyx_L21_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_15 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L22_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_cb, __pyx_t_12);
    __pyx_t_12 = 0;
    __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "cassandra/connection.py":331
 *         new_exc = ConnectionShutdown(str(exc))
 *         for cb, _ in requests.values():
 *             try:             # <<<<<<<<<<<<<<
 *                 cb(new_exc)
 *             except Exception:
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_8, &__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_2);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_7);
      /*try:*/ {

        /* "cassandra/connection.py":332
 *         for cb, _ in requests.values():
 *             try:
 *                 cb(new_exc)             # <<<<<<<<<<<<<<
 *             except Exception:
 *                 log.warning("Ignoring unhandled exception while erroring requests for a "
 */
        __Pyx_INCREF(__pyx_v_cb);
        __pyx_t_5 = __pyx_v_cb; __pyx_t_12 = NULL;
        if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_12)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        if (!__pyx_t_12) {
          __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_new_exc); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L23_error;}
          __Pyx_GOTREF(__pyx_t_4);
        } else {
          __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L23_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_12); __pyx_t_12 = NULL;
          __Pyx_INCREF(__pyx_v_new_exc);
          __Pyx_GIVEREF(__pyx_v_new_exc);
          PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_new_exc);
          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L23_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L30_try_end;
      __pyx_L23_error:;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cassandra/connection.py":333
 *             try:
 *                 cb(new_exc)
 *             except Exception:             # <<<<<<<<<<<<<<
 *                 log.warning("Ignoring unhandled exception while erroring requests for a "
 *                             "failed connection (%s) to host %s:",
 */
      __pyx_t_16 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
      if (__pyx_t_16) {
        __Pyx_AddTraceback("cassandra.connection.Connection.error_all_requests", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L25_except_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GOTREF(__pyx_t_1);

        /* "cassandra/connection.py":334
 *                 cb(new_exc)
 *             except Exception:
 *                 log.warning("Ignoring unhandled exception while erroring requests for a "             # <<<<<<<<<<<<<<
 *                             "failed connection (%s) to host %s:",
 *                             id(self), self.host, exc_info=True)
 */
        __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L25_except_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_warning); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L25_except_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

        /* "cassandra/connection.py":336
 *                 log.warning("Ignoring unhandled exception while erroring requests for a "
 *                             "failed connection (%s) to host %s:",
 *                             id(self), self.host, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *     def get_request_id(self):
 */
        __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L25_except_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_INCREF(__pyx_v_self);
        __Pyx_GIVEREF(__pyx_v_self);
        PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_self);
        __pyx_t_18 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_12, NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L25_except_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L25_except_error;}
        __Pyx_GOTREF(__pyx_t_12);

        /* "cassandra/connection.py":334
 *                 cb(new_exc)
 *             except Exception:
 *                 log.warning("Ignoring unhandled exception while erroring requests for a "             # <<<<<<<<<<<<<<
 *                             "failed connection (%s) to host %s:",
 *                             id(self), self.host, exc_info=True)
 */
        __pyx_t_19 = PyTuple_New(3); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L25_except_error;}
        __Pyx_GOTREF(__pyx_t_19);
        __Pyx_INCREF(__pyx_kp_s_Ignoring_unhandled_exception_whi);
        __Pyx_GIVEREF(__pyx_kp_s_Ignoring_unhandled_exception_whi);
        PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_kp_s_Ignoring_unhandled_exception_whi);
        __Pyx_GIVEREF(__pyx_t_18);
        PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_t_18);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_19, 2, __pyx_t_12);
        __pyx_t_18 = 0;
        __pyx_t_12 = 0;
        __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L25_except_error;}
        __Pyx_GOTREF(__pyx_t_12);

        /* "cassandra/connection.py":336
 *                 log.warning("Ignoring unhandled exception while erroring requests for a "
 *                             "failed connection (%s) to host %s:",
 *                             id(self), self.host, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *     def get_request_id(self):
 */
        if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_exc_info, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L25_except_error;}

        /* "cassandra/connection.py":334
 *                 cb(new_exc)
 *             except Exception:
 *                 log.warning("Ignoring unhandled exception while erroring requests for a "             # <<<<<<<<<<<<<<
 *                             "failed connection (%s) to host %s:",
 *                             id(self), self.host, exc_info=True)
 */
        __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_19, __pyx_t_12); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L25_except_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L24_exception_handled;
      }
      goto __pyx_L25_except_error;
      __pyx_L25_except_error:;
      __Pyx_XGIVEREF(__pyx_t_2);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_8, __pyx_t_7);
      goto __pyx_L1_error;
      __pyx_L24_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_2);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_8, __pyx_t_7);
      __pyx_L30_try_end:;
    }

    /* "cassandra/connection.py":330
 *             self._requests = {}
 *         new_exc = ConnectionShutdown(str(exc))
 *         for cb, _ in requests.values():             # <<<<<<<<<<<<<<
 *             try:
 *                 cb(new_exc)
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cassandra/connection.py":325
 *         return exc
 * 
 *     def error_all_requests(self, exc):             # <<<<<<<<<<<<<<
 *         with self.lock:
 *             requests = self._requests
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_AddTraceback("cassandra.connection.Connection.error_all_requests", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_requests);
  __Pyx_XDECREF(__pyx_v_new_exc);
  __Pyx_XDECREF(__pyx_v_cb);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":338
 *                             id(self), self.host, exc_info=True)
 * 
 *     def get_request_id(self):             # <<<<<<<<<<<<<<
 *         """
 *         This must be called while self.lock is held.
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_19get_request_id(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_9cassandra_10connection_10Connection_18get_request_id[] = "\n        This must be called while self.lock is held.\n        ";
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_19get_request_id = {"get_request_id", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_19get_request_id, METH_O, __pyx_doc_9cassandra_10connection_10Connection_18get_request_id};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_19get_request_id(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_request_id (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_18get_request_id(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_18get_request_id(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_request_id", 0);

  /* "cassandra/connection.py":342
 *         This must be called while self.lock is held.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             return self.request_ids.popleft()
 *         except IndexError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "cassandra/connection.py":343
 *         """
 *         try:
 *             return self.request_ids.popleft()             # <<<<<<<<<<<<<<
 *         except IndexError:
 *             self.highest_request_id += 1
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_request_ids); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_popleft); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      if (__pyx_t_5) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else {
        __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L7_try_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cassandra/connection.py":344
 *         try:
 *             return self.request_ids.popleft()
 *         except IndexError:             # <<<<<<<<<<<<<<
 *             self.highest_request_id += 1
 *             # in_flight checks should guarantee this
 */
    __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_IndexError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("cassandra.connection.Connection.get_request_id", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_5);

      /* "cassandra/connection.py":345
 *             return self.request_ids.popleft()
 *         except IndexError:
 *             self.highest_request_id += 1             # <<<<<<<<<<<<<<
 *             # in_flight checks should guarantee this
 *             assert self.highest_request_id <= self.max_request_id
 */
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_highest_request_id); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyNumber_InPlaceAdd(__pyx_t_8, __pyx_int_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_highest_request_id, __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "cassandra/connection.py":347
 *             self.highest_request_id += 1
 *             # in_flight checks should guarantee this
 *             assert self.highest_request_id <= self.max_request_id             # <<<<<<<<<<<<<<
 *             return self.highest_request_id
 * 
 */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!Py_OptimizeFlag)) {
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_highest_request_id); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_max_request_id); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_10 = PyObject_RichCompare(__pyx_t_9, __pyx_t_8, Py_LE); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_11)) {
          PyErr_SetNone(PyExc_AssertionError);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
        }
      }
      #endif

      /* "cassandra/connection.py":348
 *             # in_flight checks should guarantee this
 *             assert self.highest_request_id <= self.max_request_id
 *             return self.highest_request_id             # <<<<<<<<<<<<<<
 * 
 *     def handle_pushed(self, response):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_highest_request_id); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_r = __pyx_t_10;
      __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "cassandra/connection.py":338
 *                             id(self), self.host, exc_info=True)
 * 
 *     def get_request_id(self):             # <<<<<<<<<<<<<<
 *         """
 *         This must be called while self.lock is held.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cassandra.connection.Connection.get_request_id", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":350
 *             return self.highest_request_id
 * 
 *     def handle_pushed(self, response):             # <<<<<<<<<<<<<<
 *         log.debug("Message pushed from server: %r", response)
 *         for cb in self._push_watchers.get(response.event_type, []):
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_21handle_pushed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_21handle_pushed = {"handle_pushed", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_21handle_pushed, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_21handle_pushed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_response = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_pushed (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_response,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_response)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("handle_pushed", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "handle_pushed") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_response = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("handle_pushed", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Connection.handle_pushed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_20handle_pushed(__pyx_self, __pyx_v_self, __pyx_v_response);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_20handle_pushed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_response) {
  PyObject *__pyx_v_cb = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("handle_pushed", 0);

  /* "cassandra/connection.py":351
 * 
 *     def handle_pushed(self, response):
 *         log.debug("Message pushed from server: %r", response)             # <<<<<<<<<<<<<<
 *         for cb in self._push_watchers.get(response.event_type, []):
 *             try:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_2) {
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_kp_s_Message_pushed_from_server_r);
  __Pyx_GIVEREF(__pyx_kp_s_Message_pushed_from_server_r);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_kp_s_Message_pushed_from_server_r);
  __Pyx_INCREF(__pyx_v_response);
  __Pyx_GIVEREF(__pyx_v_response);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_response);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":352
 *     def handle_pushed(self, response):
 *         log.debug("Message pushed from server: %r", response)
 *         for cb in self._push_watchers.get(response.event_type, []):             # <<<<<<<<<<<<<<
 *             try:
 *                 cb(response.event_args)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_push_watchers); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_response, __pyx_n_s_event_type); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_6) {
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
  }
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_4, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_4, __pyx_t_2);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_5 = __pyx_t_1; __Pyx_INCREF(__pyx_t_5); __pyx_t_4 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_8(__pyx_t_5);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_cb, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cassandra/connection.py":353
 *         log.debug("Message pushed from server: %r", response)
 *         for cb in self._push_watchers.get(response.event_type, []):
 *             try:             # <<<<<<<<<<<<<<
 *                 cb(response.event_args)
 *             except Exception:
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      /*try:*/ {

        /* "cassandra/connection.py":354
 *         for cb in self._push_watchers.get(response.event_type, []):
 *             try:
 *                 cb(response.event_args)             # <<<<<<<<<<<<<<
 *             except Exception:
 *                 log.exception("Pushed event handler errored, ignoring:")
 */
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_response, __pyx_n_s_event_args); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_v_cb);
        __pyx_t_2 = __pyx_v_cb; __pyx_t_3 = NULL;
        if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_3)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        if (!__pyx_t_3) {
          __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_GOTREF(__pyx_t_1);
        } else {
          __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
          __Pyx_GIVEREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_7);
          __pyx_t_7 = 0;
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L12_try_end;
      __pyx_L5_error:;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cassandra/connection.py":355
 *             try:
 *                 cb(response.event_args)
 *             except Exception:             # <<<<<<<<<<<<<<
 *                 log.exception("Pushed event handler errored, ignoring:")
 * 
 */
      __pyx_t_12 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
      if (__pyx_t_12) {
        __Pyx_AddTraceback("cassandra.connection.Connection.handle_pushed", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_6);

        /* "cassandra/connection.py":356
 *                 cb(response.event_args)
 *             except Exception:
 *                 log.exception("Pushed event handler errored, ignoring:")             # <<<<<<<<<<<<<<
 * 
 *     def send_msg(self, msg, request_id, cb, encoder=ProtocolHandler.encode_message, decoder=ProtocolHandler.decode_message):
 */
        __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_exception); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L6_exception_handled;
      }
      goto __pyx_L7_except_error;
      __pyx_L7_except_error:;
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      goto __pyx_L1_error;
      __pyx_L6_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      __pyx_L12_try_end:;
    }

    /* "cassandra/connection.py":352
 *     def handle_pushed(self, response):
 *         log.debug("Message pushed from server: %r", response)
 *         for cb in self._push_watchers.get(response.event_type, []):             # <<<<<<<<<<<<<<
 *             try:
 *                 cb(response.event_args)
 */
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cassandra/connection.py":350
 *             return self.highest_request_id
 * 
 *     def handle_pushed(self, response):             # <<<<<<<<<<<<<<
 *         log.debug("Message pushed from server: %r", response)
 *         for cb in self._push_watchers.get(response.event_type, []):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cassandra.connection.Connection.handle_pushed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_cb);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":358
 *                 log.exception("Pushed event handler errored, ignoring:")
 * 
 *     def send_msg(self, msg, request_id, cb, encoder=ProtocolHandler.encode_message, decoder=ProtocolHandler.decode_message):             # <<<<<<<<<<<<<<
 *         if self.is_defunct:
 *             raise ConnectionShutdown("Connection to %s is defunct" % self.host)
 */

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_64__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__defaults__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self)->__pyx_arg_encoder);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self)->__pyx_arg_encoder);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self)->__pyx_arg_encoder);
  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self)->__pyx_arg_decoder);
  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self)->__pyx_arg_decoder);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self)->__pyx_arg_decoder);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None);
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("cassandra.connection.Connection.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_23send_msg(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_23send_msg = {"send_msg", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_23send_msg, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_23send_msg(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_msg = 0;
  PyObject *__pyx_v_request_id = 0;
  PyObject *__pyx_v_cb = 0;
  PyObject *__pyx_v_encoder = 0;
  PyObject *__pyx_v_decoder = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("send_msg (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_msg,&__pyx_n_s_request_id,&__pyx_n_s_cb,&__pyx_n_s_encoder,&__pyx_n_s_decoder,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    __pyx_defaults1 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self);
    values[4] = __pyx_dynamic_args->__pyx_arg_encoder;
    values[5] = __pyx_dynamic_args->__pyx_arg_decoder;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_msg)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("send_msg", 0, 4, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_request_id)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("send_msg", 0, 4, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cb)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("send_msg", 0, 4, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_encoder);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_decoder);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "send_msg") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_msg = values[1];
    __pyx_v_request_id = values[2];
    __pyx_v_cb = values[3];
    __pyx_v_encoder = values[4];
    __pyx_v_decoder = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("send_msg", 0, 4, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Connection.send_msg", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_22send_msg(__pyx_self, __pyx_v_self, __pyx_v_msg, __pyx_v_request_id, __pyx_v_cb, __pyx_v_encoder, __pyx_v_decoder);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_22send_msg(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_msg, PyObject *__pyx_v_request_id, PyObject *__pyx_v_cb, PyObject *__pyx_v_encoder, PyObject *__pyx_v_decoder) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("send_msg", 0);

  /* "cassandra/connection.py":359
 * 
 *     def send_msg(self, msg, request_id, cb, encoder=ProtocolHandler.encode_message, decoder=ProtocolHandler.decode_message):
 *         if self.is_defunct:             # <<<<<<<<<<<<<<
 *             raise ConnectionShutdown("Connection to %s is defunct" % self.host)
 *         elif self.is_closed:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_is_defunct); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cassandra/connection.py":360
 *     def send_msg(self, msg, request_id, cb, encoder=ProtocolHandler.encode_message, decoder=ProtocolHandler.decode_message):
 *         if self.is_defunct:
 *             raise ConnectionShutdown("Connection to %s is defunct" % self.host)             # <<<<<<<<<<<<<<
 *         elif self.is_closed:
 *             raise ConnectionShutdown("Connection to %s is closed" % self.host)
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConnectionShutdown); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Connection_to_s_is_defunct, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cassandra/connection.py":361
 *         if self.is_defunct:
 *             raise ConnectionShutdown("Connection to %s is defunct" % self.host)
 *         elif self.is_closed:             # <<<<<<<<<<<<<<
 *             raise ConnectionShutdown("Connection to %s is closed" % self.host)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_is_closed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cassandra/connection.py":362
 *             raise ConnectionShutdown("Connection to %s is defunct" % self.host)
 *         elif self.is_closed:
 *             raise ConnectionShutdown("Connection to %s is closed" % self.host)             # <<<<<<<<<<<<<<
 * 
 *         # queue the decoder function with the request
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConnectionShutdown); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Connection_to_s_is_closed, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cassandra/connection.py":366
 *         # queue the decoder function with the request
 *         # this allows us to inject custom functions per request to encode, decode messages
 *         self._requests[request_id] = (cb, decoder)             # <<<<<<<<<<<<<<
 *         self.push(encoder(msg, request_id, self.protocol_version, compressor=self.compressor))
 *         return request_id
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_cb);
  __Pyx_GIVEREF(__pyx_v_cb);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_cb);
  __Pyx_INCREF(__pyx_v_decoder);
  __Pyx_GIVEREF(__pyx_v_decoder);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_decoder);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_requests); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (unlikely(PyObject_SetItem(__pyx_t_3, __pyx_v_request_id, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":367
 *         # this allows us to inject custom functions per request to encode, decode messages
 *         self._requests[request_id] = (cb, decoder)
 *         self.push(encoder(msg, request_id, self.protocol_version, compressor=self.compressor))             # <<<<<<<<<<<<<<
 *         return request_id
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_push); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_protocol_version); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_msg);
  __Pyx_GIVEREF(__pyx_v_msg);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_msg);
  __Pyx_INCREF(__pyx_v_request_id);
  __Pyx_GIVEREF(__pyx_v_request_id);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_request_id);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_compressor); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_compressor, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_v_encoder, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":368
 *         self._requests[request_id] = (cb, decoder)
 *         self.push(encoder(msg, request_id, self.protocol_version, compressor=self.compressor))
 *         return request_id             # <<<<<<<<<<<<<<
 * 
 *     def wait_for_response(self, msg, timeout=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_request_id);
  __pyx_r = __pyx_v_request_id;
  goto __pyx_L0;

  /* "cassandra/connection.py":358
 *                 log.exception("Pushed event handler errored, ignoring:")
 * 
 *     def send_msg(self, msg, request_id, cb, encoder=ProtocolHandler.encode_message, decoder=ProtocolHandler.decode_message):             # <<<<<<<<<<<<<<
 *         if self.is_defunct:
 *             raise ConnectionShutdown("Connection to %s is defunct" % self.host)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cassandra.connection.Connection.send_msg", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":370
 *         return request_id
 * 
 *     def wait_for_response(self, msg, timeout=None):             # <<<<<<<<<<<<<<
 *         return self.wait_for_responses(msg, timeout=timeout)[0]
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_25wait_for_response(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_25wait_for_response = {"wait_for_response", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_25wait_for_response, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_25wait_for_response(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_msg = 0;
  PyObject *__pyx_v_timeout = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("wait_for_response (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_msg,&__pyx_n_s_timeout,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_msg)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("wait_for_response", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wait_for_response") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_msg = values[1];
    __pyx_v_timeout = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("wait_for_response", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Connection.wait_for_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_24wait_for_response(__pyx_self, __pyx_v_self, __pyx_v_msg, __pyx_v_timeout);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_24wait_for_response(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_msg, PyObject *__pyx_v_timeout) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("wait_for_response", 0);

  /* "cassandra/connection.py":371
 * 
 *     def wait_for_response(self, msg, timeout=None):
 *         return self.wait_for_responses(msg, timeout=timeout)[0]             # <<<<<<<<<<<<<<
 * 
 *     def wait_for_responses(self, *msgs, **kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_wait_for_responses); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_msg);
  __Pyx_GIVEREF(__pyx_v_msg);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_msg);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_timeout, __pyx_v_timeout) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "cassandra/connection.py":370
 *         return request_id
 * 
 *     def wait_for_response(self, msg, timeout=None):             # <<<<<<<<<<<<<<
 *         return self.wait_for_responses(msg, timeout=timeout)[0]
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cassandra.connection.Connection.wait_for_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":373
 *         return self.wait_for_responses(msg, timeout=timeout)[0]
 * 
 *     def wait_for_responses(self, *msgs, **kwargs):             # <<<<<<<<<<<<<<
 *         """
 *         Returns a list of (success, response) tuples.  If success
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_27wait_for_responses(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9cassandra_10connection_10Connection_26wait_for_responses[] = "\n        Returns a list of (success, response) tuples.  If success\n        is False, response will be an Exception.  Otherwise, response\n        will be the normal query response.\n\n        If fail_on_error was left as True and one of the requests\n        failed, the corresponding Exception will be raised.\n        ";
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_27wait_for_responses = {"wait_for_responses", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_27wait_for_responses, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9cassandra_10connection_10Connection_26wait_for_responses};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_27wait_for_responses(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_msgs = 0;
  PyObject *__pyx_v_kwargs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("wait_for_responses (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_msgs = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_msgs)) {
      __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
      __Pyx_RefNannyFinishContext();
      return NULL;
    }
    __Pyx_GOTREF(__pyx_v_msgs);
  } else {
    __pyx_v_msgs = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        default:
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, used_pos_args, "wait_for_responses") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("wait_for_responses", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_msgs); __pyx_v_msgs = 0;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("cassandra.connection.Connection.wait_for_responses", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_26wait_for_responses(__pyx_self, __pyx_v_self, __pyx_v_msgs, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_msgs);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_26wait_for_responses(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_msgs, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_timeout = NULL;
  PyObject *__pyx_v_fail_on_error = NULL;
  PyObject *__pyx_v_waiter = NULL;
  PyObject *__pyx_v_messages_sent = NULL;
  PyObject *__pyx_v_needed = NULL;
  PyObject *__pyx_v_available = NULL;
  PyObject *__pyx_v_request_ids = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_request_id = NULL;
  PyObject *__pyx_v_exc = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  Py_ssize_t __pyx_t_19;
  int __pyx_t_20;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("wait_for_responses", 0);

  /* "cassandra/connection.py":382
 *         failed, the corresponding Exception will be raised.
 *         """
 *         if self.is_closed or self.is_defunct:             # <<<<<<<<<<<<<<
 *             raise ConnectionShutdown("Connection %s is already closed" % (self, ))
 *         timeout = kwargs.get('timeout')
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_is_closed); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_is_defunct); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "cassandra/connection.py":383
 *         """
 *         if self.is_closed or self.is_defunct:
 *             raise ConnectionShutdown("Connection %s is already closed" % (self, ))             # <<<<<<<<<<<<<<
 *         timeout = kwargs.get('timeout')
 *         fail_on_error = kwargs.get('fail_on_error', True)
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConnectionShutdown); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_self);
    __Pyx_GIVEREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
    __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_Connection_s_is_already_closed, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cassandra/connection.py":384
 *         if self.is_closed or self.is_defunct:
 *             raise ConnectionShutdown("Connection %s is already closed" % (self, ))
 *         timeout = kwargs.get('timeout')             # <<<<<<<<<<<<<<
 *         fail_on_error = kwargs.get('fail_on_error', True)
 *         waiter = ResponseWaiter(self, len(msgs), fail_on_error)
 */
  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_kwargs, __pyx_n_s_timeout, Py_None); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_timeout = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cassandra/connection.py":385
 *             raise ConnectionShutdown("Connection %s is already closed" % (self, ))
 *         timeout = kwargs.get('timeout')
 *         fail_on_error = kwargs.get('fail_on_error', True)             # <<<<<<<<<<<<<<
 *         waiter = ResponseWaiter(self, len(msgs), fail_on_error)
 * 
 */
  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_kwargs, __pyx_n_s_fail_on_error, Py_True); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_fail_on_error = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cassandra/connection.py":386
 *         timeout = kwargs.get('timeout')
 *         fail_on_error = kwargs.get('fail_on_error', True)
 *         waiter = ResponseWaiter(self, len(msgs), fail_on_error)             # <<<<<<<<<<<<<<
 * 
 *         # busy wait for sufficient space on the connection
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_ResponseWaiter); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = PyTuple_GET_SIZE(__pyx_v_msgs); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_8 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_6) {
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
  }
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_8, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_8, __pyx_t_7);
  __Pyx_INCREF(__pyx_v_fail_on_error);
  __Pyx_GIVEREF(__pyx_v_fail_on_error);
  PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_8, __pyx_v_fail_on_error);
  __pyx_t_7 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_waiter = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "cassandra/connection.py":389
 * 
 *         # busy wait for sufficient space on the connection
 *         messages_sent = 0             # <<<<<<<<<<<<<<
 *         while True:
 *             needed = len(msgs) - messages_sent
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_messages_sent = __pyx_int_0;

  /* "cassandra/connection.py":390
 *         # busy wait for sufficient space on the connection
 *         messages_sent = 0
 *         while True:             # <<<<<<<<<<<<<<
 *             needed = len(msgs) - messages_sent
 *             with self.lock:
 */
  while (1) {

    /* "cassandra/connection.py":391
 *         messages_sent = 0
 *         while True:
 *             needed = len(msgs) - messages_sent             # <<<<<<<<<<<<<<
 *             with self.lock:
 *                 available = min(needed, self.max_request_id - self.in_flight)
 */
    __pyx_t_8 = PyTuple_GET_SIZE(__pyx_v_msgs); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyNumber_Subtract(__pyx_t_2, __pyx_v_messages_sent); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_needed, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cassandra/connection.py":392
 *         while True:
 *             needed = len(msgs) - messages_sent
 *             with self.lock:             # <<<<<<<<<<<<<<
 *                 available = min(needed, self.max_request_id - self.in_flight)
 *                 request_ids = [self.get_request_id() for _ in range(available)]
 */
    /*with:*/ {
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lock); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_n_s_exit); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_n_s_enter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (__pyx_t_7) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      }
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      /*try:*/ {
        {
          __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_12);
          /*try:*/ {

            /* "cassandra/connection.py":393
 *             needed = len(msgs) - messages_sent
 *             with self.lock:
 *                 available = min(needed, self.max_request_id - self.in_flight)             # <<<<<<<<<<<<<<
 *                 request_ids = [self.get_request_id() for _ in range(available)]
 *                 self.in_flight += available
 */
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_max_request_id); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_flight); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_5 = PyNumber_Subtract(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_INCREF(__pyx_v_needed);
            __pyx_t_2 = __pyx_v_needed;
            __pyx_t_7 = PyObject_RichCompare(__pyx_t_5, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
            __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (__pyx_t_1) {
              __Pyx_INCREF(__pyx_t_5);
              __pyx_t_4 = __pyx_t_5;
            } else {
              __Pyx_INCREF(__pyx_t_2);
              __pyx_t_4 = __pyx_t_2;
            }
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_5 = __pyx_t_4;
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF_SET(__pyx_v_available, __pyx_t_5);
            __pyx_t_5 = 0;

            /* "cassandra/connection.py":394
 *             with self.lock:
 *                 available = min(needed, self.max_request_id - self.in_flight)
 *                 request_ids = [self.get_request_id() for _ in range(available)]             # <<<<<<<<<<<<<<
 *                 self.in_flight += available
 * 
 */
            __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_range); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_7 = NULL;
            if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
              __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
              if (likely(__pyx_t_7)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
                __Pyx_INCREF(__pyx_t_7);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_2, function);
              }
            }
            if (!__pyx_t_7) {
              __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_available); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
              __Pyx_GOTREF(__pyx_t_4);
            } else {
              __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL;
              __Pyx_INCREF(__pyx_v_available);
              __Pyx_GIVEREF(__pyx_v_available);
              PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_available);
              __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            }
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
              __pyx_t_2 = __pyx_t_4; __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = 0;
              __pyx_t_13 = NULL;
            } else {
              __pyx_t_8 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_13 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
            }
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            for (;;) {
              if (likely(!__pyx_t_13)) {
                if (likely(PyList_CheckExact(__pyx_t_2))) {
                  if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_2)) break;
                  #if CYTHON_COMPILING_IN_CPYTHON
                  __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
                  #else
                  __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
                  __Pyx_GOTREF(__pyx_t_4);
                  #endif
                } else {
                  if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
                  #if CYTHON_COMPILING_IN_CPYTHON
                  __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
                  #else
                  __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
                  __Pyx_GOTREF(__pyx_t_4);
                  #endif
                }
              } else {
                __pyx_t_4 = __pyx_t_13(__pyx_t_2);
                if (unlikely(!__pyx_t_4)) {
                  PyObject* exc_type = PyErr_Occurred();
                  if (exc_type) {
                    if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                    else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
                  }
                  break;
                }
                __Pyx_GOTREF(__pyx_t_4);
              }
              __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_4);
              __pyx_t_4 = 0;
              __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_get_request_id); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_7 = NULL;
              if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
                __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
                if (likely(__pyx_t_7)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
                  __Pyx_INCREF(__pyx_t_7);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_6, function);
                }
              }
              if (__pyx_t_7) {
                __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              } else {
                __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
              }
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            }
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF_SET(__pyx_v_request_ids, ((PyObject*)__pyx_t_5));
            __pyx_t_5 = 0;

            /* "cassandra/connection.py":395
 *                 available = min(needed, self.max_request_id - self.in_flight)
 *                 request_ids = [self.get_request_id() for _ in range(available)]
 *                 self.in_flight += available             # <<<<<<<<<<<<<<
 * 
 *             for i, request_id in enumerate(request_ids):
 */
            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_in_flight); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_v_available); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_in_flight, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          }
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          goto __pyx_L21_try_end;
          __pyx_L14_error:;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "cassandra/connection.py":392
 *         while True:
 *             needed = len(msgs) - messages_sent
 *             with self.lock:             # <<<<<<<<<<<<<<
 *                 available = min(needed, self.max_request_id - self.in_flight)
 *                 request_ids = [self.get_request_id() for _ in range(available)]
 */
          /*except:*/ {
            __Pyx_AddTraceback("cassandra.connection.Connection.wait_for_responses", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_5, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_6 = PyTuple_Pack(3, __pyx_t_2, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_6, NULL);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
            __Pyx_GOTREF(__pyx_t_14);
            __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_14);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            if (__pyx_t_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
            __pyx_t_3 = ((!(__pyx_t_1 != 0)) != 0);
            if (__pyx_t_3) {
              __Pyx_GIVEREF(__pyx_t_2);
              __Pyx_GIVEREF(__pyx_t_5);
              __Pyx_XGIVEREF(__pyx_t_4);
              __Pyx_ErrRestore(__pyx_t_2, __pyx_t_5, __pyx_t_4);
              __pyx_t_2 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0; 
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
            }
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            goto __pyx_L15_exception_handled;
          }
          __pyx_L16_except_error:;
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          goto __pyx_L1_error;
          __pyx_L15_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          __pyx_L21_try_end:;
        }
      }
      /*finally:*/ {
        /*normal exit:*/{
          if (__pyx_t_9) {
            __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__15, NULL);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          }
          goto __pyx_L13;
        }
        __pyx_L13:;
      }
      goto __pyx_L27;
      __pyx_L8_error:;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L1_error;
      __pyx_L27:;
    }

    /* "cassandra/connection.py":397
 *                 self.in_flight += available
 * 
 *             for i, request_id in enumerate(request_ids):             # <<<<<<<<<<<<<<
 *                 self.send_msg(msgs[messages_sent + i],
 *                               request_id,
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_4 = __pyx_int_0;
    if (unlikely(!__pyx_v_request_ids)) { __Pyx_RaiseUnboundLocalError("request_ids"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __pyx_t_5 = __pyx_v_request_ids; __Pyx_INCREF(__pyx_t_5); __pyx_t_8 = 0;
    for (;;) {
      if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_5)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_request_id, __pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_4);
      __pyx_t_2 = PyNumber_Add(__pyx_t_4, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4);
      __pyx_t_4 = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "cassandra/connection.py":398
 * 
 *             for i, request_id in enumerate(request_ids):
 *                 self.send_msg(msgs[messages_sent + i],             # <<<<<<<<<<<<<<
 *                               request_id,
 *                               partial(waiter.got_response, index=messages_sent + i))
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send_msg); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyNumber_Add(__pyx_v_messages_sent, __pyx_v_i); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_15 = PyObject_GetItem(__pyx_v_msgs, __pyx_t_7); if (unlikely(__pyx_t_15 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "cassandra/connection.py":400
 *                 self.send_msg(msgs[messages_sent + i],
 *                               request_id,
 *                               partial(waiter.got_response, index=messages_sent + i))             # <<<<<<<<<<<<<<
 *             messages_sent += available
 * 
 */
      __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_partial); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_got_response); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_17 = PyTuple_New(1); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_16);
      PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_16);
      __pyx_t_16 = 0;
      __pyx_t_16 = PyDict_New(); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_18 = PyNumber_Add(__pyx_v_messages_sent, __pyx_v_i); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_18);
      if (PyDict_SetItem(__pyx_t_16, __pyx_n_s_index, __pyx_t_18) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_17, __pyx_t_16); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_18);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_16 = NULL;
      __pyx_t_19 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_16)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_16);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
          __pyx_t_19 = 1;
        }
      }
      __pyx_t_17 = PyTuple_New(3+__pyx_t_19); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      if (__pyx_t_16) {
        __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_16); __pyx_t_16 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_19, __pyx_t_15);
      __Pyx_INCREF(__pyx_v_request_id);
      __Pyx_GIVEREF(__pyx_v_request_id);
      PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_19, __pyx_v_request_id);
      __Pyx_GIVEREF(__pyx_t_18);
      PyTuple_SET_ITEM(__pyx_t_17, 2+__pyx_t_19, __pyx_t_18);
      __pyx_t_15 = 0;
      __pyx_t_18 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_17, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cassandra/connection.py":397
 *                 self.in_flight += available
 * 
 *             for i, request_id in enumerate(request_ids):             # <<<<<<<<<<<<<<
 *                 self.send_msg(msgs[messages_sent + i],
 *                               request_id,
 */
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cassandra/connection.py":401
 *                               request_id,
 *                               partial(waiter.got_response, index=messages_sent + i))
 *             messages_sent += available             # <<<<<<<<<<<<<<
 * 
 *             if messages_sent == len(msgs):
 */
    if (unlikely(!__pyx_v_available)) { __Pyx_RaiseUnboundLocalError("available"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_messages_sent, __pyx_v_available); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_messages_sent, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "cassandra/connection.py":403
 *             messages_sent += available
 * 
 *             if messages_sent == len(msgs):             # <<<<<<<<<<<<<<
 *                 break
 *             else:
 */
    __pyx_t_8 = PyTuple_GET_SIZE(__pyx_v_msgs); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_RichCompare(__pyx_v_messages_sent, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_3) {

      /* "cassandra/connection.py":404
 * 
 *             if messages_sent == len(msgs):
 *                 break             # <<<<<<<<<<<<<<
 *             else:
 *                 if timeout is not None:
 */
      goto __pyx_L7_break;
    }
    /*else*/ {

      /* "cassandra/connection.py":406
 *                 break
 *             else:
 *                 if timeout is not None:             # <<<<<<<<<<<<<<
 *                     timeout -= 0.01
 *                     if timeout <= 0.0:
 */
      __pyx_t_3 = (__pyx_v_timeout != Py_None);
      __pyx_t_1 = (__pyx_t_3 != 0);
      if (__pyx_t_1) {

        /* "cassandra/connection.py":407
 *             else:
 *                 if timeout is not None:
 *                     timeout -= 0.01             # <<<<<<<<<<<<<<
 *                     if timeout <= 0.0:
 *                         raise OperationTimedOut()
 */
        __pyx_t_5 = PyNumber_InPlaceSubtract(__pyx_v_timeout, __pyx_float_0_01); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF_SET(__pyx_v_timeout, __pyx_t_5);
        __pyx_t_5 = 0;

        /* "cassandra/connection.py":408
 *                 if timeout is not None:
 *                     timeout -= 0.01
 *                     if timeout <= 0.0:             # <<<<<<<<<<<<<<
 *                         raise OperationTimedOut()
 *                 time.sleep(0.01)
 */
        __pyx_t_5 = PyObject_RichCompare(__pyx_v_timeout, __pyx_float_0_0, Py_LE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (__pyx_t_1) {

          /* "cassandra/connection.py":409
 *                     timeout -= 0.01
 *                     if timeout <= 0.0:
 *                         raise OperationTimedOut()             # <<<<<<<<<<<<<<
 *                 time.sleep(0.01)
 * 
 */
          __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_OperationTimedOut); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_2 = NULL;
          if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
            if (likely(__pyx_t_2)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_4, function);
            }
          }
          if (__pyx_t_2) {
            __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          } else {
            __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_Raise(__pyx_t_5, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        goto __pyx_L31;
      }
      __pyx_L31:;

      /* "cassandra/connection.py":410
 *                     if timeout <= 0.0:
 *                         raise OperationTimedOut()
 *                 time.sleep(0.01)             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_time); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_sleep); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  __pyx_L7_break:;

  /* "cassandra/connection.py":412
 *                 time.sleep(0.01)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             return waiter.deliver(timeout)
 *         except OperationTimedOut:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_12, &__pyx_t_11);
    __Pyx_XGOTREF(__pyx_t_9);
    __Pyx_XGOTREF(__pyx_t_12);
    __Pyx_XGOTREF(__pyx_t_11);
    /*try:*/ {

      /* "cassandra/connection.py":413
 * 
 *         try:
 *             return waiter.deliver(timeout)             # <<<<<<<<<<<<<<
 *         except OperationTimedOut:
 *             raise
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_waiter, __pyx_n_s_deliver); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_2) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_timeout); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
        __Pyx_GOTREF(__pyx_t_5);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL;
        __Pyx_INCREF(__pyx_v_timeout);
        __Pyx_GIVEREF(__pyx_v_timeout);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_timeout);
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_5;
      __pyx_t_5 = 0;
      goto __pyx_L37_try_return;
    }
    __pyx_L33_error:;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cassandra/connection.py":414
 *         try:
 *             return waiter.deliver(timeout)
 *         except OperationTimedOut:             # <<<<<<<<<<<<<<
 *             raise
 *         except Exception as exc:
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_OperationTimedOut); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L35_except_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_20 = PyErr_ExceptionMatches(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_20) {
      __Pyx_AddTraceback("cassandra.connection.Connection.wait_for_responses", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L35_except_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);

      /* "cassandra/connection.py":415
 *             return waiter.deliver(timeout)
 *         except OperationTimedOut:
 *             raise             # <<<<<<<<<<<<<<
 *         except Exception as exc:
 *             self.defunct(exc)
 */
      __Pyx_GIVEREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_ErrRestore(__pyx_t_5, __pyx_t_4, __pyx_t_6);
      __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_6 = 0; 
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L35_except_error;}
    }

    /* "cassandra/connection.py":416
 *         except OperationTimedOut:
 *             raise
 *         except Exception as exc:             # <<<<<<<<<<<<<<
 *             self.defunct(exc)
 *             raise
 */
    __pyx_t_20 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
    if (__pyx_t_20) {
      __Pyx_AddTraceback("cassandra.connection.Connection.wait_for_responses", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_4, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L35_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __pyx_v_exc = __pyx_t_4;

      /* "cassandra/connection.py":417
 *             raise
 *         except Exception as exc:
 *             self.defunct(exc)             # <<<<<<<<<<<<<<
 *             raise
 * 
 */
      __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_defunct); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L35_except_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_18 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_17))) {
        __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_17);
        if (likely(__pyx_t_18)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
          __Pyx_INCREF(__pyx_t_18);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_17, function);
        }
      }
      if (!__pyx_t_18) {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_17, __pyx_v_exc); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L35_except_error;}
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L35_except_error;}
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_18); __pyx_t_18 = NULL;
        __Pyx_INCREF(__pyx_v_exc);
        __Pyx_GIVEREF(__pyx_v_exc);
        PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_v_exc);
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_15, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L35_except_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      }
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "cassandra/connection.py":418
 *         except Exception as exc:
 *             self.defunct(exc)
 *             raise             # <<<<<<<<<<<<<<
 * 
 *     def register_watcher(self, event_type, callback, register_timeout=None):
 */
      __Pyx_GIVEREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_ErrRestore(__pyx_t_6, __pyx_t_4, __pyx_t_5);
      __pyx_t_6 = 0; __pyx_t_4 = 0; __pyx_t_5 = 0; 
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L35_except_error;}
    }
    goto __pyx_L35_except_error;
    __pyx_L35_except_error:;
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_12, __pyx_t_11);
    goto __pyx_L1_error;
    __pyx_L37_try_return:;
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_12, __pyx_t_11);
    goto __pyx_L0;
  }

  /* "cassandra/connection.py":373
 *         return self.wait_for_responses(msg, timeout=timeout)[0]
 * 
 *     def wait_for_responses(self, *msgs, **kwargs):             # <<<<<<<<<<<<<<
 *         """
 *         Returns a list of (success, response) tuples.  If success
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_AddTraceback("cassandra.connection.Connection.wait_for_responses", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_timeout);
  __Pyx_XDECREF(__pyx_v_fail_on_error);
  __Pyx_XDECREF(__pyx_v_waiter);
  __Pyx_XDECREF(__pyx_v_messages_sent);
  __Pyx_XDECREF(__pyx_v_needed);
  __Pyx_XDECREF(__pyx_v_available);
  __Pyx_XDECREF(__pyx_v_request_ids);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_request_id);
  __Pyx_XDECREF(__pyx_v_exc);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":420
 *             raise
 * 
 *     def register_watcher(self, event_type, callback, register_timeout=None):             # <<<<<<<<<<<<<<
 *         """
 *         Register a callback for a given event type.
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_29register_watcher(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9cassandra_10connection_10Connection_28register_watcher[] = "\n        Register a callback for a given event type.\n        ";
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_29register_watcher = {"register_watcher", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_29register_watcher, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9cassandra_10connection_10Connection_28register_watcher};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_29register_watcher(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_event_type = 0;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_v_register_timeout = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("register_watcher (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_event_type,&__pyx_n_s_callback,&__pyx_n_s_register_timeout,0};
    PyObject* values[4] = {0,0,0,0};
    values[3] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_event_type)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("register_watcher", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("register_watcher", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_register_timeout);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "register_watcher") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_event_type = values[1];
    __pyx_v_callback = values[2];
    __pyx_v_register_timeout = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("register_watcher", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Connection.register_watcher", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_28register_watcher(__pyx_self, __pyx_v_self, __pyx_v_event_type, __pyx_v_callback, __pyx_v_register_timeout);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_28register_watcher(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_event_type, PyObject *__pyx_v_callback, PyObject *__pyx_v_register_timeout) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("register_watcher", 0);

  /* "cassandra/connection.py":424
 *         Register a callback for a given event type.
 *         """
 *         self._push_watchers[event_type].add(callback)             # <<<<<<<<<<<<<<
 *         self.wait_for_response(
 *             RegisterMessage(event_list=[event_type]),
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_push_watchers); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetItem(__pyx_t_2, __pyx_v_event_type); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_add); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_callback); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
    __Pyx_INCREF(__pyx_v_callback);
    __Pyx_GIVEREF(__pyx_v_callback);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_callback);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":425
 *         """
 *         self._push_watchers[event_type].add(callback)
 *         self.wait_for_response(             # <<<<<<<<<<<<<<
 *             RegisterMessage(event_list=[event_type]),
 *             timeout=register_timeout)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_wait_for_response); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "cassandra/connection.py":426
 *         self._push_watchers[event_type].add(callback)
 *         self.wait_for_response(
 *             RegisterMessage(event_list=[event_type]),             # <<<<<<<<<<<<<<
 *             timeout=register_timeout)
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_RegisterMessage); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_event_type);
  __Pyx_GIVEREF(__pyx_v_event_type);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_event_type);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_event_list, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cassandra/connection.py":425
 *         """
 *         self._push_watchers[event_type].add(callback)
 *         self.wait_for_response(             # <<<<<<<<<<<<<<
 *             RegisterMessage(event_list=[event_type]),
 *             timeout=register_timeout)
 */
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "cassandra/connection.py":427
 *         self.wait_for_response(
 *             RegisterMessage(event_list=[event_type]),
 *             timeout=register_timeout)             # <<<<<<<<<<<<<<
 * 
 *     def register_watchers(self, type_callback_dict, register_timeout=None):
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_timeout, __pyx_v_register_timeout) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":425
 *         """
 *         self._push_watchers[event_type].add(callback)
 *         self.wait_for_response(             # <<<<<<<<<<<<<<
 *             RegisterMessage(event_list=[event_type]),
 *             timeout=register_timeout)
 */
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":420
 *             raise
 * 
 *     def register_watcher(self, event_type, callback, register_timeout=None):             # <<<<<<<<<<<<<<
 *         """
 *         Register a callback for a given event type.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cassandra.connection.Connection.register_watcher", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":429
 *             timeout=register_timeout)
 * 
 *     def register_watchers(self, type_callback_dict, register_timeout=None):             # <<<<<<<<<<<<<<
 *         """
 *         Register multiple callback/event type pairs, expressed as a dict.
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_31register_watchers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9cassandra_10connection_10Connection_30register_watchers[] = "\n        Register multiple callback/event type pairs, expressed as a dict.\n        ";
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_31register_watchers = {"register_watchers", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_31register_watchers, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9cassandra_10connection_10Connection_30register_watchers};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_31register_watchers(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_type_callback_dict = 0;
  PyObject *__pyx_v_register_timeout = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("register_watchers (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_type_callback_dict,&__pyx_n_s_register_timeout,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_type_callback_dict)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("register_watchers", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_register_timeout);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "register_watchers") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_type_callback_dict = values[1];
    __pyx_v_register_timeout = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("register_watchers", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Connection.register_watchers", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_30register_watchers(__pyx_self, __pyx_v_self, __pyx_v_type_callback_dict, __pyx_v_register_timeout);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_30register_watchers(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_type_callback_dict, PyObject *__pyx_v_register_timeout) {
  PyObject *__pyx_v_event_type = NULL;
  PyObject *__pyx_v_callback = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("register_watchers", 0);

  /* "cassandra/connection.py":433
 *         Register multiple callback/event type pairs, expressed as a dict.
 *         """
 *         for event_type, callback in type_callback_dict.items():             # <<<<<<<<<<<<<<
 *             self._push_watchers[event_type].add(callback)
 *         self.wait_for_response(
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_type_callback_dict, __pyx_n_s_items); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_event_type, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_callback, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "cassandra/connection.py":434
 *         """
 *         for event_type, callback in type_callback_dict.items():
 *             self._push_watchers[event_type].add(callback)             # <<<<<<<<<<<<<<
 *         self.wait_for_response(
 *             RegisterMessage(event_list=type_callback_dict.keys()),
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_push_watchers); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyObject_GetItem(__pyx_t_6, __pyx_v_event_type); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_add); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_callback); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_callback);
      __Pyx_GIVEREF(__pyx_v_callback);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_callback);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cassandra/connection.py":433
 *         Register multiple callback/event type pairs, expressed as a dict.
 *         """
 *         for event_type, callback in type_callback_dict.items():             # <<<<<<<<<<<<<<
 *             self._push_watchers[event_type].add(callback)
 *         self.wait_for_response(
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":435
 *         for event_type, callback in type_callback_dict.items():
 *             self._push_watchers[event_type].add(callback)
 *         self.wait_for_response(             # <<<<<<<<<<<<<<
 *             RegisterMessage(event_list=type_callback_dict.keys()),
 *             timeout=register_timeout)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_wait_for_response); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "cassandra/connection.py":436
 *             self._push_watchers[event_type].add(callback)
 *         self.wait_for_response(
 *             RegisterMessage(event_list=type_callback_dict.keys()),             # <<<<<<<<<<<<<<
 *             timeout=register_timeout)
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_RegisterMessage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_type_callback_dict, __pyx_n_s_keys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_9 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_9) {
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else {
    __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_event_list, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cassandra/connection.py":435
 *         for event_type, callback in type_callback_dict.items():
 *             self._push_watchers[event_type].add(callback)
 *         self.wait_for_response(             # <<<<<<<<<<<<<<
 *             RegisterMessage(event_list=type_callback_dict.keys()),
 *             timeout=register_timeout)
 */
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);

  /* "cassandra/connection.py":437
 *         self.wait_for_response(
 *             RegisterMessage(event_list=type_callback_dict.keys()),
 *             timeout=register_timeout)             # <<<<<<<<<<<<<<
 * 
 *     def control_conn_disposed(self):
 */
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_timeout, __pyx_v_register_timeout) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":435
 *         for event_type, callback in type_callback_dict.items():
 *             self._push_watchers[event_type].add(callback)
 *         self.wait_for_response(             # <<<<<<<<<<<<<<
 *             RegisterMessage(event_list=type_callback_dict.keys()),
 *             timeout=register_timeout)
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":429
 *             timeout=register_timeout)
 * 
 *     def register_watchers(self, type_callback_dict, register_timeout=None):             # <<<<<<<<<<<<<<
 *         """
 *         Register multiple callback/event type pairs, expressed as a dict.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cassandra.connection.Connection.register_watchers", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_event_type);
  __Pyx_XDECREF(__pyx_v_callback);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":439
 *             timeout=register_timeout)
 * 
 *     def control_conn_disposed(self):             # <<<<<<<<<<<<<<
 *         self.is_control_connection = False
 *         self._push_watchers = {}
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_33control_conn_disposed(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_33control_conn_disposed = {"control_conn_disposed", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_33control_conn_disposed, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_33control_conn_disposed(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("control_conn_disposed (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_32control_conn_disposed(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_32control_conn_disposed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("control_conn_disposed", 0);

  /* "cassandra/connection.py":440
 * 
 *     def control_conn_disposed(self):
 *         self.is_control_connection = False             # <<<<<<<<<<<<<<
 *         self._push_watchers = {}
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_is_control_connection, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":441
 *     def control_conn_disposed(self):
 *         self.is_control_connection = False
 *         self._push_watchers = {}             # <<<<<<<<<<<<<<
 * 
 *     @defunct_on_error
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_push_watchers, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":439
 *             timeout=register_timeout)
 * 
 *     def control_conn_disposed(self):             # <<<<<<<<<<<<<<
 *         self.is_control_connection = False
 *         self._push_watchers = {}
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cassandra.connection.Connection.control_conn_disposed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":444
 * 
 *     @defunct_on_error
 *     def _read_frame_header(self):             # <<<<<<<<<<<<<<
 *         buf = self._iobuf
 *         pos = buf.tell()
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_35_read_frame_header(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_35_read_frame_header = {"_read_frame_header", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_35_read_frame_header, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_35_read_frame_header(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_read_frame_header (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_34_read_frame_header(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_34_read_frame_header(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_buf = NULL;
  PyObject *__pyx_v_pos = NULL;
  PyObject *__pyx_v_version = NULL;
  PyObject *__pyx_v_frame_header = NULL;
  PyObject *__pyx_v_header_size = NULL;
  PyObject *__pyx_v_flags = NULL;
  PyObject *__pyx_v_stream = NULL;
  PyObject *__pyx_v_op = NULL;
  PyObject *__pyx_v_body_len = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  Py_ssize_t __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_read_frame_header", 0);

  /* "cassandra/connection.py":445
 *     @defunct_on_error
 *     def _read_frame_header(self):
 *         buf = self._iobuf             # <<<<<<<<<<<<<<
 *         pos = buf.tell()
 *         if pos:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_iobuf); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_buf = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cassandra/connection.py":446
 *     def _read_frame_header(self):
 *         buf = self._iobuf
 *         pos = buf.tell()             # <<<<<<<<<<<<<<
 *         if pos:
 *             buf.seek(0)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_buf, __pyx_n_s_tell); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_pos = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cassandra/connection.py":447
 *         buf = self._iobuf
 *         pos = buf.tell()
 *         if pos:             # <<<<<<<<<<<<<<
 *             buf.seek(0)
 *             version = uint8_unpack(buf.read(1)) & PROTOCOL_VERSION_MASK
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_pos); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_4) {

    /* "cassandra/connection.py":448
 *         pos = buf.tell()
 *         if pos:
 *             buf.seek(0)             # <<<<<<<<<<<<<<
 *             version = uint8_unpack(buf.read(1)) & PROTOCOL_VERSION_MASK
 *             if version > MAX_SUPPORTED_VERSION:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_buf, __pyx_n_s_seek); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cassandra/connection.py":449
 *         if pos:
 *             buf.seek(0)
 *             version = uint8_unpack(buf.read(1)) & PROTOCOL_VERSION_MASK             # <<<<<<<<<<<<<<
 *             if version > MAX_SUPPORTED_VERSION:
 *                 raise ProtocolError("This version of the driver does not support protocol version %d" % version)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_uint8_unpack); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_buf, __pyx_n_s_read); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_PROTOCOL_VERSION_MASK); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyNumber_And(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_version = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cassandra/connection.py":450
 *             buf.seek(0)
 *             version = uint8_unpack(buf.read(1)) & PROTOCOL_VERSION_MASK
 *             if version > MAX_SUPPORTED_VERSION:             # <<<<<<<<<<<<<<
 *                 raise ProtocolError("This version of the driver does not support protocol version %d" % version)
 *             frame_header = frame_header_v3 if version >= 3 else frame_header_v1_v2
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_MAX_SUPPORTED_VERSION); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_version, __pyx_t_6, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_4) {

      /* "cassandra/connection.py":451
 *             version = uint8_unpack(buf.read(1)) & PROTOCOL_VERSION_MASK
 *             if version > MAX_SUPPORTED_VERSION:
 *                 raise ProtocolError("This version of the driver does not support protocol version %d" % version)             # <<<<<<<<<<<<<<
 *             frame_header = frame_header_v3 if version >= 3 else frame_header_v1_v2
 *             # this frame header struct is everything after the version byte
 */
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_This_version_of_the_driver_does, __pyx_v_version); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_2);
        __pyx_t_2 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cassandra/connection.py":452
 *             if version > MAX_SUPPORTED_VERSION:
 *                 raise ProtocolError("This version of the driver does not support protocol version %d" % version)
 *             frame_header = frame_header_v3 if version >= 3 else frame_header_v1_v2             # <<<<<<<<<<<<<<
 *             # this frame header struct is everything after the version byte
 *             header_size = frame_header.size + 1
 */
    __pyx_t_6 = PyObject_RichCompare(__pyx_v_version, __pyx_int_3, Py_GE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_4) {
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_frame_header_v3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = __pyx_t_6;
      __pyx_t_6 = 0;
    } else {
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_frame_header_v1_v2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = __pyx_t_6;
      __pyx_t_6 = 0;
    }
    __pyx_v_frame_header = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cassandra/connection.py":454
 *             frame_header = frame_header_v3 if version >= 3 else frame_header_v1_v2
 *             # this frame header struct is everything after the version byte
 *             header_size = frame_header.size + 1             # <<<<<<<<<<<<<<
 *             if pos >= header_size:
 *                 flags, stream, op, body_len = frame_header.unpack(buf.read(frame_header.size))
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame_header, __pyx_n_s_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_header_size = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cassandra/connection.py":455
 *             # this frame header struct is everything after the version byte
 *             header_size = frame_header.size + 1
 *             if pos >= header_size:             # <<<<<<<<<<<<<<
 *                 flags, stream, op, body_len = frame_header.unpack(buf.read(frame_header.size))
 *                 if body_len < 0:
 */
    __pyx_t_6 = PyObject_RichCompare(__pyx_v_pos, __pyx_v_header_size, Py_GE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_4) {

      /* "cassandra/connection.py":456
 *             header_size = frame_header.size + 1
 *             if pos >= header_size:
 *                 flags, stream, op, body_len = frame_header.unpack(buf.read(frame_header.size))             # <<<<<<<<<<<<<<
 *                 if body_len < 0:
 *                     raise ProtocolError("Received negative body length: %r" % body_len)
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame_header, __pyx_n_s_unpack); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_buf, __pyx_n_s_read); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame_header, __pyx_n_s_size); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      if (!__pyx_t_7) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_5);
        __pyx_t_5 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      if (!__pyx_t_2) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL;
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
        PyObject* sequence = __pyx_t_6;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 4)) {
          if (size > 4) __Pyx_RaiseTooManyValuesError(4);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 3); 
        } else {
          __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 3); 
        }
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_2);
        #else
        {
          Py_ssize_t i;
          PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_8,&__pyx_t_3,&__pyx_t_2};
          for (i=0; i < 4; i++) {
            PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(item);
            *(temps[i]) = item;
          }
        }
        #endif
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else {
        Py_ssize_t index = -1;
        PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_8,&__pyx_t_3,&__pyx_t_2};
        __pyx_t_5 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_9 = Py_TYPE(__pyx_t_5)->tp_iternext;
        for (index=0; index < 4; index++) {
          PyObject* item = __pyx_t_9(__pyx_t_5); if (unlikely(!item)) goto __pyx_L6_unpacking_failed;
          __Pyx_GOTREF(item);
          *(temps[index]) = item;
        }
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_5), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L7_unpacking_done:;
      }
      __pyx_v_flags = __pyx_t_1;
      __pyx_t_1 = 0;
      __pyx_v_stream = __pyx_t_8;
      __pyx_t_8 = 0;
      __pyx_v_op = __pyx_t_3;
      __pyx_t_3 = 0;
      __pyx_v_body_len = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "cassandra/connection.py":457
 *             if pos >= header_size:
 *                 flags, stream, op, body_len = frame_header.unpack(buf.read(frame_header.size))
 *                 if body_len < 0:             # <<<<<<<<<<<<<<
 *                     raise ProtocolError("Received negative body length: %r" % body_len)
 *                 self._current_frame = _Frame(version, flags, stream, op, header_size, body_len + header_size)
 */
      __pyx_t_6 = PyObject_RichCompare(__pyx_v_body_len, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (__pyx_t_4) {

        /* "cassandra/connection.py":458
 *                 flags, stream, op, body_len = frame_header.unpack(buf.read(frame_header.size))
 *                 if body_len < 0:
 *                     raise ProtocolError("Received negative body length: %r" % body_len)             # <<<<<<<<<<<<<<
 *                 self._current_frame = _Frame(version, flags, stream, op, header_size, body_len + header_size)
 * 
 */
        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Received_negative_body_length_r, __pyx_v_body_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_8 = NULL;
        if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_8)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        if (!__pyx_t_8) {
          __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else {
          __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8); __pyx_t_8 = NULL;
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_Raise(__pyx_t_6, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

      /* "cassandra/connection.py":459
 *                 if body_len < 0:
 *                     raise ProtocolError("Received negative body length: %r" % body_len)
 *                 self._current_frame = _Frame(version, flags, stream, op, header_size, body_len + header_size)             # <<<<<<<<<<<<<<
 * 
 *             self._iobuf.seek(pos)
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Frame); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyNumber_Add(__pyx_v_body_len, __pyx_v_header_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = NULL;
      __pyx_t_10 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_10 = 1;
        }
      }
      __pyx_t_8 = PyTuple_New(6+__pyx_t_10); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_INCREF(__pyx_v_version);
      __Pyx_GIVEREF(__pyx_v_version);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_10, __pyx_v_version);
      __Pyx_INCREF(__pyx_v_flags);
      __Pyx_GIVEREF(__pyx_v_flags);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_10, __pyx_v_flags);
      __Pyx_INCREF(__pyx_v_stream);
      __Pyx_GIVEREF(__pyx_v_stream);
      PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_10, __pyx_v_stream);
      __Pyx_INCREF(__pyx_v_op);
      __Pyx_GIVEREF(__pyx_v_op);
      PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_10, __pyx_v_op);
      __Pyx_INCREF(__pyx_v_header_size);
      __Pyx_GIVEREF(__pyx_v_header_size);
      PyTuple_SET_ITEM(__pyx_t_8, 4+__pyx_t_10, __pyx_v_header_size);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_8, 5+__pyx_t_10, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_current_frame, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "cassandra/connection.py":461
 *                 self._current_frame = _Frame(version, flags, stream, op, header_size, body_len + header_size)
 * 
 *             self._iobuf.seek(pos)             # <<<<<<<<<<<<<<
 * 
 *         return pos
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_iobuf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_seek); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_2) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_pos); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_INCREF(__pyx_v_pos);
      __Pyx_GIVEREF(__pyx_v_pos);
      PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_pos);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cassandra/connection.py":463
 *             self._iobuf.seek(pos)
 * 
 *         return pos             # <<<<<<<<<<<<<<
 * 
 *     def _reset_frame(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_pos);
  __pyx_r = __pyx_v_pos;
  goto __pyx_L0;

  /* "cassandra/connection.py":444
 * 
 *     @defunct_on_error
 *     def _read_frame_header(self):             # <<<<<<<<<<<<<<
 *         buf = self._iobuf
 *         pos = buf.tell()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cassandra.connection.Connection._read_frame_header", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_buf);
  __Pyx_XDECREF(__pyx_v_pos);
  __Pyx_XDECREF(__pyx_v_version);
  __Pyx_XDECREF(__pyx_v_frame_header);
  __Pyx_XDECREF(__pyx_v_header_size);
  __Pyx_XDECREF(__pyx_v_flags);
  __Pyx_XDECREF(__pyx_v_stream);
  __Pyx_XDECREF(__pyx_v_op);
  __Pyx_XDECREF(__pyx_v_body_len);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":465
 *         return pos
 * 
 *     def _reset_frame(self):             # <<<<<<<<<<<<<<
 *         leftover = self._iobuf.read()
 *         self._iobuf = io.BytesIO()
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_37_reset_frame(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_37_reset_frame = {"_reset_frame", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_37_reset_frame, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_37_reset_frame(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_reset_frame (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_36_reset_frame(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_36_reset_frame(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_leftover = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_reset_frame", 0);

  /* "cassandra/connection.py":466
 * 
 *     def _reset_frame(self):
 *         leftover = self._iobuf.read()             # <<<<<<<<<<<<<<
 *         self._iobuf = io.BytesIO()
 *         self._iobuf.write(leftover)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_iobuf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_read); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_leftover = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cassandra/connection.py":467
 *     def _reset_frame(self):
 *         leftover = self._iobuf.read()
 *         self._iobuf = io.BytesIO()             # <<<<<<<<<<<<<<
 *         self._iobuf.write(leftover)
 *         self._current_frame = None
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_io); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_BytesIO); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_iobuf, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":468
 *         leftover = self._iobuf.read()
 *         self._iobuf = io.BytesIO()
 *         self._iobuf.write(leftover)             # <<<<<<<<<<<<<<
 *         self._current_frame = None
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_iobuf); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_write); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_leftover); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_leftover);
    __Pyx_GIVEREF(__pyx_v_leftover);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_leftover);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":469
 *         self._iobuf = io.BytesIO()
 *         self._iobuf.write(leftover)
 *         self._current_frame = None             # <<<<<<<<<<<<<<
 * 
 *     def process_io_buffer(self):
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_current_frame, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":465
 *         return pos
 * 
 *     def _reset_frame(self):             # <<<<<<<<<<<<<<
 *         leftover = self._iobuf.read()
 *         self._iobuf = io.BytesIO()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cassandra.connection.Connection._reset_frame", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_leftover);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":471
 *         self._current_frame = None
 * 
 *     def process_io_buffer(self):             # <<<<<<<<<<<<<<
 *         while True:
 *             if not self._current_frame:
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_39process_io_buffer(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_39process_io_buffer = {"process_io_buffer", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_39process_io_buffer, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_39process_io_buffer(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("process_io_buffer (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_38process_io_buffer(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_38process_io_buffer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_pos = NULL;
  PyObject *__pyx_v_frame = NULL;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("process_io_buffer", 0);

  /* "cassandra/connection.py":472
 * 
 *     def process_io_buffer(self):
 *         while True:             # <<<<<<<<<<<<<<
 *             if not self._current_frame:
 *                 pos = self._read_frame_header()
 */
  while (1) {

    /* "cassandra/connection.py":473
 *     def process_io_buffer(self):
 *         while True:
 *             if not self._current_frame:             # <<<<<<<<<<<<<<
 *                 pos = self._read_frame_header()
 *             else:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_current_frame); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = ((!__pyx_t_2) != 0);
    if (__pyx_t_3) {

      /* "cassandra/connection.py":474
 *         while True:
 *             if not self._current_frame:
 *                 pos = self._read_frame_header()             # <<<<<<<<<<<<<<
 *             else:
 *                 pos = self._iobuf.tell()
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_read_frame_header); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (__pyx_t_5) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else {
        __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_pos, __pyx_t_1);
      __pyx_t_1 = 0;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "cassandra/connection.py":476
 *                 pos = self._read_frame_header()
 *             else:
 *                 pos = self._iobuf.tell()             # <<<<<<<<<<<<<<
 * 
 *             if not self._current_frame or pos < self._current_frame.end_pos:
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_iobuf); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_tell); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF_SET(__pyx_v_pos, __pyx_t_1);
      __pyx_t_1 = 0;
    }
    __pyx_L5:;

    /* "cassandra/connection.py":478
 *                 pos = self._iobuf.tell()
 * 
 *             if not self._current_frame or pos < self._current_frame.end_pos:             # <<<<<<<<<<<<<<
 *                 # we don't have a complete header yet or we
 *                 # already saw a header, but we don't have a
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_current_frame); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = ((!__pyx_t_2) != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_3 = __pyx_t_6;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_current_frame); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_end_pos); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_pos, __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = __pyx_t_6;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_3) {

      /* "cassandra/connection.py":482
 *                 # already saw a header, but we don't have a
 *                 # complete message yet
 *                 return             # <<<<<<<<<<<<<<
 *             else:
 *                 frame = self._current_frame
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
    }
    /*else*/ {

      /* "cassandra/connection.py":484
 *                 return
 *             else:
 *                 frame = self._current_frame             # <<<<<<<<<<<<<<
 *                 self._iobuf.seek(frame.body_offset)
 *                 msg = self._iobuf.read(frame.end_pos - frame.body_offset)
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_current_frame); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_frame, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "cassandra/connection.py":485
 *             else:
 *                 frame = self._current_frame
 *                 self._iobuf.seek(frame.body_offset)             # <<<<<<<<<<<<<<
 *                 msg = self._iobuf.read(frame.end_pos - frame.body_offset)
 *                 self.process_msg(self._current_frame, msg)
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_iobuf); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_seek); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_body_offset); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_7) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_5);
        __pyx_t_5 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cassandra/connection.py":486
 *                 frame = self._current_frame
 *                 self._iobuf.seek(frame.body_offset)
 *                 msg = self._iobuf.read(frame.end_pos - frame.body_offset)             # <<<<<<<<<<<<<<
 *                 self.process_msg(self._current_frame, msg)
 *                 self._reset_frame()
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_iobuf); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_read); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_end_pos); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_frame, __pyx_n_s_body_offset); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF_SET(__pyx_v_msg, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "cassandra/connection.py":487
 *                 self._iobuf.seek(frame.body_offset)
 *                 msg = self._iobuf.read(frame.end_pos - frame.body_offset)
 *                 self.process_msg(self._current_frame, msg)             # <<<<<<<<<<<<<<
 *                 self._reset_frame()
 * 
 */
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_process_msg); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_current_frame); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
          __pyx_t_9 = 1;
        }
      }
      __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_t_4);
      __Pyx_INCREF(__pyx_v_msg);
      __Pyx_GIVEREF(__pyx_v_msg);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_v_msg);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cassandra/connection.py":488
 *                 msg = self._iobuf.read(frame.end_pos - frame.body_offset)
 *                 self.process_msg(self._current_frame, msg)
 *                 self._reset_frame()             # <<<<<<<<<<<<<<
 * 
 *     @defunct_on_error
 */
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_reset_frame); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (__pyx_t_5) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else {
        __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
  }

  /* "cassandra/connection.py":471
 *         self._current_frame = None
 * 
 *     def process_io_buffer(self):             # <<<<<<<<<<<<<<
 *         while True:
 *             if not self._current_frame:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cassandra.connection.Connection.process_io_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_pos);
  __Pyx_XDECREF(__pyx_v_frame);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":491
 * 
 *     @defunct_on_error
 *     def process_msg(self, header, body):             # <<<<<<<<<<<<<<
 *         stream_id = header.stream
 *         if stream_id < 0:
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_41process_msg(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_41process_msg = {"process_msg", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_41process_msg, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_41process_msg(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_header = 0;
  PyObject *__pyx_v_body = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("process_msg (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_header,&__pyx_n_s_body,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_header)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("process_msg", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_body)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("process_msg", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "process_msg") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_header = values[1];
    __pyx_v_body = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("process_msg", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Connection.process_msg", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_40process_msg(__pyx_self, __pyx_v_self, __pyx_v_header, __pyx_v_body);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_40process_msg(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_header, PyObject *__pyx_v_body) {
  PyObject *__pyx_v_stream_id = NULL;
  PyObject *__pyx_v_callback = NULL;
  PyObject *__pyx_v_decoder = NULL;
  PyObject *__pyx_v_response = NULL;
  PyObject *__pyx_v_exc = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  int __pyx_t_20;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("process_msg", 0);

  /* "cassandra/connection.py":492
 *     @defunct_on_error
 *     def process_msg(self, header, body):
 *         stream_id = header.stream             # <<<<<<<<<<<<<<
 *         if stream_id < 0:
 *             callback = None
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_header, __pyx_n_s_stream); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_stream_id = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cassandra/connection.py":493
 *     def process_msg(self, header, body):
 *         stream_id = header.stream
 *         if stream_id < 0:             # <<<<<<<<<<<<<<
 *             callback = None
 *             decoder = ProtocolHandler.decode_message
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_stream_id, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cassandra/connection.py":494
 *         stream_id = header.stream
 *         if stream_id < 0:
 *             callback = None             # <<<<<<<<<<<<<<
 *             decoder = ProtocolHandler.decode_message
 *         else:
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_callback = Py_None;

    /* "cassandra/connection.py":495
 *         if stream_id < 0:
 *             callback = None
 *             decoder = ProtocolHandler.decode_message             # <<<<<<<<<<<<<<
 *         else:
 *             callback, decoder = self._requests.pop(stream_id, None)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ProtocolHandler); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_decode_message); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_decoder = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "cassandra/connection.py":497
 *             decoder = ProtocolHandler.decode_message
 *         else:
 *             callback, decoder = self._requests.pop(stream_id, None)             # <<<<<<<<<<<<<<
 *             with self.lock:
 *                 self.request_ids.append(stream_id)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_requests); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_pop); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_5 = 1;
      }
    }
    __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_INCREF(__pyx_v_stream_id);
    __Pyx_GIVEREF(__pyx_v_stream_id);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_stream_id);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, Py_None);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
      PyObject* sequence = __pyx_t_3;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext;
      index = 0; __pyx_t_4 = __pyx_t_7(__pyx_t_1); if (unlikely(!__pyx_t_4)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      index = 1; __pyx_t_6 = __pyx_t_7(__pyx_t_1); if (unlikely(!__pyx_t_6)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_1), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_7 = NULL;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L5_unpacking_done;
      __pyx_L4_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_7 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L5_unpacking_done:;
    }
    __pyx_v_callback = __pyx_t_4;
    __pyx_t_4 = 0;
    __pyx_v_decoder = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cassandra/connection.py":498
 *         else:
 *             callback, decoder = self._requests.pop(stream_id, None)
 *             with self.lock:             # <<<<<<<<<<<<<<
 *                 self.request_ids.append(stream_id)
 * 
 */
    /*with:*/ {
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lock); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_exit); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_enter); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (__pyx_t_1) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      }
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      /*try:*/ {
        {
          __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_9);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_11);
          /*try:*/ {

            /* "cassandra/connection.py":499
 *             callback, decoder = self._requests.pop(stream_id, None)
 *             with self.lock:
 *                 self.request_ids.append(stream_id)             # <<<<<<<<<<<<<<
 * 
 *         self.msg_received = True
 */
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_request_ids); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_12 = __Pyx_PyObject_Append(__pyx_t_3, __pyx_v_stream_id); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          }
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          goto __pyx_L17_try_end;
          __pyx_L10_error:;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "cassandra/connection.py":498
 *         else:
 *             callback, decoder = self._requests.pop(stream_id, None)
 *             with self.lock:             # <<<<<<<<<<<<<<
 *                 self.request_ids.append(stream_id)
 * 
 */
          /*except:*/ {
            __Pyx_AddTraceback("cassandra.connection.Connection.process_msg", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_6, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_1 = PyTuple_Pack(3, __pyx_t_3, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_1, NULL);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (__pyx_t_2 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
            __pyx_t_14 = ((!(__pyx_t_2 != 0)) != 0);
            if (__pyx_t_14) {
              __Pyx_GIVEREF(__pyx_t_3);
              __Pyx_GIVEREF(__pyx_t_6);
              __Pyx_XGIVEREF(__pyx_t_4);
              __Pyx_ErrRestore(__pyx_t_3, __pyx_t_6, __pyx_t_4);
              __pyx_t_3 = 0; __pyx_t_6 = 0; __pyx_t_4 = 0; 
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
            }
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            goto __pyx_L11_exception_handled;
          }
          __pyx_L12_except_error:;
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
          goto __pyx_L1_error;
          __pyx_L11_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
          __pyx_L17_try_end:;
        }
      }
      /*finally:*/ {
        /*normal exit:*/{
          if (__pyx_t_8) {
            __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__19, NULL);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_11);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          }
          goto __pyx_L9;
        }
        __pyx_L9:;
      }
      goto __pyx_L21;
      __pyx_L6_error:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L1_error;
      __pyx_L21:;
    }
  }
  __pyx_L3:;

  /* "cassandra/connection.py":501
 *                 self.request_ids.append(stream_id)
 * 
 *         self.msg_received = True             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_msg_received, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":503
 *         self.msg_received = True
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             response = decoder(header.version, self.user_type_map, stream_id,
 *                                header.flags, header.opcode, body, self.decompressor)
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_11, &__pyx_t_10);
    __Pyx_XGOTREF(__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_11);
    __Pyx_XGOTREF(__pyx_t_10);
    /*try:*/ {

      /* "cassandra/connection.py":504
 * 
 *         try:
 *             response = decoder(header.version, self.user_type_map, stream_id,             # <<<<<<<<<<<<<<
 *                                header.flags, header.opcode, body, self.decompressor)
 *         except Exception as exc:
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_header, __pyx_n_s_version); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L22_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_user_type_map); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L22_error;}
      __Pyx_GOTREF(__pyx_t_3);

      /* "cassandra/connection.py":505
 *         try:
 *             response = decoder(header.version, self.user_type_map, stream_id,
 *                                header.flags, header.opcode, body, self.decompressor)             # <<<<<<<<<<<<<<
 *         except Exception as exc:
 *             log.exception("Error decoding response from Cassandra. "
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_header, __pyx_n_s_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L22_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_header, __pyx_n_s_opcode); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L22_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_decompressor); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L22_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_INCREF(__pyx_v_decoder);
      __pyx_t_17 = __pyx_v_decoder; __pyx_t_18 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_17))) {
        __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_17);
        if (likely(__pyx_t_18)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
          __Pyx_INCREF(__pyx_t_18);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_17, function);
          __pyx_t_5 = 1;
        }
      }
      __pyx_t_19 = PyTuple_New(7+__pyx_t_5); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L22_error;}
      __Pyx_GOTREF(__pyx_t_19);
      if (__pyx_t_18) {
        __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_18); __pyx_t_18 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_19, 0+__pyx_t_5, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_19, 1+__pyx_t_5, __pyx_t_3);
      __Pyx_INCREF(__pyx_v_stream_id);
      __Pyx_GIVEREF(__pyx_v_stream_id);
      PyTuple_SET_ITEM(__pyx_t_19, 2+__pyx_t_5, __pyx_v_stream_id);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_19, 3+__pyx_t_5, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_19, 4+__pyx_t_5, __pyx_t_15);
      __Pyx_INCREF(__pyx_v_body);
      __Pyx_GIVEREF(__pyx_v_body);
      PyTuple_SET_ITEM(__pyx_t_19, 5+__pyx_t_5, __pyx_v_body);
      __Pyx_GIVEREF(__pyx_t_16);
      PyTuple_SET_ITEM(__pyx_t_19, 6+__pyx_t_5, __pyx_t_16);
      __pyx_t_6 = 0;
      __pyx_t_3 = 0;
      __pyx_t_1 = 0;
      __pyx_t_15 = 0;
      __pyx_t_16 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_19, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L22_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_v_response = __pyx_t_4;
      __pyx_t_4 = 0;
    }
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    goto __pyx_L29_try_end;
    __pyx_L22_error:;
    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cassandra/connection.py":506
 *             response = decoder(header.version, self.user_type_map, stream_id,
 *                                header.flags, header.opcode, body, self.decompressor)
 *         except Exception as exc:             # <<<<<<<<<<<<<<
 *             log.exception("Error decoding response from Cassandra. "
 *                           "opcode: %04x; message contents: %r", header.opcode, body)
 */
    __pyx_t_20 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
    if (__pyx_t_20) {
      __Pyx_AddTraceback("cassandra.connection.Connection.process_msg", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_17, &__pyx_t_19) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_GOTREF(__pyx_t_19);
      __Pyx_INCREF(__pyx_t_17);
      __pyx_v_exc = __pyx_t_17;

      /* "cassandra/connection.py":507
 *                                header.flags, header.opcode, body, self.decompressor)
 *         except Exception as exc:
 *             log.exception("Error decoding response from Cassandra. "             # <<<<<<<<<<<<<<
 *                           "opcode: %04x; message contents: %r", header.opcode, body)
 *             if callback is not None:
 */
      __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_exception); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

      /* "cassandra/connection.py":508
 *         except Exception as exc:
 *             log.exception("Error decoding response from Cassandra. "
 *                           "opcode: %04x; message contents: %r", header.opcode, body)             # <<<<<<<<<<<<<<
 *             if callback is not None:
 *                 callback(exc)
 */
      __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_header, __pyx_n_s_opcode); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_3 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
          __pyx_t_5 = 1;
        }
      }
      __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_INCREF(__pyx_kp_s_Error_decoding_response_from_Cas);
      __Pyx_GIVEREF(__pyx_kp_s_Error_decoding_response_from_Cas);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_kp_s_Error_decoding_response_from_Cas);
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_15);
      __Pyx_INCREF(__pyx_v_body);
      __Pyx_GIVEREF(__pyx_v_body);
      PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_body);
      __pyx_t_15 = 0;
      __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;

      /* "cassandra/connection.py":509
 *             log.exception("Error decoding response from Cassandra. "
 *                           "opcode: %04x; message contents: %r", header.opcode, body)
 *             if callback is not None:             # <<<<<<<<<<<<<<
 *                 callback(exc)
 *             self.defunct(exc)
 */
      __pyx_t_14 = (__pyx_v_callback != Py_None);
      __pyx_t_2 = (__pyx_t_14 != 0);
      if (__pyx_t_2) {

        /* "cassandra/connection.py":510
 *                           "opcode: %04x; message contents: %r", header.opcode, body)
 *             if callback is not None:
 *                 callback(exc)             # <<<<<<<<<<<<<<
 *             self.defunct(exc)
 *             return
 */
        __Pyx_INCREF(__pyx_v_callback);
        __pyx_t_1 = __pyx_v_callback; __pyx_t_6 = NULL;
        if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
          if (likely(__pyx_t_6)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_1, function);
          }
        }
        if (!__pyx_t_6) {
          __pyx_t_16 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_exc); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
          __Pyx_GOTREF(__pyx_t_16);
        } else {
          __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_6); __pyx_t_6 = NULL;
          __Pyx_INCREF(__pyx_v_exc);
          __Pyx_GIVEREF(__pyx_v_exc);
          PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_v_exc);
          __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_15, NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
          __Pyx_GOTREF(__pyx_t_16);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        goto __pyx_L32;
      }
      __pyx_L32:;

      /* "cassandra/connection.py":511
 *             if callback is not None:
 *                 callback(exc)
 *             self.defunct(exc)             # <<<<<<<<<<<<<<
 *             return
 * 
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_defunct); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_15 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_15)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      if (!__pyx_t_15) {
        __pyx_t_16 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_exc); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
        __Pyx_GOTREF(__pyx_t_16);
      } else {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_15); __pyx_t_15 = NULL;
        __Pyx_INCREF(__pyx_v_exc);
        __Pyx_GIVEREF(__pyx_v_exc);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_exc);
        __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;

      /* "cassandra/connection.py":512
 *                 callback(exc)
 *             self.defunct(exc)
 *             return             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      goto __pyx_L25_except_return;
    }
    goto __pyx_L24_except_error;
    __pyx_L24_except_error:;
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_XGIVEREF(__pyx_t_10);
    __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_11, __pyx_t_10);
    goto __pyx_L1_error;
    __pyx_L25_except_return:;
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_XGIVEREF(__pyx_t_10);
    __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_11, __pyx_t_10);
    goto __pyx_L0;
    __pyx_L29_try_end:;
  }

  /* "cassandra/connection.py":514
 *             return
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if stream_id >= 0:
 *                 if isinstance(response, ProtocolException):
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_10);
    __Pyx_XGOTREF(__pyx_t_11);
    __Pyx_XGOTREF(__pyx_t_8);
    /*try:*/ {

      /* "cassandra/connection.py":515
 * 
 *         try:
 *             if stream_id >= 0:             # <<<<<<<<<<<<<<
 *                 if isinstance(response, ProtocolException):
 *                     if 'unsupported protocol version' in response.message:
 */
      __pyx_t_19 = PyObject_RichCompare(__pyx_v_stream_id, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_19); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_19); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      if (__pyx_t_2) {

        /* "cassandra/connection.py":516
 *         try:
 *             if stream_id >= 0:
 *                 if isinstance(response, ProtocolException):             # <<<<<<<<<<<<<<
 *                     if 'unsupported protocol version' in response.message:
 *                         self.is_unsupported_proto_version = True
 */
        __pyx_t_19 = __Pyx_GetModuleGlobalName(__pyx_n_s_ProtocolException); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
        __Pyx_GOTREF(__pyx_t_19);
        __pyx_t_2 = PyObject_IsInstance(__pyx_v_response, __pyx_t_19); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __pyx_t_14 = (__pyx_t_2 != 0);
        if (__pyx_t_14) {

          /* "cassandra/connection.py":517
 *             if stream_id >= 0:
 *                 if isinstance(response, ProtocolException):
 *                     if 'unsupported protocol version' in response.message:             # <<<<<<<<<<<<<<
 *                         self.is_unsupported_proto_version = True
 * 
 */
          __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_v_response, __pyx_n_s_message); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
          __Pyx_GOTREF(__pyx_t_19);
          __pyx_t_14 = (__Pyx_PySequence_Contains(__pyx_kp_s_unsupported_protocol_version, __pyx_t_19, Py_EQ)); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          __pyx_t_2 = (__pyx_t_14 != 0);
          if (__pyx_t_2) {

            /* "cassandra/connection.py":518
 *                 if isinstance(response, ProtocolException):
 *                     if 'unsupported protocol version' in response.message:
 *                         self.is_unsupported_proto_version = True             # <<<<<<<<<<<<<<
 * 
 *                     log.error("Closing connection %s due to protocol error: %s", self, response.summary_msg())
 */
            if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_is_unsupported_proto_version, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
            goto __pyx_L43;
          }
          __pyx_L43:;

          /* "cassandra/connection.py":520
 *                         self.is_unsupported_proto_version = True
 * 
 *                     log.error("Closing connection %s due to protocol error: %s", self, response.summary_msg())             # <<<<<<<<<<<<<<
 *                     self.defunct(response)
 *                 if callback is not None:
 */
          __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_error); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_response, __pyx_n_s_summary_msg); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
          __Pyx_GOTREF(__pyx_t_16);
          __pyx_t_1 = NULL;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_16))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_16);
            if (likely(__pyx_t_1)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_16, function);
            }
          }
          if (__pyx_t_1) {
            __pyx_t_17 = __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_1); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          } else {
            __pyx_t_17 = __Pyx_PyObject_CallNoArg(__pyx_t_16); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
          }
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __pyx_t_16 = NULL;
          __pyx_t_5 = 0;
          if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_4);
            if (likely(__pyx_t_16)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_16);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_4, function);
              __pyx_t_5 = 1;
            }
          }
          __pyx_t_1 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
          __Pyx_GOTREF(__pyx_t_1);
          if (__pyx_t_16) {
            __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_16); __pyx_t_16 = NULL;
          }
          __Pyx_INCREF(__pyx_kp_s_Closing_connection_s_due_to_prot);
          __Pyx_GIVEREF(__pyx_kp_s_Closing_connection_s_due_to_prot);
          PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_5, __pyx_kp_s_Closing_connection_s_due_to_prot);
          __Pyx_INCREF(__pyx_v_self);
          __Pyx_GIVEREF(__pyx_v_self);
          PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_5, __pyx_v_self);
          __Pyx_GIVEREF(__pyx_t_17);
          PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_5, __pyx_t_17);
          __pyx_t_17 = 0;
          __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
          __Pyx_GOTREF(__pyx_t_19);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

          /* "cassandra/connection.py":521
 * 
 *                     log.error("Closing connection %s due to protocol error: %s", self, response.summary_msg())
 *                     self.defunct(response)             # <<<<<<<<<<<<<<
 *                 if callback is not None:
 *                     callback(response)
 */
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_defunct); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_1 = NULL;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
            if (likely(__pyx_t_1)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_4, function);
            }
          }
          if (!__pyx_t_1) {
            __pyx_t_19 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_response); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
            __Pyx_GOTREF(__pyx_t_19);
          } else {
            __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
            __Pyx_GOTREF(__pyx_t_17);
            __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_1); __pyx_t_1 = NULL;
            __Pyx_INCREF(__pyx_v_response);
            __Pyx_GIVEREF(__pyx_v_response);
            PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_v_response);
            __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_17, NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
            __Pyx_GOTREF(__pyx_t_19);
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          }
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          goto __pyx_L42;
        }
        __pyx_L42:;

        /* "cassandra/connection.py":522
 *                     log.error("Closing connection %s due to protocol error: %s", self, response.summary_msg())
 *                     self.defunct(response)
 *                 if callback is not None:             # <<<<<<<<<<<<<<
 *                     callback(response)
 *             else:
 */
        __pyx_t_2 = (__pyx_v_callback != Py_None);
        __pyx_t_14 = (__pyx_t_2 != 0);
        if (__pyx_t_14) {

          /* "cassandra/connection.py":523
 *                     self.defunct(response)
 *                 if callback is not None:
 *                     callback(response)             # <<<<<<<<<<<<<<
 *             else:
 *                 self.handle_pushed(response)
 */
          __Pyx_INCREF(__pyx_v_callback);
          __pyx_t_4 = __pyx_v_callback; __pyx_t_17 = NULL;
          if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_4);
            if (likely(__pyx_t_17)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_17);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_4, function);
            }
          }
          if (!__pyx_t_17) {
            __pyx_t_19 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_response); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
            __Pyx_GOTREF(__pyx_t_19);
          } else {
            __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_17); __pyx_t_17 = NULL;
            __Pyx_INCREF(__pyx_v_response);
            __Pyx_GIVEREF(__pyx_v_response);
            PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_response);
            __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
            __Pyx_GOTREF(__pyx_t_19);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          }
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          goto __pyx_L44;
        }
        __pyx_L44:;
        goto __pyx_L41;
      }
      /*else*/ {

        /* "cassandra/connection.py":525
 *                     callback(response)
 *             else:
 *                 self.handle_pushed(response)             # <<<<<<<<<<<<<<
 *         except Exception:
 *             log.exception("Callback handler errored, ignoring:")
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_handle_pushed); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_1 = NULL;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        if (!__pyx_t_1) {
          __pyx_t_19 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_response); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
          __Pyx_GOTREF(__pyx_t_19);
        } else {
          __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_1); __pyx_t_1 = NULL;
          __Pyx_INCREF(__pyx_v_response);
          __Pyx_GIVEREF(__pyx_v_response);
          PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_v_response);
          __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_17, NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
          __Pyx_GOTREF(__pyx_t_19);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      }
      __pyx_L41:;
    }
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    goto __pyx_L40_try_end;
    __pyx_L33_error:;
    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;

    /* "cassandra/connection.py":526
 *             else:
 *                 self.handle_pushed(response)
 *         except Exception:             # <<<<<<<<<<<<<<
 *             log.exception("Callback handler errored, ignoring:")
 * 
 */
    __pyx_t_20 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
    if (__pyx_t_20) {
      __Pyx_AddTraceback("cassandra.connection.Connection.process_msg", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_19, &__pyx_t_4, &__pyx_t_17) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L35_except_error;}
      __Pyx_GOTREF(__pyx_t_19);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_17);

      /* "cassandra/connection.py":527
 *                 self.handle_pushed(response)
 *         except Exception:
 *             log.exception("Callback handler errored, ignoring:")             # <<<<<<<<<<<<<<
 * 
 *     @defunct_on_error
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L35_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_exception); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L35_except_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L35_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      goto __pyx_L34_exception_handled;
    }
    goto __pyx_L35_except_error;
    __pyx_L35_except_error:;
    __Pyx_XGIVEREF(__pyx_t_10);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_8);
    goto __pyx_L1_error;
    __pyx_L34_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_10);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_8);
    __pyx_L40_try_end:;
  }

  /* "cassandra/connection.py":491
 * 
 *     @defunct_on_error
 *     def process_msg(self, header, body):             # <<<<<<<<<<<<<<
 *         stream_id = header.stream
 *         if stream_id < 0:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_AddTraceback("cassandra.connection.Connection.process_msg", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_stream_id);
  __Pyx_XDECREF(__pyx_v_callback);
  __Pyx_XDECREF(__pyx_v_decoder);
  __Pyx_XDECREF(__pyx_v_response);
  __Pyx_XDECREF(__pyx_v_exc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":530
 * 
 *     @defunct_on_error
 *     def _send_options_message(self):             # <<<<<<<<<<<<<<
 *         if self.cql_version is None and (not self.compression or not locally_supported_compressions):
 *             log.debug("Not sending options message for new connection(%s) to %s "
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_43_send_options_message(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_43_send_options_message = {"_send_options_message", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_43_send_options_message, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_43_send_options_message(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_send_options_message (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_42_send_options_message(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_42_send_options_message(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  Py_ssize_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_send_options_message", 0);

  /* "cassandra/connection.py":531
 *     @defunct_on_error
 *     def _send_options_message(self):
 *         if self.cql_version is None and (not self.compression or not locally_supported_compressions):             # <<<<<<<<<<<<<<
 *             log.debug("Not sending options message for new connection(%s) to %s "
 *                       "because compression is disabled and a cql version was not "
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cql_version); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = (__pyx_t_2 == Py_None);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_compression); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = ((!__pyx_t_4) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_locally_supported_compressions); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = ((!__pyx_t_3) != 0);
  __pyx_t_1 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "cassandra/connection.py":532
 *     def _send_options_message(self):
 *         if self.cql_version is None and (not self.compression or not locally_supported_compressions):
 *             log.debug("Not sending options message for new connection(%s) to %s "             # <<<<<<<<<<<<<<
 *                       "because compression is disabled and a cql version was not "
 *                       "specified", id(self), self.host)
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_debug); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cassandra/connection.py":534
 *             log.debug("Not sending options message for new connection(%s) to %s "
 *                       "because compression is disabled and a cql version was not "
 *                       "specified", id(self), self.host)             # <<<<<<<<<<<<<<
 *             self._compressor = None
 *             self.cql_version = DEFAULT_CQL_VERSION
 */
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_self);
    __Pyx_GIVEREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_9 = 1;
      }
    }
    __pyx_t_10 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_s_Not_sending_options_message_for);
    __Pyx_GIVEREF(__pyx_kp_s_Not_sending_options_message_for);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_kp_s_Not_sending_options_message_for);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_t_5);
    __pyx_t_7 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cassandra/connection.py":535
 *                       "because compression is disabled and a cql version was not "
 *                       "specified", id(self), self.host)
 *             self._compressor = None             # <<<<<<<<<<<<<<
 *             self.cql_version = DEFAULT_CQL_VERSION
 *             self._send_startup_message()
 */
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_compressor_2, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cassandra/connection.py":536
 *                       "specified", id(self), self.host)
 *             self._compressor = None
 *             self.cql_version = DEFAULT_CQL_VERSION             # <<<<<<<<<<<<<<
 *             self._send_startup_message()
 *         else:
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEFAULT_CQL_VERSION); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_cql_version, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cassandra/connection.py":537
 *             self._compressor = None
 *             self.cql_version = DEFAULT_CQL_VERSION
 *             self._send_startup_message()             # <<<<<<<<<<<<<<
 *         else:
 *             log.debug("Sending initial options message for new connection (%s) to %s", id(self), self.host)
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send_startup_message); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_10 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_10) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "cassandra/connection.py":539
 *             self._send_startup_message()
 *         else:
 *             log.debug("Sending initial options message for new connection (%s) to %s", id(self), self.host)             # <<<<<<<<<<<<<<
 *             self.send_msg(OptionsMessage(), self.get_request_id(), self._handle_options_response)
 * 
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_debug); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_self);
    __Pyx_GIVEREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_self);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
        __pyx_t_9 = 1;
      }
    }
    __pyx_t_8 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_s_Sending_initial_options_message);
    __Pyx_GIVEREF(__pyx_kp_s_Sending_initial_options_message);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_kp_s_Sending_initial_options_message);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_9, __pyx_t_6);
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "cassandra/connection.py":540
 *         else:
 *             log.debug("Sending initial options message for new connection (%s) to %s", id(self), self.host)
 *             self.send_msg(OptionsMessage(), self.get_request_id(), self._handle_options_response)             # <<<<<<<<<<<<<<
 * 
 *     @defunct_on_error
 */
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send_msg); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_OptionsMessage); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_get_request_id); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_handle_options_response); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
        __pyx_t_9 = 1;
      }
    }
    __pyx_t_11 = PyTuple_New(3+__pyx_t_9); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_9, __pyx_t_5);
    __pyx_t_8 = 0;
    __pyx_t_6 = 0;
    __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "cassandra/connection.py":530
 * 
 *     @defunct_on_error
 *     def _send_options_message(self):             # <<<<<<<<<<<<<<
 *         if self.cql_version is None and (not self.compression or not locally_supported_compressions):
 *             log.debug("Not sending options message for new connection(%s) to %s "
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("cassandra.connection.Connection._send_options_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":543
 * 
 *     @defunct_on_error
 *     def _handle_options_response(self, options_response):             # <<<<<<<<<<<<<<
 *         if self.is_defunct:
 *             return
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_45_handle_options_response(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_45_handle_options_response = {"_handle_options_response", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_45_handle_options_response, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_45_handle_options_response(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_options_response = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_handle_options_response (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_options_response,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_options_response)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_handle_options_response", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_handle_options_response") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_options_response = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_handle_options_response", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Connection._handle_options_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_44_handle_options_response(__pyx_self, __pyx_v_self, __pyx_v_options_response);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_44_handle_options_response(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_options_response) {
  PyObject *__pyx_v_supported_cql_versions = NULL;
  PyObject *__pyx_v_remote_supported_compressions = NULL;
  PyObject *__pyx_v_compression_type = NULL;
  PyObject *__pyx_v_overlap = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *(*__pyx_t_11)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_handle_options_response", 0);

  /* "cassandra/connection.py":544
 *     @defunct_on_error
 *     def _handle_options_response(self, options_response):
 *         if self.is_defunct:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_is_defunct); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cassandra/connection.py":545
 *     def _handle_options_response(self, options_response):
 *         if self.is_defunct:
 *             return             # <<<<<<<<<<<<<<
 * 
 *         if not isinstance(options_response, SupportedMessage):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }

  /* "cassandra/connection.py":547
 *             return
 * 
 *         if not isinstance(options_response, SupportedMessage):             # <<<<<<<<<<<<<<
 *             if isinstance(options_response, ConnectionException):
 *                 raise options_response
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_SupportedMessage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_options_response, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((!(__pyx_t_2 != 0)) != 0);
  if (__pyx_t_3) {

    /* "cassandra/connection.py":548
 * 
 *         if not isinstance(options_response, SupportedMessage):
 *             if isinstance(options_response, ConnectionException):             # <<<<<<<<<<<<<<
 *                 raise options_response
 *             else:
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConnectionException); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_IsInstance(__pyx_v_options_response, __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_2 = (__pyx_t_3 != 0);
    if (__pyx_t_2) {

      /* "cassandra/connection.py":549
 *         if not isinstance(options_response, SupportedMessage):
 *             if isinstance(options_response, ConnectionException):
 *                 raise options_response             # <<<<<<<<<<<<<<
 *             else:
 *                 log.error("Did not get expected SupportedMessage response; "
 */
      __Pyx_Raise(__pyx_v_options_response, 0, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    /*else*/ {

      /* "cassandra/connection.py":551
 *                 raise options_response
 *             else:
 *                 log.error("Did not get expected SupportedMessage response; "             # <<<<<<<<<<<<<<
 *                           "instead, got: %s", options_response)
 *                 raise ConnectionException("Did not get expected SupportedMessage "
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_error); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cassandra/connection.py":552
 *             else:
 *                 log.error("Did not get expected SupportedMessage response; "
 *                           "instead, got: %s", options_response)             # <<<<<<<<<<<<<<
 *                 raise ConnectionException("Did not get expected SupportedMessage "
 *                                           "response; instead, got: %s"
 */
      __pyx_t_4 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(__pyx_kp_s_Did_not_get_expected_SupportedMe);
      __Pyx_GIVEREF(__pyx_kp_s_Did_not_get_expected_SupportedMe);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_kp_s_Did_not_get_expected_SupportedMe);
      __Pyx_INCREF(__pyx_v_options_response);
      __Pyx_GIVEREF(__pyx_v_options_response);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_options_response);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "cassandra/connection.py":553
 *                 log.error("Did not get expected SupportedMessage response; "
 *                           "instead, got: %s", options_response)
 *                 raise ConnectionException("Did not get expected SupportedMessage "             # <<<<<<<<<<<<<<
 *                                           "response; instead, got: %s"
 *                                           % (options_response,))
 */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConnectionException); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);

      /* "cassandra/connection.py":555
 *                 raise ConnectionException("Did not get expected SupportedMessage "
 *                                           "response; instead, got: %s"
 *                                           % (options_response,))             # <<<<<<<<<<<<<<
 * 
 *         log.debug("Received options response on new connection (%s) from %s",
 */
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_v_options_response);
      __Pyx_GIVEREF(__pyx_v_options_response);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_options_response);
      __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Did_not_get_expected_SupportedMe, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (!__pyx_t_7) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }

  /* "cassandra/connection.py":557
 *                                           % (options_response,))
 * 
 *         log.debug("Received options response on new connection (%s) from %s",             # <<<<<<<<<<<<<<
 *                   id(self), self.host)
 *         supported_cql_versions = options_response.cql_versions
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_debug); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "cassandra/connection.py":558
 * 
 *         log.debug("Received options response on new connection (%s) from %s",
 *                   id(self), self.host)             # <<<<<<<<<<<<<<
 *         supported_cql_versions = options_response.cql_versions
 *         remote_supported_compressions = options_response.options['COMPRESSION']
 */
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_9 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  if (__pyx_t_7) {
    __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
  }
  __Pyx_INCREF(__pyx_kp_s_Received_options_response_on_new);
  __Pyx_GIVEREF(__pyx_kp_s_Received_options_response_on_new);
  PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_6, __pyx_kp_s_Received_options_response_on_new);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_6, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_6, __pyx_t_5);
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":559
 *         log.debug("Received options response on new connection (%s) from %s",
 *                   id(self), self.host)
 *         supported_cql_versions = options_response.cql_versions             # <<<<<<<<<<<<<<
 *         remote_supported_compressions = options_response.options['COMPRESSION']
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_options_response, __pyx_n_s_cql_versions); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_supported_cql_versions = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cassandra/connection.py":560
 *                   id(self), self.host)
 *         supported_cql_versions = options_response.cql_versions
 *         remote_supported_compressions = options_response.options['COMPRESSION']             # <<<<<<<<<<<<<<
 * 
 *         if self.cql_version:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_options_response, __pyx_n_s_options); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = PyObject_GetItem(__pyx_t_1, __pyx_n_s_COMPRESSION); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_remote_supported_compressions = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "cassandra/connection.py":562
 *         remote_supported_compressions = options_response.options['COMPRESSION']
 * 
 *         if self.cql_version:             # <<<<<<<<<<<<<<
 *             if self.cql_version not in supported_cql_versions:
 *                 raise ProtocolError(
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cql_version); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__pyx_t_2) {

    /* "cassandra/connection.py":563
 * 
 *         if self.cql_version:
 *             if self.cql_version not in supported_cql_versions:             # <<<<<<<<<<<<<<
 *                 raise ProtocolError(
 *                     "cql_version %r is not supported by remote (w/ native "
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cql_version); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_2 = (__Pyx_PySequence_Contains(__pyx_t_8, __pyx_v_supported_cql_versions, Py_NE)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_3 = (__pyx_t_2 != 0);
    if (__pyx_t_3) {

      /* "cassandra/connection.py":564
 *         if self.cql_version:
 *             if self.cql_version not in supported_cql_versions:
 *                 raise ProtocolError(             # <<<<<<<<<<<<<<
 *                     "cql_version %r is not supported by remote (w/ native "
 *                     "protocol). Supported versions: %r"
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);

      /* "cassandra/connection.py":567
 *                     "cql_version %r is not supported by remote (w/ native "
 *                     "protocol). Supported versions: %r"
 *                     % (self.cql_version, supported_cql_versions))             # <<<<<<<<<<<<<<
 *         else:
 *             self.cql_version = supported_cql_versions[0]
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cql_version); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_9);
      __Pyx_INCREF(__pyx_v_supported_cql_versions);
      __Pyx_GIVEREF(__pyx_v_supported_cql_versions);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_supported_cql_versions);
      __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyString_Format(__pyx_kp_s_cql_version_r_is_not_supported_b, __pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_8);
      } else {
        __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    goto __pyx_L6;
  }
  /*else*/ {

    /* "cassandra/connection.py":569
 *                     % (self.cql_version, supported_cql_versions))
 *         else:
 *             self.cql_version = supported_cql_versions[0]             # <<<<<<<<<<<<<<
 * 
 *         self._compressor = None
 */
    __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_supported_cql_versions, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_8);
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_cql_version, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __pyx_L6:;

  /* "cassandra/connection.py":571
 *             self.cql_version = supported_cql_versions[0]
 * 
 *         self._compressor = None             # <<<<<<<<<<<<<<
 *         compression_type = None
 *         if self.compression:
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_compressor_2, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":572
 * 
 *         self._compressor = None
 *         compression_type = None             # <<<<<<<<<<<<<<
 *         if self.compression:
 *             overlap = (set(locally_supported_compressions.keys()) &
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_compression_type = Py_None;

  /* "cassandra/connection.py":573
 *         self._compressor = None
 *         compression_type = None
 *         if self.compression:             # <<<<<<<<<<<<<<
 *             overlap = (set(locally_supported_compressions.keys()) &
 *                        set(remote_supported_compressions))
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_compression); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__pyx_t_3) {

    /* "cassandra/connection.py":574
 *         compression_type = None
 *         if self.compression:
 *             overlap = (set(locally_supported_compressions.keys()) &             # <<<<<<<<<<<<<<
 *                        set(remote_supported_compressions))
 *             if len(overlap) == 0:
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_locally_supported_compressions); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_keys); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_1) {
      __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PySet_New(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "cassandra/connection.py":575
 *         if self.compression:
 *             overlap = (set(locally_supported_compressions.keys()) &
 *                        set(remote_supported_compressions))             # <<<<<<<<<<<<<<
 *             if len(overlap) == 0:
 *                 log.debug("No available compression types supported on both ends."
 */
    __pyx_t_8 = PySet_New(__pyx_v_remote_supported_compressions); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);

    /* "cassandra/connection.py":574
 *         compression_type = None
 *         if self.compression:
 *             overlap = (set(locally_supported_compressions.keys()) &             # <<<<<<<<<<<<<<
 *                        set(remote_supported_compressions))
 *             if len(overlap) == 0:
 */
    __pyx_t_1 = PyNumber_And(__pyx_t_4, __pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_v_overlap = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "cassandra/connection.py":576
 *             overlap = (set(locally_supported_compressions.keys()) &
 *                        set(remote_supported_compressions))
 *             if len(overlap) == 0:             # <<<<<<<<<<<<<<
 *                 log.debug("No available compression types supported on both ends."
 *                           " locally supported: %r. remotely supported: %r",
 */
    __pyx_t_6 = PySet_Size(__pyx_v_overlap); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = ((__pyx_t_6 == 0) != 0);
    if (__pyx_t_3) {

      /* "cassandra/connection.py":577
 *                        set(remote_supported_compressions))
 *             if len(overlap) == 0:
 *                 log.debug("No available compression types supported on both ends."             # <<<<<<<<<<<<<<
 *                           " locally supported: %r. remotely supported: %r",
 *                           locally_supported_compressions.keys(),
 */
      __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_debug); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "cassandra/connection.py":579
 *                 log.debug("No available compression types supported on both ends."
 *                           " locally supported: %r. remotely supported: %r",
 *                           locally_supported_compressions.keys(),             # <<<<<<<<<<<<<<
 *                           remote_supported_compressions)
 *             else:
 */
      __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_locally_supported_compressions); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_keys); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (__pyx_t_9) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cassandra/connection.py":580
 *                           " locally supported: %r. remotely supported: %r",
 *                           locally_supported_compressions.keys(),
 *                           remote_supported_compressions)             # <<<<<<<<<<<<<<
 *             else:
 *                 compression_type = None
 */
      __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_9 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_kp_s_No_available_compression_types_s);
      __Pyx_GIVEREF(__pyx_kp_s_No_available_compression_types_s);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_6, __pyx_kp_s_No_available_compression_types_s);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_6, __pyx_t_8);
      __Pyx_INCREF(__pyx_v_remote_supported_compressions);
      __Pyx_GIVEREF(__pyx_v_remote_supported_compressions);
      PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_6, __pyx_v_remote_supported_compressions);
      __pyx_t_8 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L9;
    }
    /*else*/ {

      /* "cassandra/connection.py":582
 *                           remote_supported_compressions)
 *             else:
 *                 compression_type = None             # <<<<<<<<<<<<<<
 *                 if isinstance(self.compression, six.string_types):
 *                     # the user picked a specific compression type ('snappy' or 'lz4')
 */
      __Pyx_INCREF(Py_None);
      __Pyx_DECREF_SET(__pyx_v_compression_type, Py_None);

      /* "cassandra/connection.py":583
 *             else:
 *                 compression_type = None
 *                 if isinstance(self.compression, six.string_types):             # <<<<<<<<<<<<<<
 *                     # the user picked a specific compression type ('snappy' or 'lz4')
 *                     if self.compression not in remote_supported_compressions:
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_compression); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_string_types); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_3 = PyObject_IsInstance(__pyx_t_1, __pyx_t_9); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_2 = (__pyx_t_3 != 0);
      if (__pyx_t_2) {

        /* "cassandra/connection.py":585
 *                 if isinstance(self.compression, six.string_types):
 *                     # the user picked a specific compression type ('snappy' or 'lz4')
 *                     if self.compression not in remote_supported_compressions:             # <<<<<<<<<<<<<<
 *                         raise ProtocolError(
 *                             "The requested compression type (%s) is not supported by the Cassandra server at %s"
 */
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_compression); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_2 = (__Pyx_PySequence_Contains(__pyx_t_9, __pyx_v_remote_supported_compressions, Py_NE)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_3 = (__pyx_t_2 != 0);
        if (__pyx_t_3) {

          /* "cassandra/connection.py":586
 *                     # the user picked a specific compression type ('snappy' or 'lz4')
 *                     if self.compression not in remote_supported_compressions:
 *                         raise ProtocolError(             # <<<<<<<<<<<<<<
 *                             "The requested compression type (%s) is not supported by the Cassandra server at %s"
 *                             % (self.compression, self.host))
 */
          __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);

          /* "cassandra/connection.py":588
 *                         raise ProtocolError(
 *                             "The requested compression type (%s) is not supported by the Cassandra server at %s"
 *                             % (self.compression, self.host))             # <<<<<<<<<<<<<<
 *                     compression_type = self.compression
 *                 else:
 */
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_compression); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_8);
          __pyx_t_4 = 0;
          __pyx_t_8 = 0;
          __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_The_requested_compression_type_s, __pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_5 = NULL;
          if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
            if (likely(__pyx_t_5)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_5);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_1, function);
            }
          }
          if (!__pyx_t_5) {
            __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_GOTREF(__pyx_t_9);
          } else {
            __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
            __Pyx_GIVEREF(__pyx_t_8);
            PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_8);
            __pyx_t_8 = 0;
            __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_Raise(__pyx_t_9, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }

        /* "cassandra/connection.py":589
 *                             "The requested compression type (%s) is not supported by the Cassandra server at %s"
 *                             % (self.compression, self.host))
 *                     compression_type = self.compression             # <<<<<<<<<<<<<<
 *                 else:
 *                     # our locally supported compressions are ordered to prefer
 */
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_compression); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF_SET(__pyx_v_compression_type, __pyx_t_9);
        __pyx_t_9 = 0;
        goto __pyx_L10;
      }
      /*else*/ {

        /* "cassandra/connection.py":593
 *                     # our locally supported compressions are ordered to prefer
 *                     # lz4, if available
 *                     for k in locally_supported_compressions.keys():             # <<<<<<<<<<<<<<
 *                         if k in overlap:
 *                             compression_type = k
 */
        __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_locally_supported_compressions); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_keys); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = NULL;
        if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        if (__pyx_t_1) {
          __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else {
          __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (likely(PyList_CheckExact(__pyx_t_9)) || PyTuple_CheckExact(__pyx_t_9)) {
          __pyx_t_4 = __pyx_t_9; __Pyx_INCREF(__pyx_t_4); __pyx_t_6 = 0;
          __pyx_t_10 = NULL;
        } else {
          __pyx_t_6 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        for (;;) {
          if (likely(!__pyx_t_10)) {
            if (likely(PyList_CheckExact(__pyx_t_4))) {
              if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_4)) break;
              #if CYTHON_COMPILING_IN_CPYTHON
              __pyx_t_9 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_9); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              #else
              __pyx_t_9 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_9);
              #endif
            } else {
              if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
              #if CYTHON_COMPILING_IN_CPYTHON
              __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_9); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              #else
              __pyx_t_9 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_9);
              #endif
            }
          } else {
            __pyx_t_9 = __pyx_t_10(__pyx_t_4);
            if (unlikely(!__pyx_t_9)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_9);
          }
          __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_9);
          __pyx_t_9 = 0;

          /* "cassandra/connection.py":594
 *                     # lz4, if available
 *                     for k in locally_supported_compressions.keys():
 *                         if k in overlap:             # <<<<<<<<<<<<<<
 *                             compression_type = k
 *                             break
 */
          __pyx_t_3 = (__Pyx_PySequence_Contains(__pyx_v_k, __pyx_v_overlap, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_2 = (__pyx_t_3 != 0);
          if (__pyx_t_2) {

            /* "cassandra/connection.py":595
 *                     for k in locally_supported_compressions.keys():
 *                         if k in overlap:
 *                             compression_type = k             # <<<<<<<<<<<<<<
 *                             break
 * 
 */
            __Pyx_INCREF(__pyx_v_k);
            __Pyx_DECREF_SET(__pyx_v_compression_type, __pyx_v_k);

            /* "cassandra/connection.py":596
 *                         if k in overlap:
 *                             compression_type = k
 *                             break             # <<<<<<<<<<<<<<
 * 
 *                 # set the decompressor here, but set the compressor only after
 */
            goto __pyx_L13_break;
          }

          /* "cassandra/connection.py":593
 *                     # our locally supported compressions are ordered to prefer
 *                     # lz4, if available
 *                     for k in locally_supported_compressions.keys():             # <<<<<<<<<<<<<<
 *                         if k in overlap:
 *                             compression_type = k
 */
        }
        __pyx_L13_break:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __pyx_L10:;

      /* "cassandra/connection.py":601
 *                 # a successful Ready message
 *                 self._compressor, self.decompressor = \
 *                     locally_supported_compressions[compression_type]             # <<<<<<<<<<<<<<
 * 
 *         self._send_startup_message(compression_type)
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_locally_supported_compressions); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = PyObject_GetItem(__pyx_t_4, __pyx_v_compression_type); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_9))) || (PyList_CheckExact(__pyx_t_9))) {
        PyObject* sequence = __pyx_t_9;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        #else
        __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_8 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_11 = Py_TYPE(__pyx_t_8)->tp_iternext;
        index = 0; __pyx_t_4 = __pyx_t_11(__pyx_t_8); if (unlikely(!__pyx_t_4)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 1; __pyx_t_1 = __pyx_t_11(__pyx_t_8); if (unlikely(!__pyx_t_1)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_11 = NULL;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L16_unpacking_done;
        __pyx_L15_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_11 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L16_unpacking_done:;
      }

      /* "cassandra/connection.py":600
 *                 # set the decompressor here, but set the compressor only after
 *                 # a successful Ready message
 *                 self._compressor, self.decompressor = \             # <<<<<<<<<<<<<<
 *                     locally_supported_compressions[compression_type]
 * 
 */
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_compressor_2, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_decompressor, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_L9:;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "cassandra/connection.py":603
 *                     locally_supported_compressions[compression_type]
 * 
 *         self._send_startup_message(compression_type)             # <<<<<<<<<<<<<<
 * 
 *     @defunct_on_error
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send_startup_message); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_compression_type); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
  } else {
    __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_INCREF(__pyx_v_compression_type);
    __Pyx_GIVEREF(__pyx_v_compression_type);
    PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_compression_type);
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "cassandra/connection.py":543
 * 
 *     @defunct_on_error
 *     def _handle_options_response(self, options_response):             # <<<<<<<<<<<<<<
 *         if self.is_defunct:
 *             return
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cassandra.connection.Connection._handle_options_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_supported_cql_versions);
  __Pyx_XDECREF(__pyx_v_remote_supported_compressions);
  __Pyx_XDECREF(__pyx_v_compression_type);
  __Pyx_XDECREF(__pyx_v_overlap);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":606
 * 
 *     @defunct_on_error
 *     def _send_startup_message(self, compression=None):             # <<<<<<<<<<<<<<
 *         log.debug("Sending StartupMessage on %s", self)
 *         opts = {}
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_47_send_startup_message(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_47_send_startup_message = {"_send_startup_message", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_47_send_startup_message, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_47_send_startup_message(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_compression = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_send_startup_message (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_compression,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compression);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_send_startup_message") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_compression = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_send_startup_message", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Connection._send_startup_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_46_send_startup_message(__pyx_self, __pyx_v_self, __pyx_v_compression);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_46_send_startup_message(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_compression) {
  PyObject *__pyx_v_opts = NULL;
  PyObject *__pyx_v_sm = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_send_startup_message", 0);

  /* "cassandra/connection.py":607
 *     @defunct_on_error
 *     def _send_startup_message(self, compression=None):
 *         log.debug("Sending StartupMessage on %s", self)             # <<<<<<<<<<<<<<
 *         opts = {}
 *         if compression:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_2) {
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
  }
  __Pyx_INCREF(__pyx_kp_s_Sending_StartupMessage_on_s);
  __Pyx_GIVEREF(__pyx_kp_s_Sending_StartupMessage_on_s);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_kp_s_Sending_StartupMessage_on_s);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_self);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":608
 *     def _send_startup_message(self, compression=None):
 *         log.debug("Sending StartupMessage on %s", self)
 *         opts = {}             # <<<<<<<<<<<<<<
 *         if compression:
 *             opts['COMPRESSION'] = compression
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_opts = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "cassandra/connection.py":609
 *         log.debug("Sending StartupMessage on %s", self)
 *         opts = {}
 *         if compression:             # <<<<<<<<<<<<<<
 *             opts['COMPRESSION'] = compression
 *         sm = StartupMessage(cqlversion=self.cql_version, options=opts)
 */
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_compression); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_6) {

    /* "cassandra/connection.py":610
 *         opts = {}
 *         if compression:
 *             opts['COMPRESSION'] = compression             # <<<<<<<<<<<<<<
 *         sm = StartupMessage(cqlversion=self.cql_version, options=opts)
 *         self.send_msg(sm, self.get_request_id(), cb=self._handle_startup_response)
 */
    if (unlikely(PyDict_SetItem(__pyx_v_opts, __pyx_n_s_COMPRESSION, __pyx_v_compression) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cassandra/connection.py":611
 *         if compression:
 *             opts['COMPRESSION'] = compression
 *         sm = StartupMessage(cqlversion=self.cql_version, options=opts)             # <<<<<<<<<<<<<<
 *         self.send_msg(sm, self.get_request_id(), cb=self._handle_startup_response)
 *         log.debug("Sent StartupMessage on %s", self)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_StartupMessage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cql_version); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_cqlversion, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_options, __pyx_v_opts) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_sm = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "cassandra/connection.py":612
 *             opts['COMPRESSION'] = compression
 *         sm = StartupMessage(cqlversion=self.cql_version, options=opts)
 *         self.send_msg(sm, self.get_request_id(), cb=self._handle_startup_response)             # <<<<<<<<<<<<<<
 *         log.debug("Sent StartupMessage on %s", self)
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send_msg); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_get_request_id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_sm);
  __Pyx_GIVEREF(__pyx_v_sm);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_sm);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_handle_startup_response); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_cb, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":613
 *         sm = StartupMessage(cqlversion=self.cql_version, options=opts)
 *         self.send_msg(sm, self.get_request_id(), cb=self._handle_startup_response)
 *         log.debug("Sent StartupMessage on %s", self)             # <<<<<<<<<<<<<<
 * 
 *     @defunct_on_error
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_debug); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_4 = 1;
    }
  }
  __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (__pyx_t_3) {
    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  }
  __Pyx_INCREF(__pyx_kp_s_Sent_StartupMessage_on_s);
  __Pyx_GIVEREF(__pyx_kp_s_Sent_StartupMessage_on_s);
  PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_kp_s_Sent_StartupMessage_on_s);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_self);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":606
 * 
 *     @defunct_on_error
 *     def _send_startup_message(self, compression=None):             # <<<<<<<<<<<<<<
 *         log.debug("Sending StartupMessage on %s", self)
 *         opts = {}
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cassandra.connection.Connection._send_startup_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_opts);
  __Pyx_XDECREF(__pyx_v_sm);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":616
 * 
 *     @defunct_on_error
 *     def _handle_startup_response(self, startup_response, did_authenticate=False):             # <<<<<<<<<<<<<<
 *         if self.is_defunct:
 *             return
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_49_handle_startup_response(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_49_handle_startup_response = {"_handle_startup_response", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_49_handle_startup_response, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_49_handle_startup_response(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_startup_response = 0;
  PyObject *__pyx_v_did_authenticate = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_handle_startup_response (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_startup_response,&__pyx_n_s_did_authenticate,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)((PyObject *)Py_False));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_startup_response)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_handle_startup_response", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_did_authenticate);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_handle_startup_response") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_startup_response = values[1];
    __pyx_v_did_authenticate = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_handle_startup_response", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Connection._handle_startup_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_48_handle_startup_response(__pyx_self, __pyx_v_self, __pyx_v_startup_response, __pyx_v_did_authenticate);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_48_handle_startup_response(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_startup_response, PyObject *__pyx_v_did_authenticate) {
  PyObject *__pyx_v_cm = NULL;
  PyObject *__pyx_v_callback = NULL;
  PyObject *__pyx_v_initial_response = NULL;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_handle_startup_response", 0);

  /* "cassandra/connection.py":617
 *     @defunct_on_error
 *     def _handle_startup_response(self, startup_response, did_authenticate=False):
 *         if self.is_defunct:             # <<<<<<<<<<<<<<
 *             return
 *         if isinstance(startup_response, ReadyMessage):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_is_defunct); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cassandra/connection.py":618
 *     def _handle_startup_response(self, startup_response, did_authenticate=False):
 *         if self.is_defunct:
 *             return             # <<<<<<<<<<<<<<
 *         if isinstance(startup_response, ReadyMessage):
 *             log.debug("Got ReadyMessage on new connection (%s) from %s", id(self), self.host)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }

  /* "cassandra/connection.py":619
 *         if self.is_defunct:
 *             return
 *         if isinstance(startup_response, ReadyMessage):             # <<<<<<<<<<<<<<
 *             log.debug("Got ReadyMessage on new connection (%s) from %s", id(self), self.host)
 *             if self._compressor:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ReadyMessage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_startup_response, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cassandra/connection.py":620
 *             return
 *         if isinstance(startup_response, ReadyMessage):
 *             log.debug("Got ReadyMessage on new connection (%s) from %s", id(self), self.host)             # <<<<<<<<<<<<<<
 *             if self._compressor:
 *                 self.compressor = self._compressor
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_debug); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_self);
    __Pyx_GIVEREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self);
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_8 = 1;
      }
    }
    __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_s_Got_ReadyMessage_on_new_connecti);
    __Pyx_GIVEREF(__pyx_kp_s_Got_ReadyMessage_on_new_connecti);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_kp_s_Got_ReadyMessage_on_new_connecti);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_4);
    __pyx_t_6 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cassandra/connection.py":621
 *         if isinstance(startup_response, ReadyMessage):
 *             log.debug("Got ReadyMessage on new connection (%s) from %s", id(self), self.host)
 *             if self._compressor:             # <<<<<<<<<<<<<<
 *                 self.compressor = self._compressor
 *             self.connected_event.set()
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_compressor_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {

      /* "cassandra/connection.py":622
 *             log.debug("Got ReadyMessage on new connection (%s) from %s", id(self), self.host)
 *             if self._compressor:
 *                 self.compressor = self._compressor             # <<<<<<<<<<<<<<
 *             self.connected_event.set()
 *         elif isinstance(startup_response, AuthenticateMessage):
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_compressor_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_compressor, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "cassandra/connection.py":623
 *             if self._compressor:
 *                 self.compressor = self._compressor
 *             self.connected_event.set()             # <<<<<<<<<<<<<<
 *         elif isinstance(startup_response, AuthenticateMessage):
 *             log.debug("Got AuthenticateMessage on new connection (%s) from %s: %s",
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_connected_event); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_set); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L4;
  }

  /* "cassandra/connection.py":624
 *                 self.compressor = self._compressor
 *             self.connected_event.set()
 *         elif isinstance(startup_response, AuthenticateMessage):             # <<<<<<<<<<<<<<
 *             log.debug("Got AuthenticateMessage on new connection (%s) from %s: %s",
 *                       id(self), self.host, startup_response.authenticator)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_AuthenticateMessage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_IsInstance(__pyx_v_startup_response, __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "cassandra/connection.py":625
 *             self.connected_event.set()
 *         elif isinstance(startup_response, AuthenticateMessage):
 *             log.debug("Got AuthenticateMessage on new connection (%s) from %s: %s",             # <<<<<<<<<<<<<<
 *                       id(self), self.host, startup_response.authenticator)
 * 
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_debug); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "cassandra/connection.py":626
 *         elif isinstance(startup_response, AuthenticateMessage):
 *             log.debug("Got AuthenticateMessage on new connection (%s) from %s: %s",
 *                       id(self), self.host, startup_response.authenticator)             # <<<<<<<<<<<<<<
 * 
 *             if self.authenticator is None:
 */
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_v_self);
    __Pyx_GIVEREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_self);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_startup_response, __pyx_n_s_authenticator); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_8 = 1;
      }
    }
    __pyx_t_10 = PyTuple_New(4+__pyx_t_8); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_s_Got_AuthenticateMessage_on_new_c);
    __Pyx_GIVEREF(__pyx_kp_s_Got_AuthenticateMessage_on_new_c);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_8, __pyx_kp_s_Got_AuthenticateMessage_on_new_c);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_8, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_8, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_8, __pyx_t_6);
    __pyx_t_4 = 0;
    __pyx_t_9 = 0;
    __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cassandra/connection.py":628
 *                       id(self), self.host, startup_response.authenticator)
 * 
 *             if self.authenticator is None:             # <<<<<<<<<<<<<<
 *                 raise AuthenticationFailed('Remote end requires authentication.')
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_authenticator); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = (__pyx_t_1 == Py_None);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = (__pyx_t_2 != 0);
    if (__pyx_t_3) {

      /* "cassandra/connection.py":629
 * 
 *             if self.authenticator is None:
 *                 raise AuthenticationFailed('Remote end requires authentication.')             # <<<<<<<<<<<<<<
 * 
 *             self.authenticator_class = startup_response.authenticator
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_AuthenticationFailed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "cassandra/connection.py":631
 *                 raise AuthenticationFailed('Remote end requires authentication.')
 * 
 *             self.authenticator_class = startup_response.authenticator             # <<<<<<<<<<<<<<
 * 
 *             if isinstance(self.authenticator, dict):
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_startup_response, __pyx_n_s_authenticator); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_authenticator_class, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cassandra/connection.py":633
 *             self.authenticator_class = startup_response.authenticator
 * 
 *             if isinstance(self.authenticator, dict):             # <<<<<<<<<<<<<<
 *                 log.debug("Sending credentials-based auth response on %s", self)
 *                 cm = CredentialsMessage(creds=self.authenticator)
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_authenticator); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyDict_Check(__pyx_t_5); 
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = (__pyx_t_3 != 0);
    if (__pyx_t_2) {

      /* "cassandra/connection.py":634
 * 
 *             if isinstance(self.authenticator, dict):
 *                 log.debug("Sending credentials-based auth response on %s", self)             # <<<<<<<<<<<<<<
 *                 cm = CredentialsMessage(creds=self.authenticator)
 *                 callback = partial(self._handle_startup_response, did_authenticate=True)
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_debug); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
          __pyx_t_8 = 1;
        }
      }
      __pyx_t_6 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_INCREF(__pyx_kp_s_Sending_credentials_based_auth_r);
      __Pyx_GIVEREF(__pyx_kp_s_Sending_credentials_based_auth_r);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_8, __pyx_kp_s_Sending_credentials_based_auth_r);
      __Pyx_INCREF(__pyx_v_self);
      __Pyx_GIVEREF(__pyx_v_self);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_8, __pyx_v_self);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cassandra/connection.py":635
 *             if isinstance(self.authenticator, dict):
 *                 log.debug("Sending credentials-based auth response on %s", self)
 *                 cm = CredentialsMessage(creds=self.authenticator)             # <<<<<<<<<<<<<<
 *                 callback = partial(self._handle_startup_response, did_authenticate=True)
 *                 self.send_msg(cm, self.get_request_id(), cb=callback)
 */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_CredentialsMessage); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_authenticator); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_creds, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, __pyx_t_10); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_v_cm = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "cassandra/connection.py":636
 *                 log.debug("Sending credentials-based auth response on %s", self)
 *                 cm = CredentialsMessage(creds=self.authenticator)
 *                 callback = partial(self._handle_startup_response, did_authenticate=True)             # <<<<<<<<<<<<<<
 *                 self.send_msg(cm, self.get_request_id(), cb=callback)
 *             else:
 */
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_partial); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_handle_startup_response); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_10);
      __pyx_t_10 = 0;
      __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_did_authenticate, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_v_callback = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "cassandra/connection.py":637
 *                 cm = CredentialsMessage(creds=self.authenticator)
 *                 callback = partial(self._handle_startup_response, did_authenticate=True)
 *                 self.send_msg(cm, self.get_request_id(), cb=callback)             # <<<<<<<<<<<<<<
 *             else:
 *                 log.debug("Sending SASL-based auth response on %s", self)
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send_msg); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_get_request_id); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (__pyx_t_6) {
        __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else {
        __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_cm);
      __Pyx_GIVEREF(__pyx_v_cm);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_cm);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_10);
      __pyx_t_10 = 0;
      __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_cb, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_10); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L7;
    }
    /*else*/ {

      /* "cassandra/connection.py":639
 *                 self.send_msg(cm, self.get_request_id(), cb=callback)
 *             else:
 *                 log.debug("Sending SASL-based auth response on %s", self)             # <<<<<<<<<<<<<<
 *                 initial_response = self.authenticator.initial_response()
 *                 initial_response = "" if initial_response is None else initial_response
 */
      __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_debug); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_8 = 1;
        }
      }
      __pyx_t_1 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_INCREF(__pyx_kp_s_Sending_SASL_based_auth_response);
      __Pyx_GIVEREF(__pyx_kp_s_Sending_SASL_based_auth_response);
      PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_8, __pyx_kp_s_Sending_SASL_based_auth_response);
      __Pyx_INCREF(__pyx_v_self);
      __Pyx_GIVEREF(__pyx_v_self);
      PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_8, __pyx_v_self);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "cassandra/connection.py":640
 *             else:
 *                 log.debug("Sending SASL-based auth response on %s", self)
 *                 initial_response = self.authenticator.initial_response()             # <<<<<<<<<<<<<<
 *                 initial_response = "" if initial_response is None else initial_response
 *                 self.send_msg(AuthResponseMessage(initial_response), self.get_request_id(), self._handle_auth_response)
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_authenticator); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_initial_response); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      if (__pyx_t_5) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else {
        __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_initial_response = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "cassandra/connection.py":641
 *                 log.debug("Sending SASL-based auth response on %s", self)
 *                 initial_response = self.authenticator.initial_response()
 *                 initial_response = "" if initial_response is None else initial_response             # <<<<<<<<<<<<<<
 *                 self.send_msg(AuthResponseMessage(initial_response), self.get_request_id(), self._handle_auth_response)
 *         elif isinstance(startup_response, ErrorMessage):
 */
      __pyx_t_2 = (__pyx_v_initial_response == Py_None);
      if ((__pyx_t_2 != 0)) {
        __Pyx_INCREF(__pyx_kp_s__5);
        __pyx_t_6 = __pyx_kp_s__5;
      } else {
        __Pyx_INCREF(__pyx_v_initial_response);
        __pyx_t_6 = __pyx_v_initial_response;
      }
      __Pyx_DECREF_SET(__pyx_v_initial_response, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "cassandra/connection.py":642
 *                 initial_response = self.authenticator.initial_response()
 *                 initial_response = "" if initial_response is None else initial_response
 *                 self.send_msg(AuthResponseMessage(initial_response), self.get_request_id(), self._handle_auth_response)             # <<<<<<<<<<<<<<
 *         elif isinstance(startup_response, ErrorMessage):
 *             log.debug("Received ErrorMessage on new connection (%s) from %s: %s",
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send_msg); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_AuthResponseMessage); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_9 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
        }
      }
      if (!__pyx_t_9) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_initial_response); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
      } else {
        __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_INCREF(__pyx_v_initial_response);
        __Pyx_GIVEREF(__pyx_v_initial_response);
        PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_initial_response);
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_get_request_id); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (__pyx_t_9) {
        __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_handle_auth_response); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = NULL;
      __pyx_t_8 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
          __pyx_t_8 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_9) {
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_9); __pyx_t_9 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_8, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_8, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_8, __pyx_t_4);
      __pyx_t_5 = 0;
      __pyx_t_10 = 0;
      __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __pyx_L7:;
    goto __pyx_L4;
  }

  /* "cassandra/connection.py":643
 *                 initial_response = "" if initial_response is None else initial_response
 *                 self.send_msg(AuthResponseMessage(initial_response), self.get_request_id(), self._handle_auth_response)
 *         elif isinstance(startup_response, ErrorMessage):             # <<<<<<<<<<<<<<
 *             log.debug("Received ErrorMessage on new connection (%s) from %s: %s",
 *                       id(self), self.host, startup_response.summary_msg())
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_ErrorMessage); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_startup_response, __pyx_t_6); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cassandra/connection.py":644
 *                 self.send_msg(AuthResponseMessage(initial_response), self.get_request_id(), self._handle_auth_response)
 *         elif isinstance(startup_response, ErrorMessage):
 *             log.debug("Received ErrorMessage on new connection (%s) from %s: %s",             # <<<<<<<<<<<<<<
 *                       id(self), self.host, startup_response.summary_msg())
 *             if did_authenticate:
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_debug); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cassandra/connection.py":645
 *         elif isinstance(startup_response, ErrorMessage):
 *             log.debug("Received ErrorMessage on new connection (%s) from %s: %s",
 *                       id(self), self.host, startup_response.summary_msg())             # <<<<<<<<<<<<<<
 *             if did_authenticate:
 *                 raise AuthenticationFailed(
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_self);
    __Pyx_GIVEREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_startup_response, __pyx_n_s_summary_msg); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (__pyx_t_9) {
      __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else {
      __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
        __pyx_t_8 = 1;
      }
    }
    __pyx_t_9 = PyTuple_New(4+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_s_Received_ErrorMessage_on_new_con);
    __Pyx_GIVEREF(__pyx_kp_s_Received_ErrorMessage_on_new_con);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_kp_s_Received_ErrorMessage_on_new_con);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_9, 3+__pyx_t_8, __pyx_t_10);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_t_10 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cassandra/connection.py":646
 *             log.debug("Received ErrorMessage on new connection (%s) from %s: %s",
 *                       id(self), self.host, startup_response.summary_msg())
 *             if did_authenticate:             # <<<<<<<<<<<<<<
 *                 raise AuthenticationFailed(
 *                     "Failed to authenticate to %s: %s" %
 */
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_did_authenticate); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_3) {

      /* "cassandra/connection.py":647
 *                       id(self), self.host, startup_response.summary_msg())
 *             if did_authenticate:
 *                 raise AuthenticationFailed(             # <<<<<<<<<<<<<<
 *                     "Failed to authenticate to %s: %s" %
 *                     (self.host, startup_response.summary_msg()))
 */
      __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_AuthenticationFailed); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);

      /* "cassandra/connection.py":649
 *                 raise AuthenticationFailed(
 *                     "Failed to authenticate to %s: %s" %
 *                     (self.host, startup_response.summary_msg()))             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ConnectionException(
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_startup_response, __pyx_n_s_summary_msg); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_10);
      __pyx_t_9 = 0;
      __pyx_t_10 = 0;

      /* "cassandra/connection.py":648
 *             if did_authenticate:
 *                 raise AuthenticationFailed(
 *                     "Failed to authenticate to %s: %s" %             # <<<<<<<<<<<<<<
 *                     (self.host, startup_response.summary_msg()))
 *             else:
 */
      __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_Failed_to_authenticate_to_s_s, __pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      if (!__pyx_t_1) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_10); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1); __pyx_t_1 = NULL;
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_10);
        __pyx_t_10 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    /*else*/ {

      /* "cassandra/connection.py":651
 *                     (self.host, startup_response.summary_msg()))
 *             else:
 *                 raise ConnectionException(             # <<<<<<<<<<<<<<
 *                     "Failed to initialize new connection to %s: %s"
 *                     % (self.host, startup_response.summary_msg()))
 */
      __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConnectionException); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);

      /* "cassandra/connection.py":653
 *                 raise ConnectionException(
 *                     "Failed to initialize new connection to %s: %s"
 *                     % (self.host, startup_response.summary_msg()))             # <<<<<<<<<<<<<<
 *         elif isinstance(startup_response, ConnectionShutdown):
 *             log.debug("Connection to %s was closed during the startup handshake", (self.host))
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_startup_response, __pyx_n_s_summary_msg); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_10);
      __pyx_t_9 = 0;
      __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_Failed_to_initialize_new_connect, __pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      if (!__pyx_t_1) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_10); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1); __pyx_t_1 = NULL;
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_10);
        __pyx_t_10 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }

  /* "cassandra/connection.py":654
 *                     "Failed to initialize new connection to %s: %s"
 *                     % (self.host, startup_response.summary_msg()))
 *         elif isinstance(startup_response, ConnectionShutdown):             # <<<<<<<<<<<<<<
 *             log.debug("Connection to %s was closed during the startup handshake", (self.host))
 *             raise startup_response
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConnectionShutdown); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = PyObject_IsInstance(__pyx_v_startup_response, __pyx_t_6); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "cassandra/connection.py":655
 *                     % (self.host, startup_response.summary_msg()))
 *         elif isinstance(startup_response, ConnectionShutdown):
 *             log.debug("Connection to %s was closed during the startup handshake", (self.host))             # <<<<<<<<<<<<<<
 *             raise startup_response
 *         else:
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_debug); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_10 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
        __pyx_t_8 = 1;
      }
    }
    __pyx_t_1 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (__pyx_t_10) {
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10); __pyx_t_10 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_s_Connection_to_s_was_closed_durin);
    __Pyx_GIVEREF(__pyx_kp_s_Connection_to_s_was_closed_durin);
    PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_8, __pyx_kp_s_Connection_to_s_was_closed_durin);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_8, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cassandra/connection.py":656
 *         elif isinstance(startup_response, ConnectionShutdown):
 *             log.debug("Connection to %s was closed during the startup handshake", (self.host))
 *             raise startup_response             # <<<<<<<<<<<<<<
 *         else:
 *             msg = "Unexpected response during Connection setup: %r"
 */
    __Pyx_Raise(__pyx_v_startup_response, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  /*else*/ {

    /* "cassandra/connection.py":658
 *             raise startup_response
 *         else:
 *             msg = "Unexpected response during Connection setup: %r"             # <<<<<<<<<<<<<<
 *             log.error(msg, startup_response)
 *             raise ProtocolError(msg % (startup_response,))
 */
    __Pyx_INCREF(__pyx_kp_s_Unexpected_response_during_Conne);
    __pyx_v_msg = __pyx_kp_s_Unexpected_response_during_Conne;

    /* "cassandra/connection.py":659
 *         else:
 *             msg = "Unexpected response during Connection setup: %r"
 *             log.error(msg, startup_response)             # <<<<<<<<<<<<<<
 *             raise ProtocolError(msg % (startup_response,))
 * 
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_8 = 1;
      }
    }
    __pyx_t_7 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_9) {
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_9); __pyx_t_9 = NULL;
    }
    __Pyx_INCREF(__pyx_v_msg);
    __Pyx_GIVEREF(__pyx_v_msg);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_8, __pyx_v_msg);
    __Pyx_INCREF(__pyx_v_startup_response);
    __Pyx_GIVEREF(__pyx_v_startup_response);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_8, __pyx_v_startup_response);
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cassandra/connection.py":660
 *             msg = "Unexpected response during Connection setup: %r"
 *             log.error(msg, startup_response)
 *             raise ProtocolError(msg % (startup_response,))             # <<<<<<<<<<<<<<
 * 
 *     @defunct_on_error
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_startup_response);
    __Pyx_GIVEREF(__pyx_v_startup_response);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_startup_response);
    __pyx_t_9 = PyNumber_Remainder(__pyx_v_msg, __pyx_t_7); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L4:;

  /* "cassandra/connection.py":616
 * 
 *     @defunct_on_error
 *     def _handle_startup_response(self, startup_response, did_authenticate=False):             # <<<<<<<<<<<<<<
 *         if self.is_defunct:
 *             return
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cassandra.connection.Connection._handle_startup_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_cm);
  __Pyx_XDECREF(__pyx_v_callback);
  __Pyx_XDECREF(__pyx_v_initial_response);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":663
 * 
 *     @defunct_on_error
 *     def _handle_auth_response(self, auth_response):             # <<<<<<<<<<<<<<
 *         if self.is_defunct:
 *             return
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_51_handle_auth_response(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_51_handle_auth_response = {"_handle_auth_response", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_51_handle_auth_response, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_51_handle_auth_response(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_auth_response = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_handle_auth_response (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_auth_response,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_auth_response)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_handle_auth_response", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_handle_auth_response") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_auth_response = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_handle_auth_response", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Connection._handle_auth_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_50_handle_auth_response(__pyx_self, __pyx_v_self, __pyx_v_auth_response);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_50_handle_auth_response(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_auth_response) {
  PyObject *__pyx_v_response = NULL;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_handle_auth_response", 0);

  /* "cassandra/connection.py":664
 *     @defunct_on_error
 *     def _handle_auth_response(self, auth_response):
 *         if self.is_defunct:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_is_defunct); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cassandra/connection.py":665
 *     def _handle_auth_response(self, auth_response):
 *         if self.is_defunct:
 *             return             # <<<<<<<<<<<<<<
 * 
 *         if isinstance(auth_response, AuthSuccessMessage):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }

  /* "cassandra/connection.py":667
 *             return
 * 
 *         if isinstance(auth_response, AuthSuccessMessage):             # <<<<<<<<<<<<<<
 *             log.debug("Connection %s successfully authenticated", self)
 *             self.authenticator.on_authentication_success(auth_response.token)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_AuthSuccessMessage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_auth_response, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cassandra/connection.py":668
 * 
 *         if isinstance(auth_response, AuthSuccessMessage):
 *             log.debug("Connection %s successfully authenticated", self)             # <<<<<<<<<<<<<<
 *             self.authenticator.on_authentication_success(auth_response.token)
 *             if self._compressor:
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_debug); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_6 = 1;
      }
    }
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_s_Connection_s_successfully_authen);
    __Pyx_GIVEREF(__pyx_kp_s_Connection_s_successfully_authen);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_kp_s_Connection_s_successfully_authen);
    __Pyx_INCREF(__pyx_v_self);
    __Pyx_GIVEREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_self);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cassandra/connection.py":669
 *         if isinstance(auth_response, AuthSuccessMessage):
 *             log.debug("Connection %s successfully authenticated", self)
 *             self.authenticator.on_authentication_success(auth_response.token)             # <<<<<<<<<<<<<<
 *             if self._compressor:
 *                 self.compressor = self._compressor
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_authenticator); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_on_authentication_success); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_auth_response, __pyx_n_s_token); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cassandra/connection.py":670
 *             log.debug("Connection %s successfully authenticated", self)
 *             self.authenticator.on_authentication_success(auth_response.token)
 *             if self._compressor:             # <<<<<<<<<<<<<<
 *                 self.compressor = self._compressor
 *             self.connected_event.set()
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_compressor_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {

      /* "cassandra/connection.py":671
 *             self.authenticator.on_authentication_success(auth_response.token)
 *             if self._compressor:
 *                 self.compressor = self._compressor             # <<<<<<<<<<<<<<
 *             self.connected_event.set()
 *         elif isinstance(auth_response, AuthChallengeMessage):
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_compressor_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_compressor, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "cassandra/connection.py":672
 *             if self._compressor:
 *                 self.compressor = self._compressor
 *             self.connected_event.set()             # <<<<<<<<<<<<<<
 *         elif isinstance(auth_response, AuthChallengeMessage):
 *             response = self.authenticator.evaluate_challenge(auth_response.challenge)
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_connected_event); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_set); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L4;
  }

  /* "cassandra/connection.py":673
 *                 self.compressor = self._compressor
 *             self.connected_event.set()
 *         elif isinstance(auth_response, AuthChallengeMessage):             # <<<<<<<<<<<<<<
 *             response = self.authenticator.evaluate_challenge(auth_response.challenge)
 *             msg = AuthResponseMessage("" if response is None else response)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_AuthChallengeMessage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_IsInstance(__pyx_v_auth_response, __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "cassandra/connection.py":674
 *             self.connected_event.set()
 *         elif isinstance(auth_response, AuthChallengeMessage):
 *             response = self.authenticator.evaluate_challenge(auth_response.challenge)             # <<<<<<<<<<<<<<
 *             msg = AuthResponseMessage("" if response is None else response)
 *             log.debug("Responding to auth challenge on %s", self)
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_authenticator); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_evaluate_challenge); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_auth_response, __pyx_n_s_challenge); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_response = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cassandra/connection.py":675
 *         elif isinstance(auth_response, AuthChallengeMessage):
 *             response = self.authenticator.evaluate_challenge(auth_response.challenge)
 *             msg = AuthResponseMessage("" if response is None else response)             # <<<<<<<<<<<<<<
 *             log.debug("Responding to auth challenge on %s", self)
 *             self.send_msg(msg, self.get_request_id(), self._handle_auth_response)
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_AuthResponseMessage); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_2 = (__pyx_v_response == Py_None);
    if ((__pyx_t_2 != 0)) {
      __Pyx_INCREF(__pyx_kp_s__5);
      __pyx_t_4 = __pyx_kp_s__5;
    } else {
      __Pyx_INCREF(__pyx_v_response);
      __pyx_t_4 = __pyx_v_response;
    }
    __pyx_t_8 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_8); __pyx_t_8 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_msg = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cassandra/connection.py":676
 *             response = self.authenticator.evaluate_challenge(auth_response.challenge)
 *             msg = AuthResponseMessage("" if response is None else response)
 *             log.debug("Responding to auth challenge on %s", self)             # <<<<<<<<<<<<<<
 *             self.send_msg(msg, self.get_request_id(), self._handle_auth_response)
 *         elif isinstance(auth_response, ErrorMessage):
 */
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_debug); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_6 = 1;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_s_Responding_to_auth_challenge_on);
    __Pyx_GIVEREF(__pyx_kp_s_Responding_to_auth_challenge_on);
    PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_kp_s_Responding_to_auth_challenge_on);
    __Pyx_INCREF(__pyx_v_self);
    __Pyx_GIVEREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_v_self);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cassandra/connection.py":677
 *             msg = AuthResponseMessage("" if response is None else response)
 *             log.debug("Responding to auth challenge on %s", self)
 *             self.send_msg(msg, self.get_request_id(), self._handle_auth_response)             # <<<<<<<<<<<<<<
 *         elif isinstance(auth_response, ErrorMessage):
 *             log.debug("Received ErrorMessage on new connection (%s) from %s: %s",
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_send_msg); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_get_request_id); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (__pyx_t_8) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_handle_auth_response); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_6 = 1;
      }
    }
    __pyx_t_9 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_INCREF(__pyx_v_msg);
    __Pyx_GIVEREF(__pyx_v_msg);
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_6, __pyx_v_msg);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_6, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_6, __pyx_t_7);
    __pyx_t_4 = 0;
    __pyx_t_7 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L4;
  }

  /* "cassandra/connection.py":678
 *             log.debug("Responding to auth challenge on %s", self)
 *             self.send_msg(msg, self.get_request_id(), self._handle_auth_response)
 *         elif isinstance(auth_response, ErrorMessage):             # <<<<<<<<<<<<<<
 *             log.debug("Received ErrorMessage on new connection (%s) from %s: %s",
 *                       id(self), self.host, auth_response.summary_msg())
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ErrorMessage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_auth_response, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cassandra/connection.py":679
 *             self.send_msg(msg, self.get_request_id(), self._handle_auth_response)
 *         elif isinstance(auth_response, ErrorMessage):
 *             log.debug("Received ErrorMessage on new connection (%s) from %s: %s",             # <<<<<<<<<<<<<<
 *                       id(self), self.host, auth_response.summary_msg())
 *             raise AuthenticationFailed(
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_debug); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cassandra/connection.py":680
 *         elif isinstance(auth_response, ErrorMessage):
 *             log.debug("Received ErrorMessage on new connection (%s) from %s: %s",
 *                       id(self), self.host, auth_response.summary_msg())             # <<<<<<<<<<<<<<
 *             raise AuthenticationFailed(
 *                 "Failed to authenticate to %s: %s" %
 */
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_self);
    __Pyx_GIVEREF(__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_auth_response, __pyx_n_s_summary_msg); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_10 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (__pyx_t_10) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_10); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
        __pyx_t_6 = 1;
      }
    }
    __pyx_t_10 = PyTuple_New(4+__pyx_t_6); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_s_Received_ErrorMessage_on_new_con);
    __Pyx_GIVEREF(__pyx_kp_s_Received_ErrorMessage_on_new_con);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_6, __pyx_kp_s_Received_ErrorMessage_on_new_con);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_6, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_6, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_6, __pyx_t_4);
    __pyx_t_7 = 0;
    __pyx_t_5 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cassandra/connection.py":681
 *             log.debug("Received ErrorMessage on new connection (%s) from %s: %s",
 *                       id(self), self.host, auth_response.summary_msg())
 *             raise AuthenticationFailed(             # <<<<<<<<<<<<<<
 *                 "Failed to authenticate to %s: %s" %
 *                 (self.host, auth_response.summary_msg()))
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_AuthenticationFailed); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);

    /* "cassandra/connection.py":683
 *             raise AuthenticationFailed(
 *                 "Failed to authenticate to %s: %s" %
 *                 (self.host, auth_response.summary_msg()))             # <<<<<<<<<<<<<<
 *         elif isinstance(auth_response, ConnectionShutdown):
 *             log.debug("Connection to %s was closed during the authentication process", self.host)
 */
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_auth_response, __pyx_n_s_summary_msg); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (__pyx_t_7) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
    __pyx_t_10 = 0;
    __pyx_t_4 = 0;

    /* "cassandra/connection.py":682
 *                       id(self), self.host, auth_response.summary_msg())
 *             raise AuthenticationFailed(
 *                 "Failed to authenticate to %s: %s" %             # <<<<<<<<<<<<<<
 *                 (self.host, auth_response.summary_msg()))
 *         elif isinstance(auth_response, ConnectionShutdown):
 */
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Failed_to_authenticate_to_s_s, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cassandra/connection.py":684
 *                 "Failed to authenticate to %s: %s" %
 *                 (self.host, auth_response.summary_msg()))
 *         elif isinstance(auth_response, ConnectionShutdown):             # <<<<<<<<<<<<<<
 *             log.debug("Connection to %s was closed during the authentication process", self.host)
 *             raise auth_response
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConnectionShutdown); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_IsInstance(__pyx_v_auth_response, __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "cassandra/connection.py":685
 *                 (self.host, auth_response.summary_msg()))
 *         elif isinstance(auth_response, ConnectionShutdown):
 *             log.debug("Connection to %s was closed during the authentication process", self.host)             # <<<<<<<<<<<<<<
 *             raise auth_response
 *         else:
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_debug); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_4 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
        __pyx_t_6 = 1;
      }
    }
    __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_kp_s_Connection_to_s_was_closed_durin_2);
    __Pyx_GIVEREF(__pyx_kp_s_Connection_to_s_was_closed_durin_2);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_kp_s_Connection_to_s_was_closed_durin_2);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cassandra/connection.py":686
 *         elif isinstance(auth_response, ConnectionShutdown):
 *             log.debug("Connection to %s was closed during the authentication process", self.host)
 *             raise auth_response             # <<<<<<<<<<<<<<
 *         else:
 *             msg = "Unexpected response during Connection authentication to %s: %r"
 */
    __Pyx_Raise(__pyx_v_auth_response, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  /*else*/ {

    /* "cassandra/connection.py":688
 *             raise auth_response
 *         else:
 *             msg = "Unexpected response during Connection authentication to %s: %r"             # <<<<<<<<<<<<<<
 *             log.error(msg, self.host, auth_response)
 *             raise ProtocolError(msg % (self.host, auth_response))
 */
    __Pyx_INCREF(__pyx_kp_s_Unexpected_response_during_Conne_2);
    __pyx_v_msg = __pyx_kp_s_Unexpected_response_during_Conne_2;

    /* "cassandra/connection.py":689
 *         else:
 *             msg = "Unexpected response during Connection authentication to %s: %r"
 *             log.error(msg, self.host, auth_response)             # <<<<<<<<<<<<<<
 *             raise ProtocolError(msg % (self.host, auth_response))
 * 
 */
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_error); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_9 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_6 = 1;
      }
    }
    __pyx_t_4 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (__pyx_t_9) {
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_9); __pyx_t_9 = NULL;
    }
    __Pyx_INCREF(__pyx_v_msg);
    __Pyx_GIVEREF(__pyx_v_msg);
    PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_v_msg);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_t_10);
    __Pyx_INCREF(__pyx_v_auth_response);
    __Pyx_GIVEREF(__pyx_v_auth_response);
    PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_6, __pyx_v_auth_response);
    __pyx_t_10 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cassandra/connection.py":690
 *             msg = "Unexpected response during Connection authentication to %s: %r"
 *             log.error(msg, self.host, auth_response)
 *             raise ProtocolError(msg % (self.host, auth_response))             # <<<<<<<<<<<<<<
 * 
 *     def set_keyspace_blocking(self, keyspace):
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_ProtocolError); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4);
    __Pyx_INCREF(__pyx_v_auth_response);
    __Pyx_GIVEREF(__pyx_v_auth_response);
    PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_auth_response);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Remainder(__pyx_v_msg, __pyx_t_10); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L4:;

  /* "cassandra/connection.py":663
 * 
 *     @defunct_on_error
 *     def _handle_auth_response(self, auth_response):             # <<<<<<<<<<<<<<
 *         if self.is_defunct:
 *             return
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("cassandra.connection.Connection._handle_auth_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_response);
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":692
 *             raise ProtocolError(msg % (self.host, auth_response))
 * 
 *     def set_keyspace_blocking(self, keyspace):             # <<<<<<<<<<<<<<
 *         if not keyspace or keyspace == self.keyspace:
 *             return
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_53set_keyspace_blocking(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_53set_keyspace_blocking = {"set_keyspace_blocking", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_53set_keyspace_blocking, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_53set_keyspace_blocking(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_keyspace = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_keyspace_blocking (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_keyspace,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_keyspace)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("set_keyspace_blocking", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_keyspace_blocking") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_keyspace = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set_keyspace_blocking", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Connection.set_keyspace_blocking", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_52set_keyspace_blocking(__pyx_self, __pyx_v_self, __pyx_v_keyspace);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_52set_keyspace_blocking(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_keyspace) {
  PyObject *__pyx_v_query = NULL;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_ire = NULL;
  PyObject *__pyx_v_exc = NULL;
  PyObject *__pyx_v_conn_exc = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  Py_ssize_t __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_keyspace_blocking", 0);

  /* "cassandra/connection.py":693
 * 
 *     def set_keyspace_blocking(self, keyspace):
 *         if not keyspace or keyspace == self.keyspace:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_keyspace); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = ((!__pyx_t_2) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_keyspace); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_RichCompare(__pyx_v_keyspace, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "cassandra/connection.py":694
 *     def set_keyspace_blocking(self, keyspace):
 *         if not keyspace or keyspace == self.keyspace:
 *             return             # <<<<<<<<<<<<<<
 * 
 *         query = QueryMessage(query='USE "%s"' % (keyspace,),
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }

  /* "cassandra/connection.py":696
 *             return
 * 
 *         query = QueryMessage(query='USE "%s"' % (keyspace,),             # <<<<<<<<<<<<<<
 *                              consistency_level=ConsistencyLevel.ONE)
 *         try:
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_QueryMessage); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_keyspace);
  __Pyx_GIVEREF(__pyx_v_keyspace);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_keyspace);
  __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_USE_s, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_query, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cassandra/connection.py":697
 * 
 *         query = QueryMessage(query='USE "%s"' % (keyspace,),
 *                              consistency_level=ConsistencyLevel.ONE)             # <<<<<<<<<<<<<<
 *         try:
 *             result = self.wait_for_response(query)
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConsistencyLevel); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_ONE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_consistency_level, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cassandra/connection.py":696
 *             return
 * 
 *         query = QueryMessage(query='USE "%s"' % (keyspace,),             # <<<<<<<<<<<<<<
 *                              consistency_level=ConsistencyLevel.ONE)
 *         try:
 */
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_query = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "cassandra/connection.py":698
 *         query = QueryMessage(query='USE "%s"' % (keyspace,),
 *                              consistency_level=ConsistencyLevel.ONE)
 *         try:             # <<<<<<<<<<<<<<
 *             result = self.wait_for_response(query)
 *         except InvalidRequestException as ire:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
    __Pyx_XGOTREF(__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_9);
    __Pyx_XGOTREF(__pyx_t_10);
    /*try:*/ {

      /* "cassandra/connection.py":699
 *                              consistency_level=ConsistencyLevel.ONE)
 *         try:
 *             result = self.wait_for_response(query)             # <<<<<<<<<<<<<<
 *         except InvalidRequestException as ire:
 *             # the keyspace probably doesn't exist
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_wait_for_response); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_query); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_INCREF(__pyx_v_query);
        __Pyx_GIVEREF(__pyx_v_query);
        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_query);
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_result = __pyx_t_6;
      __pyx_t_6 = 0;
    }
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    goto __pyx_L13_try_end;
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cassandra/connection.py":700
 *         try:
 *             result = self.wait_for_response(query)
 *         except InvalidRequestException as ire:             # <<<<<<<<<<<<<<
 *             # the keyspace probably doesn't exist
 *             raise ire.to_exception()
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_InvalidRequestException); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_11 = PyErr_ExceptionMatches(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_11) {
      __Pyx_AddTraceback("cassandra.connection.Connection.set_keyspace_blocking", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_4, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_4);
      __pyx_v_ire = __pyx_t_4;

      /* "cassandra/connection.py":702
 *         except InvalidRequestException as ire:
 *             # the keyspace probably doesn't exist
 *             raise ire.to_exception()             # <<<<<<<<<<<<<<
 *         except Exception as exc:
 *             conn_exc = ConnectionException(
 */
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_ire, __pyx_n_s_to_exception); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_13)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
        }
      }
      if (__pyx_t_13) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      } else {
        __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      }
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
    }

    /* "cassandra/connection.py":703
 *             # the keyspace probably doesn't exist
 *             raise ire.to_exception()
 *         except Exception as exc:             # <<<<<<<<<<<<<<
 *             conn_exc = ConnectionException(
 *                 "Problem while setting keyspace: %r" % (exc,), self.host)
 */
    __pyx_t_11 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
    if (__pyx_t_11) {
      __Pyx_AddTraceback("cassandra.connection.Connection.set_keyspace_blocking", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_4, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __pyx_v_exc = __pyx_t_4;

      /* "cassandra/connection.py":704
 *             raise ire.to_exception()
 *         except Exception as exc:
 *             conn_exc = ConnectionException(             # <<<<<<<<<<<<<<
 *                 "Problem while setting keyspace: %r" % (exc,), self.host)
 *             self.defunct(conn_exc)
 */
      __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConnectionException); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(__pyx_t_12);

      /* "cassandra/connection.py":705
 *         except Exception as exc:
 *             conn_exc = ConnectionException(
 *                 "Problem while setting keyspace: %r" % (exc,), self.host)             # <<<<<<<<<<<<<<
 *             self.defunct(conn_exc)
 *             raise conn_exc
 */
      __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_INCREF(__pyx_v_exc);
      __Pyx_GIVEREF(__pyx_v_exc);
      PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_exc);
      __pyx_t_14 = __Pyx_PyString_Format(__pyx_kp_s_Problem_while_setting_keyspace_r, __pyx_t_13); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_15 = NULL;
      __pyx_t_16 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_15)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
          __pyx_t_16 = 1;
        }
      }
      __pyx_t_17 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(__pyx_t_17);
      if (__pyx_t_15) {
        __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_15); __pyx_t_15 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_14);
      PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_16, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_13);
      PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_16, __pyx_t_13);
      __pyx_t_14 = 0;
      __pyx_t_13 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_17, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_v_conn_exc = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "cassandra/connection.py":706
 *             conn_exc = ConnectionException(
 *                 "Problem while setting keyspace: %r" % (exc,), self.host)
 *             self.defunct(conn_exc)             # <<<<<<<<<<<<<<
 *             raise conn_exc
 * 
 */
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_defunct); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_17 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_17)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_17);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
        }
      }
      if (!__pyx_t_17) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_conn_exc); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_5);
      } else {
        __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_17); __pyx_t_17 = NULL;
        __Pyx_INCREF(__pyx_v_conn_exc);
        __Pyx_GIVEREF(__pyx_v_conn_exc);
        PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_v_conn_exc);
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_13, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cassandra/connection.py":707
 *                 "Problem while setting keyspace: %r" % (exc,), self.host)
 *             self.defunct(conn_exc)
 *             raise conn_exc             # <<<<<<<<<<<<<<
 * 
 *         if isinstance(result, ResultMessage):
 */
      __Pyx_Raise(__pyx_v_conn_exc, 0, 0, 0);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
    }
    goto __pyx_L8_except_error;
    __pyx_L8_except_error:;
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_XGIVEREF(__pyx_t_10);
    __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
    goto __pyx_L1_error;
    __pyx_L13_try_end:;
  }

  /* "cassandra/connection.py":709
 *             raise conn_exc
 * 
 *         if isinstance(result, ResultMessage):             # <<<<<<<<<<<<<<
 *             self.keyspace = keyspace
 *         else:
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_ResultMessage); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = PyObject_IsInstance(__pyx_v_result, __pyx_t_6); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_3 = (__pyx_t_1 != 0);
  if (__pyx_t_3) {

    /* "cassandra/connection.py":710
 * 
 *         if isinstance(result, ResultMessage):
 *             self.keyspace = keyspace             # <<<<<<<<<<<<<<
 *         else:
 *             conn_exc = ConnectionException(
 */
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_keyspace, __pyx_v_keyspace) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L18;
  }
  /*else*/ {

    /* "cassandra/connection.py":712
 *             self.keyspace = keyspace
 *         else:
 *             conn_exc = ConnectionException(             # <<<<<<<<<<<<<<
 *                 "Problem while setting keyspace: %r" % (result,), self.host)
 *             self.defunct(conn_exc)
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConnectionException); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);

    /* "cassandra/connection.py":713
 *         else:
 *             conn_exc = ConnectionException(
 *                 "Problem while setting keyspace: %r" % (result,), self.host)             # <<<<<<<<<<<<<<
 *             self.defunct(conn_exc)
 *             raise conn_exc
 */
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_result);
    __Pyx_GIVEREF(__pyx_v_result);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_result);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Problem_while_setting_keyspace_r, __pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_12 = NULL;
    __pyx_t_16 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_16 = 1;
      }
    }
    __pyx_t_13 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_13);
    if (__pyx_t_12) {
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); __pyx_t_12 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_16, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_16, __pyx_t_7);
    __pyx_t_5 = 0;
    __pyx_t_7 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_13, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_conn_exc = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "cassandra/connection.py":714
 *             conn_exc = ConnectionException(
 *                 "Problem while setting keyspace: %r" % (result,), self.host)
 *             self.defunct(conn_exc)             # <<<<<<<<<<<<<<
 *             raise conn_exc
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_defunct); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_13 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_13)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_13);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_13) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_conn_exc); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_13); __pyx_t_13 = NULL;
      __Pyx_INCREF(__pyx_v_conn_exc);
      __Pyx_GIVEREF(__pyx_v_conn_exc);
      PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_conn_exc);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "cassandra/connection.py":715
 *                 "Problem while setting keyspace: %r" % (result,), self.host)
 *             self.defunct(conn_exc)
 *             raise conn_exc             # <<<<<<<<<<<<<<
 * 
 *     def set_keyspace_async(self, keyspace, callback):
 */
    __Pyx_Raise(__pyx_v_conn_exc, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L18:;

  /* "cassandra/connection.py":692
 *             raise ProtocolError(msg % (self.host, auth_response))
 * 
 *     def set_keyspace_blocking(self, keyspace):             # <<<<<<<<<<<<<<
 *         if not keyspace or keyspace == self.keyspace:
 *             return
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_AddTraceback("cassandra.connection.Connection.set_keyspace_blocking", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_query);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_ire);
  __Pyx_XDECREF(__pyx_v_exc);
  __Pyx_XDECREF(__pyx_v_conn_exc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":717
 *             raise conn_exc
 * 
 *     def set_keyspace_async(self, keyspace, callback):             # <<<<<<<<<<<<<<
 *         """
 *         Use this in order to avoid deadlocking the event loop thread.
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_55set_keyspace_async(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9cassandra_10connection_10Connection_54set_keyspace_async[] = "\n        Use this in order to avoid deadlocking the event loop thread.\n        When the operation completes, `callback` will be called with\n        two arguments: this connection and an Exception if an error\n        occurred, otherwise :const:`None`.\n        ";
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_55set_keyspace_async = {"set_keyspace_async", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_55set_keyspace_async, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9cassandra_10connection_10Connection_54set_keyspace_async};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_55set_keyspace_async(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_keyspace = 0;
  PyObject *__pyx_v_callback = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_keyspace_async (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_keyspace,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_keyspace)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("set_keyspace_async", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("set_keyspace_async", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_keyspace_async") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_keyspace = values[1];
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set_keyspace_async", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Connection.set_keyspace_async", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_54set_keyspace_async(__pyx_self, __pyx_v_self, __pyx_v_keyspace, __pyx_v_callback);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":731
 *                              consistency_level=ConsistencyLevel.ONE)
 * 
 *         def process_result(result):             # <<<<<<<<<<<<<<
 *             if isinstance(result, ResultMessage):
 *                 self.keyspace = keyspace
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_18set_keyspace_async_1process_result(PyObject *__pyx_self, PyObject *__pyx_v_result); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_18set_keyspace_async_1process_result = {"process_result", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_18set_keyspace_async_1process_result, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_18set_keyspace_async_1process_result(PyObject *__pyx_self, PyObject *__pyx_v_result) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("process_result (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_18set_keyspace_async_process_result(__pyx_self, ((PyObject *)__pyx_v_result));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_18set_keyspace_async_process_result(PyObject *__pyx_self, PyObject *__pyx_v_result) {
  struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async *__pyx_cur_scope;
  struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async *__pyx_outer_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("process_result", 0);
  __pyx_outer_scope = (struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "cassandra/connection.py":732
 * 
 *         def process_result(result):
 *             if isinstance(result, ResultMessage):             # <<<<<<<<<<<<<<
 *                 self.keyspace = keyspace
 *                 callback(self, None)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ResultMessage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "cassandra/connection.py":733
 *         def process_result(result):
 *             if isinstance(result, ResultMessage):
 *                 self.keyspace = keyspace             # <<<<<<<<<<<<<<
 *                 callback(self, None)
 *             elif isinstance(result, InvalidRequestException):
 */
    if (unlikely(!__pyx_cur_scope->__pyx_v_keyspace)) { __Pyx_RaiseClosureNameError("keyspace"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_n_s_keyspace, __pyx_cur_scope->__pyx_v_keyspace) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "cassandra/connection.py":734
 *             if isinstance(result, ResultMessage):
 *                 self.keyspace = keyspace
 *                 callback(self, None)             # <<<<<<<<<<<<<<
 *             elif isinstance(result, InvalidRequestException):
 *                 callback(self, result.to_exception())
 */
    if (unlikely(!__pyx_cur_scope->__pyx_v_callback)) { __Pyx_RaiseClosureNameError("callback"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_callback);
    __pyx_t_4 = __pyx_cur_scope->__pyx_v_callback; __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_6 = 1;
      }
    }
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_cur_scope->__pyx_v_self);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, Py_None);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L3;
  }

  /* "cassandra/connection.py":735
 *                 self.keyspace = keyspace
 *                 callback(self, None)
 *             elif isinstance(result, InvalidRequestException):             # <<<<<<<<<<<<<<
 *                 callback(self, result.to_exception())
 *             else:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_InvalidRequestException); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_IsInstance(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "cassandra/connection.py":736
 *                 callback(self, None)
 *             elif isinstance(result, InvalidRequestException):
 *                 callback(self, result.to_exception())             # <<<<<<<<<<<<<<
 *             else:
 *                 callback(self, self.defunct(ConnectionException(
 */
    if (unlikely(!__pyx_cur_scope->__pyx_v_callback)) { __Pyx_RaiseClosureNameError("callback"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_result, __pyx_n_s_to_exception); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_callback);
    __pyx_t_7 = __pyx_cur_scope->__pyx_v_callback; __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
        __pyx_t_6 = 1;
      }
    }
    __pyx_t_8 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_6, __pyx_cur_scope->__pyx_v_self);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_6, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "cassandra/connection.py":738
 *                 callback(self, result.to_exception())
 *             else:
 *                 callback(self, self.defunct(ConnectionException(             # <<<<<<<<<<<<<<
 *                     "Problem while setting keyspace: %r" % (result,), self.host)))
 * 
 */
    if (unlikely(!__pyx_cur_scope->__pyx_v_callback)) { __Pyx_RaiseClosureNameError("callback"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_n_s_defunct); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConnectionException); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);

    /* "cassandra/connection.py":739
 *             else:
 *                 callback(self, self.defunct(ConnectionException(
 *                     "Problem while setting keyspace: %r" % (result,), self.host)))             # <<<<<<<<<<<<<<
 * 
 *         request_id = None
 */
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_v_result);
    __Pyx_GIVEREF(__pyx_v_result);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_result);
    __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_Problem_while_setting_keyspace_r, __pyx_t_9); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_11 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_6 = 1;
      }
    }
    __pyx_t_12 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    if (__pyx_t_11) {
      __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_6, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_6, __pyx_t_9);
    __pyx_t_10 = 0;
    __pyx_t_9 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_12, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_5) {
      __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_7);
    } else {
      __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_12, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_callback);
    __pyx_t_8 = __pyx_cur_scope->__pyx_v_callback; __pyx_t_12 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
        __pyx_t_6 = 1;
      }
    }
    __pyx_t_4 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (__pyx_t_12) {
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_12); __pyx_t_12 = NULL;
    }
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_6, __pyx_cur_scope->__pyx_v_self);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_6, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "cassandra/connection.py":731
 *                              consistency_level=ConsistencyLevel.ONE)
 * 
 *         def process_result(result):             # <<<<<<<<<<<<<<
 *             if isinstance(result, ResultMessage):
 *                 self.keyspace = keyspace
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("cassandra.connection.Connection.set_keyspace_async.process_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":717
 *             raise conn_exc
 * 
 *     def set_keyspace_async(self, keyspace, callback):             # <<<<<<<<<<<<<<
 *         """
 *         Use this in order to avoid deadlocking the event loop thread.
 */

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_54set_keyspace_async(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_keyspace, PyObject *__pyx_v_callback) {
  struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async *__pyx_cur_scope;
  PyObject *__pyx_v_query = NULL;
  PyObject *__pyx_v_process_result = 0;
  PyObject *__pyx_v_request_id = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_keyspace_async", 0);
  __pyx_cur_scope = (struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async *)__pyx_tp_new_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async(__pyx_ptype_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_keyspace = __pyx_v_keyspace;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_keyspace);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_keyspace);
  __pyx_cur_scope->__pyx_v_callback = __pyx_v_callback;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_callback);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_callback);

  /* "cassandra/connection.py":724
 *         occurred, otherwise :const:`None`.
 *         """
 *         if not keyspace or keyspace == self.keyspace:             # <<<<<<<<<<<<<<
 *             callback(self, None)
 *             return
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_keyspace); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = ((!__pyx_t_2) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_n_s_keyspace); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_keyspace, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "cassandra/connection.py":725
 *         """
 *         if not keyspace or keyspace == self.keyspace:
 *             callback(self, None)             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_callback);
    __pyx_t_4 = __pyx_cur_scope->__pyx_v_callback; __pyx_t_6 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_7 = 1;
      }
    }
    __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_cur_scope->__pyx_v_self);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, Py_None);
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "cassandra/connection.py":726
 *         if not keyspace or keyspace == self.keyspace:
 *             callback(self, None)
 *             return             # <<<<<<<<<<<<<<
 * 
 *         query = QueryMessage(query='USE "%s"' % (keyspace,),
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }

  /* "cassandra/connection.py":728
 *             return
 * 
 *         query = QueryMessage(query='USE "%s"' % (keyspace,),             # <<<<<<<<<<<<<<
 *                              consistency_level=ConsistencyLevel.ONE)
 * 
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_QueryMessage); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_keyspace);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_keyspace);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_cur_scope->__pyx_v_keyspace);
  __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_USE_s, __pyx_t_8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_query, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "cassandra/connection.py":729
 * 
 *         query = QueryMessage(query='USE "%s"' % (keyspace,),
 *                              consistency_level=ConsistencyLevel.ONE)             # <<<<<<<<<<<<<<
 * 
 *         def process_result(result):
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConsistencyLevel); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_ONE); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_consistency_level, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cassandra/connection.py":728
 *             return
 * 
 *         query = QueryMessage(query='USE "%s"' % (keyspace,),             # <<<<<<<<<<<<<<
 *                              consistency_level=ConsistencyLevel.ONE)
 * 
 */
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_query = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "cassandra/connection.py":731
 *                              consistency_level=ConsistencyLevel.ONE)
 * 
 *         def process_result(result):             # <<<<<<<<<<<<<<
 *             if isinstance(result, ResultMessage):
 *                 self.keyspace = keyspace
 */
  __pyx_t_8 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_18set_keyspace_async_1process_result, 0, __pyx_n_s_Connection_set_keyspace_async_lo, ((PyObject*)__pyx_cur_scope), __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__23)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_v_process_result = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "cassandra/connection.py":741
 *                     "Problem while setting keyspace: %r" % (result,), self.host)))
 * 
 *         request_id = None             # <<<<<<<<<<<<<<
 *         # we use a busy wait on the lock here because:
 *         # - we'll only spin if the connection is at max capacity, which is very
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_request_id = Py_None;

  /* "cassandra/connection.py":746
 *         #   unlikely for a set_keyspace call
 *         # - it allows us to avoid signaling a condition every time a request completes
 *         while True:             # <<<<<<<<<<<<<<
 *             with self.lock:
 *                 if self.in_flight < self.max_request_id:
 */
  while (1) {

    /* "cassandra/connection.py":747
 *         # - it allows us to avoid signaling a condition every time a request completes
 *         while True:
 *             with self.lock:             # <<<<<<<<<<<<<<
 *                 if self.in_flight < self.max_request_id:
 *                     request_id = self.get_request_id()
 */
    /*with:*/ {
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_n_s_lock); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_8, __pyx_n_s_exit); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_8, __pyx_n_s_enter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (__pyx_t_6) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else {
        __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
      }
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      /*try:*/ {
        {
          __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_12);
          /*try:*/ {

            /* "cassandra/connection.py":748
 *         while True:
 *             with self.lock:
 *                 if self.in_flight < self.max_request_id:             # <<<<<<<<<<<<<<
 *                     request_id = self.get_request_id()
 *                     self.in_flight += 1
 */
            __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_n_s_in_flight); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
            __Pyx_GOTREF(__pyx_t_8);
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_n_s_max_request_id); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_5 = PyObject_RichCompare(__pyx_t_8, __pyx_t_4, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (__pyx_t_1) {

              /* "cassandra/connection.py":749
 *             with self.lock:
 *                 if self.in_flight < self.max_request_id:
 *                     request_id = self.get_request_id()             # <<<<<<<<<<<<<<
 *                     self.in_flight += 1
 *                     break
 */
              __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_n_s_get_request_id); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_8 = NULL;
              if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
                __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
                if (likely(__pyx_t_8)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
                  __Pyx_INCREF(__pyx_t_8);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_4, function);
                }
              }
              if (__pyx_t_8) {
                __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_8); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
                __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
              } else {
                __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
              }
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF_SET(__pyx_v_request_id, __pyx_t_5);
              __pyx_t_5 = 0;

              /* "cassandra/connection.py":750
 *                 if self.in_flight < self.max_request_id:
 *                     request_id = self.get_request_id()
 *                     self.in_flight += 1             # <<<<<<<<<<<<<<
 *                     break
 * 
 */
              __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_n_s_in_flight); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_5, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_n_s_in_flight, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

              /* "cassandra/connection.py":751
 *                     request_id = self.get_request_id()
 *                     self.in_flight += 1
 *                     break             # <<<<<<<<<<<<<<
 * 
 *             time.sleep(0.001)
 */
              goto __pyx_L19_try_break;
            }
          }
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          goto __pyx_L21_try_end;
          __pyx_L14_error:;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "cassandra/connection.py":747
 *         # - it allows us to avoid signaling a condition every time a request completes
 *         while True:
 *             with self.lock:             # <<<<<<<<<<<<<<
 *                 if self.in_flight < self.max_request_id:
 *                     request_id = self.get_request_id()
 */
          /*except:*/ {
            __Pyx_AddTraceback("cassandra.connection.Connection.set_keyspace_async", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_GOTREF(__pyx_t_8);
            __pyx_t_6 = PyTuple_Pack(3, __pyx_t_4, __pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_6, NULL);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (__pyx_t_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
            __pyx_t_3 = ((!(__pyx_t_1 != 0)) != 0);
            if (__pyx_t_3) {
              __Pyx_GIVEREF(__pyx_t_4);
              __Pyx_GIVEREF(__pyx_t_5);
              __Pyx_XGIVEREF(__pyx_t_8);
              __Pyx_ErrRestore(__pyx_t_4, __pyx_t_5, __pyx_t_8);
              __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_8 = 0; 
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
            }
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            goto __pyx_L15_exception_handled;
          }
          __pyx_L16_except_error:;
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          goto __pyx_L1_error;
          __pyx_L19_try_break:;
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          goto __pyx_L10_break;
          __pyx_L15_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          __pyx_L21_try_end:;
        }
      }
      /*finally:*/ {
        /*normal exit:*/{
          if (__pyx_t_9) {
            __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__24, NULL);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          }
          goto __pyx_L13;
        }
        __pyx_L10_break: {
          if (__pyx_t_9) {
            __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__25, NULL);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          }
          goto __pyx_L7_break;
        }
        __pyx_L13:;
      }
      goto __pyx_L26;
      __pyx_L8_error:;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L1_error;
      __pyx_L26:;
    }

    /* "cassandra/connection.py":753
 *                     break
 * 
 *             time.sleep(0.001)             # <<<<<<<<<<<<<<
 * 
 *         self.send_msg(query, request_id, process_result)
 */
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_time); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_sleep); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __pyx_L7_break:;

  /* "cassandra/connection.py":755
 *             time.sleep(0.001)
 * 
 *         self.send_msg(query, request_id, process_result)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_n_s_send_msg); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = NULL;
  __pyx_t_7 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_7 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_4) {
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  }
  __Pyx_INCREF(__pyx_v_query);
  __Pyx_GIVEREF(__pyx_v_query);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_v_query);
  __Pyx_INCREF(__pyx_v_request_id);
  __Pyx_GIVEREF(__pyx_v_request_id);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_v_request_id);
  __Pyx_INCREF(__pyx_v_process_result);
  __Pyx_GIVEREF(__pyx_v_process_result);
  PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_7, __pyx_v_process_result);
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "cassandra/connection.py":717
 *             raise conn_exc
 * 
 *     def set_keyspace_async(self, keyspace, callback):             # <<<<<<<<<<<<<<
 *         """
 *         Use this in order to avoid deadlocking the event loop thread.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("cassandra.connection.Connection.set_keyspace_async", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_query);
  __Pyx_XDECREF(__pyx_v_process_result);
  __Pyx_XDECREF(__pyx_v_request_id);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":758
 * 
 *     @property
 *     def is_idle(self):             # <<<<<<<<<<<<<<
 *         return not self.msg_received
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_57is_idle(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_57is_idle = {"is_idle", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_57is_idle, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_57is_idle(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_idle (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_56is_idle(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_56is_idle(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_idle", 0);

  /* "cassandra/connection.py":759
 *     @property
 *     def is_idle(self):
 *         return not self.msg_received             # <<<<<<<<<<<<<<
 * 
 *     def reset_idle(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_msg_received); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "cassandra/connection.py":758
 * 
 *     @property
 *     def is_idle(self):             # <<<<<<<<<<<<<<
 *         return not self.msg_received
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cassandra.connection.Connection.is_idle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":761
 *         return not self.msg_received
 * 
 *     def reset_idle(self):             # <<<<<<<<<<<<<<
 *         self.msg_received = False
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_59reset_idle(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_59reset_idle = {"reset_idle", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_59reset_idle, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_59reset_idle(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reset_idle (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_58reset_idle(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_58reset_idle(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("reset_idle", 0);

  /* "cassandra/connection.py":762
 * 
 *     def reset_idle(self):
 *         self.msg_received = False             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_msg_received, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":761
 *         return not self.msg_received
 * 
 *     def reset_idle(self):             # <<<<<<<<<<<<<<
 *         self.msg_received = False
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cassandra.connection.Connection.reset_idle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":764
 *         self.msg_received = False
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         status = ""
 *         if self.is_defunct:
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_61__str__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_10Connection_61__str__ = {"__str__", (PyCFunction)__pyx_pw_9cassandra_10connection_10Connection_61__str__, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_10Connection_61__str__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_10Connection_60__str__(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_10Connection_60__str__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_status = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__str__", 0);

  /* "cassandra/connection.py":765
 * 
 *     def __str__(self):
 *         status = ""             # <<<<<<<<<<<<<<
 *         if self.is_defunct:
 *             status = " (defunct)"
 */
  __Pyx_INCREF(__pyx_kp_s__5);
  __pyx_v_status = __pyx_kp_s__5;

  /* "cassandra/connection.py":766
 *     def __str__(self):
 *         status = ""
 *         if self.is_defunct:             # <<<<<<<<<<<<<<
 *             status = " (defunct)"
 *         elif self.is_closed:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_is_defunct); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cassandra/connection.py":767
 *         status = ""
 *         if self.is_defunct:
 *             status = " (defunct)"             # <<<<<<<<<<<<<<
 *         elif self.is_closed:
 *             status = " (closed)"
 */
    __Pyx_INCREF(__pyx_kp_s_defunct_2);
    __Pyx_DECREF_SET(__pyx_v_status, __pyx_kp_s_defunct_2);
    goto __pyx_L3;
  }

  /* "cassandra/connection.py":768
 *         if self.is_defunct:
 *             status = " (defunct)"
 *         elif self.is_closed:             # <<<<<<<<<<<<<<
 *             status = " (closed)"
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_is_closed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cassandra/connection.py":769
 *             status = " (defunct)"
 *         elif self.is_closed:
 *             status = " (closed)"             # <<<<<<<<<<<<<<
 * 
 *         return "<%s(%r) %s:%d%s>" % (self.__class__.__name__, id(self), self.host, self.port, status)
 */
    __Pyx_INCREF(__pyx_kp_s_closed);
    __Pyx_DECREF_SET(__pyx_v_status, __pyx_kp_s_closed);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cassandra/connection.py":771
 *             status = " (closed)"
 * 
 *         return "<%s(%r) %s:%d%s>" % (self.__class__.__name__, id(self), self.host, self.port, status)             # <<<<<<<<<<<<<<
 *     __repr__ = __str__
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_class); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_host); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_port); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5);
  __Pyx_INCREF(__pyx_v_status);
  __Pyx_GIVEREF(__pyx_v_status);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_v_status);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_1 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_s_r_s_d_s, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "cassandra/connection.py":764
 *         self.msg_received = False
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         status = ""
 *         if self.is_defunct:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("cassandra.connection.Connection.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_status);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":777
 * class ResponseWaiter(object):
 * 
 *     def __init__(self, connection, num_responses, fail_on_error):             # <<<<<<<<<<<<<<
 *         self.connection = connection
 *         self.pending = num_responses
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_14ResponseWaiter_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_14ResponseWaiter_1__init__ = {"__init__", (PyCFunction)__pyx_pw_9cassandra_10connection_14ResponseWaiter_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_14ResponseWaiter_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_connection = 0;
  PyObject *__pyx_v_num_responses = 0;
  PyObject *__pyx_v_fail_on_error = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_connection,&__pyx_n_s_num_responses,&__pyx_n_s_fail_on_error,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_connection)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_num_responses)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fail_on_error)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_self = values[0];
    __pyx_v_connection = values[1];
    __pyx_v_num_responses = values[2];
    __pyx_v_fail_on_error = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.ResponseWaiter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_14ResponseWaiter___init__(__pyx_self, __pyx_v_self, __pyx_v_connection, __pyx_v_num_responses, __pyx_v_fail_on_error);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_14ResponseWaiter___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_connection, PyObject *__pyx_v_num_responses, PyObject *__pyx_v_fail_on_error) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cassandra/connection.py":778
 * 
 *     def __init__(self, connection, num_responses, fail_on_error):
 *         self.connection = connection             # <<<<<<<<<<<<<<
 *         self.pending = num_responses
 *         self.fail_on_error = fail_on_error
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_connection, __pyx_v_connection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":779
 *     def __init__(self, connection, num_responses, fail_on_error):
 *         self.connection = connection
 *         self.pending = num_responses             # <<<<<<<<<<<<<<
 *         self.fail_on_error = fail_on_error
 *         self.error = None
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pending, __pyx_v_num_responses) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":780
 *         self.connection = connection
 *         self.pending = num_responses
 *         self.fail_on_error = fail_on_error             # <<<<<<<<<<<<<<
 *         self.error = None
 *         self.responses = [None] * num_responses
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_fail_on_error, __pyx_v_fail_on_error) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":781
 *         self.pending = num_responses
 *         self.fail_on_error = fail_on_error
 *         self.error = None             # <<<<<<<<<<<<<<
 *         self.responses = [None] * num_responses
 *         self.event = Event()
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_error, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":782
 *         self.fail_on_error = fail_on_error
 *         self.error = None
 *         self.responses = [None] * num_responses             # <<<<<<<<<<<<<<
 *         self.event = Event()
 * 
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyList_SET_ITEM(__pyx_t_1, 0, Py_None);
  { PyObject* __pyx_temp = PyNumber_InPlaceMultiply(__pyx_t_1, __pyx_v_num_responses); if (unlikely(!__pyx_temp)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_temp);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_temp;
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_responses, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":783
 *         self.error = None
 *         self.responses = [None] * num_responses
 *         self.event = Event()             # <<<<<<<<<<<<<<
 * 
 *     def got_response(self, response, index):
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Event); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_event, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":777
 * class ResponseWaiter(object):
 * 
 *     def __init__(self, connection, num_responses, fail_on_error):             # <<<<<<<<<<<<<<
 *         self.connection = connection
 *         self.pending = num_responses
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cassandra.connection.ResponseWaiter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":785
 *         self.event = Event()
 * 
 *     def got_response(self, response, index):             # <<<<<<<<<<<<<<
 *         with self.connection.lock:
 *             self.connection.in_flight -= 1
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_14ResponseWaiter_3got_response(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_14ResponseWaiter_3got_response = {"got_response", (PyCFunction)__pyx_pw_9cassandra_10connection_14ResponseWaiter_3got_response, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_14ResponseWaiter_3got_response(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_response = 0;
  PyObject *__pyx_v_index = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("got_response (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_response,&__pyx_n_s_index,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_response)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("got_response", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_index)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("got_response", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "got_response") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_response = values[1];
    __pyx_v_index = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("got_response", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.ResponseWaiter.got_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_14ResponseWaiter_2got_response(__pyx_self, __pyx_v_self, __pyx_v_response, __pyx_v_index);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_14ResponseWaiter_2got_response(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_response, PyObject *__pyx_v_index) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("got_response", 0);
  __Pyx_INCREF(__pyx_v_response);

  /* "cassandra/connection.py":786
 * 
 *     def got_response(self, response, index):
 *         with self.connection.lock:             # <<<<<<<<<<<<<<
 *             self.connection.in_flight -= 1
 *         if isinstance(response, Exception):
 */
  /*with:*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_connection); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_lock); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_2, __pyx_n_s_exit); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_2, __pyx_n_s_enter); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    /*try:*/ {
      {
        __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_6);
        __Pyx_XGOTREF(__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_8);
        /*try:*/ {

          /* "cassandra/connection.py":787
 *     def got_response(self, response, index):
 *         with self.connection.lock:
 *             self.connection.in_flight -= 1             # <<<<<<<<<<<<<<
 *         if isinstance(response, Exception):
 *             if hasattr(response, 'to_exception'):
 */
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_connection); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_in_flight); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_4 = PyNumber_InPlaceSubtract(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_in_flight, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        }
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L14_try_end;
        __pyx_L7_error:;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "cassandra/connection.py":786
 * 
 *     def got_response(self, response, index):
 *         with self.connection.lock:             # <<<<<<<<<<<<<<
 *             self.connection.in_flight -= 1
 *         if isinstance(response, Exception):
 */
        /*except:*/ {
          __Pyx_AddTraceback("cassandra.connection.ResponseWaiter.got_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_4, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_5 = PyTuple_Pack(3, __pyx_t_2, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (__pyx_t_10 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __pyx_t_11 = ((!(__pyx_t_10 != 0)) != 0);
          if (__pyx_t_11) {
            __Pyx_GIVEREF(__pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_4);
            __Pyx_XGIVEREF(__pyx_t_1);
            __Pyx_ErrRestore(__pyx_t_2, __pyx_t_4, __pyx_t_1);
            __pyx_t_2 = 0; __pyx_t_4 = 0; __pyx_t_1 = 0; 
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          goto __pyx_L8_exception_handled;
        }
        __pyx_L9_except_error:;
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
        goto __pyx_L1_error;
        __pyx_L8_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
        __pyx_L14_try_end:;
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_3) {
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__27, NULL);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
        goto __pyx_L6;
      }
      __pyx_L6:;
    }
    goto __pyx_L18;
    __pyx_L3_error:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L1_error;
    __pyx_L18:;
  }

  /* "cassandra/connection.py":788
 *         with self.connection.lock:
 *             self.connection.in_flight -= 1
 *         if isinstance(response, Exception):             # <<<<<<<<<<<<<<
 *             if hasattr(response, 'to_exception'):
 *                 response = response.to_exception()
 */
  __pyx_t_11 = PyObject_IsInstance(__pyx_v_response, __pyx_builtin_Exception); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_10 = (__pyx_t_11 != 0);
  if (__pyx_t_10) {

    /* "cassandra/connection.py":789
 *             self.connection.in_flight -= 1
 *         if isinstance(response, Exception):
 *             if hasattr(response, 'to_exception'):             # <<<<<<<<<<<<<<
 *                 response = response.to_exception()
 *             if self.fail_on_error:
 */
    __pyx_t_10 = PyObject_HasAttr(__pyx_v_response, __pyx_n_s_to_exception); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = (__pyx_t_10 != 0);
    if (__pyx_t_11) {

      /* "cassandra/connection.py":790
 *         if isinstance(response, Exception):
 *             if hasattr(response, 'to_exception'):
 *                 response = response.to_exception()             # <<<<<<<<<<<<<<
 *             if self.fail_on_error:
 *                 self.error = response
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_response, __pyx_n_s_to_exception); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (__pyx_t_2) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_response, __pyx_t_1);
      __pyx_t_1 = 0;
      goto __pyx_L20;
    }
    __pyx_L20:;

    /* "cassandra/connection.py":791
 *             if hasattr(response, 'to_exception'):
 *                 response = response.to_exception()
 *             if self.fail_on_error:             # <<<<<<<<<<<<<<
 *                 self.error = response
 *                 self.event.set()
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fail_on_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_11) {

      /* "cassandra/connection.py":792
 *                 response = response.to_exception()
 *             if self.fail_on_error:
 *                 self.error = response             # <<<<<<<<<<<<<<
 *                 self.event.set()
 *             else:
 */
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_error, __pyx_v_response) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "cassandra/connection.py":793
 *             if self.fail_on_error:
 *                 self.error = response
 *                 self.event.set()             # <<<<<<<<<<<<<<
 *             else:
 *                 self.responses[index] = (False, response)
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_event); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_set); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      if (__pyx_t_4) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L21;
    }
    /*else*/ {

      /* "cassandra/connection.py":795
 *                 self.event.set()
 *             else:
 *                 self.responses[index] = (False, response)             # <<<<<<<<<<<<<<
 *         else:
 *             if not self.fail_on_error:
 */
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(Py_False);
      __Pyx_GIVEREF(Py_False);
      PyTuple_SET_ITEM(__pyx_t_1, 0, Py_False);
      __Pyx_INCREF(__pyx_v_response);
      __Pyx_GIVEREF(__pyx_v_response);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_response);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_responses); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (unlikely(PyObject_SetItem(__pyx_t_2, __pyx_v_index, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_L21:;
    goto __pyx_L19;
  }
  /*else*/ {

    /* "cassandra/connection.py":797
 *                 self.responses[index] = (False, response)
 *         else:
 *             if not self.fail_on_error:             # <<<<<<<<<<<<<<
 *                 self.responses[index] = (True, response)
 *             else:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fail_on_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_10 = ((!__pyx_t_11) != 0);
    if (__pyx_t_10) {

      /* "cassandra/connection.py":798
 *         else:
 *             if not self.fail_on_error:
 *                 self.responses[index] = (True, response)             # <<<<<<<<<<<<<<
 *             else:
 *                 self.responses[index] = response
 */
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(Py_True);
      __Pyx_GIVEREF(Py_True);
      PyTuple_SET_ITEM(__pyx_t_1, 0, Py_True);
      __Pyx_INCREF(__pyx_v_response);
      __Pyx_GIVEREF(__pyx_v_response);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_response);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_responses); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (unlikely(PyObject_SetItem(__pyx_t_2, __pyx_v_index, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L22;
    }
    /*else*/ {

      /* "cassandra/connection.py":800
 *                 self.responses[index] = (True, response)
 *             else:
 *                 self.responses[index] = response             # <<<<<<<<<<<<<<
 * 
 *         self.pending -= 1
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_responses); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_index, __pyx_v_response) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_L22:;
  }
  __pyx_L19:;

  /* "cassandra/connection.py":802
 *                 self.responses[index] = response
 * 
 *         self.pending -= 1             # <<<<<<<<<<<<<<
 *         if not self.pending:
 *             self.event.set()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pending); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_InPlaceSubtract(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pending, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":803
 * 
 *         self.pending -= 1
 *         if not self.pending:             # <<<<<<<<<<<<<<
 *             self.event.set()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pending); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_11 = ((!__pyx_t_10) != 0);
  if (__pyx_t_11) {

    /* "cassandra/connection.py":804
 *         self.pending -= 1
 *         if not self.pending:
 *             self.event.set()             # <<<<<<<<<<<<<<
 * 
 *     def deliver(self, timeout=None):
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_event); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_set); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_1) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L23;
  }
  __pyx_L23:;

  /* "cassandra/connection.py":785
 *         self.event = Event()
 * 
 *     def got_response(self, response, index):             # <<<<<<<<<<<<<<
 *         with self.connection.lock:
 *             self.connection.in_flight -= 1
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cassandra.connection.ResponseWaiter.got_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_response);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":806
 *             self.event.set()
 * 
 *     def deliver(self, timeout=None):             # <<<<<<<<<<<<<<
 *         """
 *         If fail_on_error was set to False, a list of (success, response)
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_14ResponseWaiter_5deliver(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9cassandra_10connection_14ResponseWaiter_4deliver[] = "\n        If fail_on_error was set to False, a list of (success, response)\n        tuples will be returned.  If success is False, response will be\n        an Exception.  Otherwise, response will be the normal query response.\n\n        If fail_on_error was left as True and one of the requests\n        failed, the corresponding Exception will be raised. Otherwise,\n        the normal response will be returned.\n        ";
static PyMethodDef __pyx_mdef_9cassandra_10connection_14ResponseWaiter_5deliver = {"deliver", (PyCFunction)__pyx_pw_9cassandra_10connection_14ResponseWaiter_5deliver, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9cassandra_10connection_14ResponseWaiter_4deliver};
static PyObject *__pyx_pw_9cassandra_10connection_14ResponseWaiter_5deliver(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_timeout = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("deliver (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_timeout,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)((PyObject *)Py_None));
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "deliver") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_timeout = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("deliver", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.ResponseWaiter.deliver", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_14ResponseWaiter_4deliver(__pyx_self, __pyx_v_self, __pyx_v_timeout);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_14ResponseWaiter_4deliver(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_timeout) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("deliver", 0);

  /* "cassandra/connection.py":816
 *         the normal response will be returned.
 *         """
 *         self.event.wait(timeout)             # <<<<<<<<<<<<<<
 *         if self.error:
 *             raise self.error
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_event); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_wait); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_timeout); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_timeout);
    __Pyx_GIVEREF(__pyx_v_timeout);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_timeout);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":817
 *         """
 *         self.event.wait(timeout)
 *         if self.error:             # <<<<<<<<<<<<<<
 *             raise self.error
 *         elif not self.event.is_set():
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "cassandra/connection.py":818
 *         self.event.wait(timeout)
 *         if self.error:
 *             raise self.error             # <<<<<<<<<<<<<<
 *         elif not self.event.is_set():
 *             raise OperationTimedOut()
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_error); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cassandra/connection.py":819
 *         if self.error:
 *             raise self.error
 *         elif not self.event.is_set():             # <<<<<<<<<<<<<<
 *             raise OperationTimedOut()
 *         else:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_event); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_is_set); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = ((!__pyx_t_5) != 0);
  if (__pyx_t_6) {

    /* "cassandra/connection.py":820
 *             raise self.error
 *         elif not self.event.is_set():
 *             raise OperationTimedOut()             # <<<<<<<<<<<<<<
 *         else:
 *             return self.responses
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_OperationTimedOut); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  /*else*/ {

    /* "cassandra/connection.py":822
 *             raise OperationTimedOut()
 *         else:
 *             return self.responses             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_responses); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "cassandra/connection.py":806
 *             self.event.set()
 * 
 *     def deliver(self, timeout=None):             # <<<<<<<<<<<<<<
 *         """
 *         If fail_on_error was set to False, a list of (success, response)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cassandra.connection.ResponseWaiter.deliver", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":826
 * 
 * class HeartbeatFuture(object):
 *     def __init__(self, connection, owner):             # <<<<<<<<<<<<<<
 *         self._exception = None
 *         self._event = Event()
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_15HeartbeatFuture_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_15HeartbeatFuture_1__init__ = {"__init__", (PyCFunction)__pyx_pw_9cassandra_10connection_15HeartbeatFuture_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_15HeartbeatFuture_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_connection = 0;
  PyObject *__pyx_v_owner = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_connection,&__pyx_n_s_owner,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_connection)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_owner)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_connection = values[1];
    __pyx_v_owner = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.HeartbeatFuture.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_15HeartbeatFuture___init__(__pyx_self, __pyx_v_self, __pyx_v_connection, __pyx_v_owner);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_15HeartbeatFuture___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_connection, PyObject *__pyx_v_owner) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cassandra/connection.py":827
 * class HeartbeatFuture(object):
 *     def __init__(self, connection, owner):
 *         self._exception = None             # <<<<<<<<<<<<<<
 *         self._event = Event()
 *         self.connection = connection
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_exception_2, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":828
 *     def __init__(self, connection, owner):
 *         self._exception = None
 *         self._event = Event()             # <<<<<<<<<<<<<<
 *         self.connection = connection
 *         self.owner = owner
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Event); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_event_2, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":829
 *         self._exception = None
 *         self._event = Event()
 *         self.connection = connection             # <<<<<<<<<<<<<<
 *         self.owner = owner
 *         log.debug("Sending options message heartbeat on idle connection (%s) %s",
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_connection, __pyx_v_connection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":830
 *         self._event = Event()
 *         self.connection = connection
 *         self.owner = owner             # <<<<<<<<<<<<<<
 *         log.debug("Sending options message heartbeat on idle connection (%s) %s",
 *                   id(connection), connection.host)
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_owner, __pyx_v_owner) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":831
 *         self.connection = connection
 *         self.owner = owner
 *         log.debug("Sending options message heartbeat on idle connection (%s) %s",             # <<<<<<<<<<<<<<
 *                   id(connection), connection.host)
 *         with connection.lock:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":832
 *         self.owner = owner
 *         log.debug("Sending options message heartbeat on idle connection (%s) %s",
 *                   id(connection), connection.host)             # <<<<<<<<<<<<<<
 *         with connection.lock:
 *             if connection.in_flight < connection.max_request_id:
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_connection);
  __Pyx_GIVEREF(__pyx_v_connection);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_connection);
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_connection, __pyx_n_s_host); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_6 = 1;
    }
  }
  __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (__pyx_t_5) {
    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
  }
  __Pyx_INCREF(__pyx_kp_s_Sending_options_message_heartbea);
  __Pyx_GIVEREF(__pyx_kp_s_Sending_options_message_heartbea);
  PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_kp_s_Sending_options_message_heartbea);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":833
 *         log.debug("Sending options message heartbeat on idle connection (%s) %s",
 *                   id(connection), connection.host)
 *         with connection.lock:             # <<<<<<<<<<<<<<
 *             if connection.in_flight < connection.max_request_id:
 *                 connection.in_flight += 1
 */
  /*with:*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_connection, __pyx_n_s_lock); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_2 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (__pyx_t_2) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    /*try:*/ {
      {
        __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
        __Pyx_XGOTREF(__pyx_t_9);
        __Pyx_XGOTREF(__pyx_t_10);
        __Pyx_XGOTREF(__pyx_t_11);
        /*try:*/ {

          /* "cassandra/connection.py":834
 *                   id(connection), connection.host)
 *         with connection.lock:
 *             if connection.in_flight < connection.max_request_id:             # <<<<<<<<<<<<<<
 *                 connection.in_flight += 1
 *                 connection.send_msg(OptionsMessage(), connection.get_request_id(), self._options_callback)
 */
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_connection, __pyx_n_s_in_flight); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_connection, __pyx_n_s_max_request_id); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (__pyx_t_12) {

            /* "cassandra/connection.py":835
 *         with connection.lock:
 *             if connection.in_flight < connection.max_request_id:
 *                 connection.in_flight += 1             # <<<<<<<<<<<<<<
 *                 connection.send_msg(OptionsMessage(), connection.get_request_id(), self._options_callback)
 *             else:
 */
            __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_connection, __pyx_n_s_in_flight); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (__Pyx_PyObject_SetAttrStr(__pyx_v_connection, __pyx_n_s_in_flight, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "cassandra/connection.py":836
 *             if connection.in_flight < connection.max_request_id:
 *                 connection.in_flight += 1
 *                 connection.send_msg(OptionsMessage(), connection.get_request_id(), self._options_callback)             # <<<<<<<<<<<<<<
 *             else:
 *                 self._exception = Exception("Failed to send heartbeat because connection 'in_flight' exceeds threshold")
 */
            __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_connection, __pyx_n_s_send_msg); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_OptionsMessage); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_4 = NULL;
            if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
              if (likely(__pyx_t_4)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_2, function);
              }
            }
            if (__pyx_t_4) {
              __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            } else {
              __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            }
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_connection, __pyx_n_s_get_request_id); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_5 = NULL;
            if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
              __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
              if (likely(__pyx_t_5)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
                __Pyx_INCREF(__pyx_t_5);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_4, function);
              }
            }
            if (__pyx_t_5) {
              __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            } else {
              __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            }
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_options_callback); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_5 = NULL;
            __pyx_t_6 = 0;
            if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
              __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
              if (likely(__pyx_t_5)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
                __Pyx_INCREF(__pyx_t_5);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_7, function);
                __pyx_t_6 = 1;
              }
            }
            __pyx_t_13 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_13);
            if (__pyx_t_5) {
              __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_5); __pyx_t_5 = NULL;
            }
            __Pyx_GIVEREF(__pyx_t_1);
            PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_6, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_2);
            PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_6, __pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_4);
            PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_6, __pyx_t_4);
            __pyx_t_1 = 0;
            __pyx_t_2 = 0;
            __pyx_t_4 = 0;
            __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_13, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            goto __pyx_L15;
          }
          /*else*/ {

            /* "cassandra/connection.py":838
 *                 connection.send_msg(OptionsMessage(), connection.get_request_id(), self._options_callback)
 *             else:
 *                 self._exception = Exception("Failed to send heartbeat because connection 'in_flight' exceeds threshold")             # <<<<<<<<<<<<<<
 *                 self._event.set()
 * 
 */
            __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_Exception, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_3);
            if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_exception_2, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "cassandra/connection.py":839
 *             else:
 *                 self._exception = Exception("Failed to send heartbeat because connection 'in_flight' exceeds threshold")
 *                 self._event.set()             # <<<<<<<<<<<<<<
 * 
 *     def wait(self, timeout):
 */
            __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_event_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_set); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __pyx_t_7 = NULL;
            if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_13))) {
              __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_13);
              if (likely(__pyx_t_7)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
                __Pyx_INCREF(__pyx_t_7);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_13, function);
              }
            }
            if (__pyx_t_7) {
              __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            } else {
              __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
            }
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          }
          __pyx_L15:;
        }
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L14_try_end;
        __pyx_L7_error:;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "cassandra/connection.py":833
 *         log.debug("Sending options message heartbeat on idle connection (%s) %s",
 *                   id(connection), connection.host)
 *         with connection.lock:             # <<<<<<<<<<<<<<
 *             if connection.in_flight < connection.max_request_id:
 *                 connection.in_flight += 1
 */
        /*except:*/ {
          __Pyx_AddTraceback("cassandra.connection.HeartbeatFuture.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_13, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_4 = PyTuple_Pack(3, __pyx_t_3, __pyx_t_13, __pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_4, NULL);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          if (__pyx_t_12 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __pyx_t_15 = ((!(__pyx_t_12 != 0)) != 0);
          if (__pyx_t_15) {
            __Pyx_GIVEREF(__pyx_t_3);
            __Pyx_GIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_7);
            __Pyx_ErrRestore(__pyx_t_3, __pyx_t_13, __pyx_t_7);
            __pyx_t_3 = 0; __pyx_t_13 = 0; __pyx_t_7 = 0; 
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          }
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          goto __pyx_L8_exception_handled;
        }
        __pyx_L9_except_error:;
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
        goto __pyx_L1_error;
        __pyx_L8_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
        __pyx_L14_try_end:;
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_8) {
          __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__29, NULL);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
        goto __pyx_L6;
      }
      __pyx_L6:;
    }
    goto __pyx_L19;
    __pyx_L3_error:;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    goto __pyx_L1_error;
    __pyx_L19:;
  }

  /* "cassandra/connection.py":826
 * 
 * class HeartbeatFuture(object):
 *     def __init__(self, connection, owner):             # <<<<<<<<<<<<<<
 *         self._exception = None
 *         self._event = Event()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("cassandra.connection.HeartbeatFuture.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":841
 *                 self._event.set()
 * 
 *     def wait(self, timeout):             # <<<<<<<<<<<<<<
 *         self._event.wait(timeout)
 *         if self._event.is_set():
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_15HeartbeatFuture_3wait(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_15HeartbeatFuture_3wait = {"wait", (PyCFunction)__pyx_pw_9cassandra_10connection_15HeartbeatFuture_3wait, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_15HeartbeatFuture_3wait(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_timeout = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("wait (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_timeout,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("wait", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wait") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_timeout = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("wait", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.HeartbeatFuture.wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_15HeartbeatFuture_2wait(__pyx_self, __pyx_v_self, __pyx_v_timeout);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_15HeartbeatFuture_2wait(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_timeout) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("wait", 0);

  /* "cassandra/connection.py":842
 * 
 *     def wait(self, timeout):
 *         self._event.wait(timeout)             # <<<<<<<<<<<<<<
 *         if self._event.is_set():
 *             if self._exception:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_event_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_wait); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_timeout); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
    __Pyx_INCREF(__pyx_v_timeout);
    __Pyx_GIVEREF(__pyx_v_timeout);
    PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_timeout);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":843
 *     def wait(self, timeout):
 *         self._event.wait(timeout)
 *         if self._event.is_set():             # <<<<<<<<<<<<<<
 *             if self._exception:
 *                 raise self._exception
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_event_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_is_set); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "cassandra/connection.py":844
 *         self._event.wait(timeout)
 *         if self._event.is_set():
 *             if self._exception:             # <<<<<<<<<<<<<<
 *                 raise self._exception
 *         else:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_exception_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_5) {

      /* "cassandra/connection.py":845
 *         if self._event.is_set():
 *             if self._exception:
 *                 raise self._exception             # <<<<<<<<<<<<<<
 *         else:
 *             raise OperationTimedOut()
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_exception_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    goto __pyx_L3;
  }
  /*else*/ {

    /* "cassandra/connection.py":847
 *                 raise self._exception
 *         else:
 *             raise OperationTimedOut()             # <<<<<<<<<<<<<<
 * 
 *     def _options_callback(self, response):
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_OperationTimedOut); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  /* "cassandra/connection.py":841
 *                 self._event.set()
 * 
 *     def wait(self, timeout):             # <<<<<<<<<<<<<<
 *         self._event.wait(timeout)
 *         if self._event.is_set():
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cassandra.connection.HeartbeatFuture.wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":849
 *             raise OperationTimedOut()
 * 
 *     def _options_callback(self, response):             # <<<<<<<<<<<<<<
 *         if not isinstance(response, SupportedMessage):
 *             if isinstance(response, ConnectionException):
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_15HeartbeatFuture_5_options_callback(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_15HeartbeatFuture_5_options_callback = {"_options_callback", (PyCFunction)__pyx_pw_9cassandra_10connection_15HeartbeatFuture_5_options_callback, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_15HeartbeatFuture_5_options_callback(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_response = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_options_callback (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_response,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_response)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_options_callback", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_options_callback") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_response = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_options_callback", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.HeartbeatFuture._options_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_15HeartbeatFuture_4_options_callback(__pyx_self, __pyx_v_self, __pyx_v_response);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_15HeartbeatFuture_4_options_callback(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_response) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_options_callback", 0);

  /* "cassandra/connection.py":850
 * 
 *     def _options_callback(self, response):
 *         if not isinstance(response, SupportedMessage):             # <<<<<<<<<<<<<<
 *             if isinstance(response, ConnectionException):
 *                 self._exception = response
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_SupportedMessage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_response, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((!(__pyx_t_2 != 0)) != 0);
  if (__pyx_t_3) {

    /* "cassandra/connection.py":851
 *     def _options_callback(self, response):
 *         if not isinstance(response, SupportedMessage):
 *             if isinstance(response, ConnectionException):             # <<<<<<<<<<<<<<
 *                 self._exception = response
 *             else:
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConnectionException); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_IsInstance(__pyx_v_response, __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_2 = (__pyx_t_3 != 0);
    if (__pyx_t_2) {

      /* "cassandra/connection.py":852
 *         if not isinstance(response, SupportedMessage):
 *             if isinstance(response, ConnectionException):
 *                 self._exception = response             # <<<<<<<<<<<<<<
 *             else:
 *                 self._exception = ConnectionException("Received unexpected response to OptionsMessage: %s"
 */
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_exception_2, __pyx_v_response) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L4;
    }
    /*else*/ {

      /* "cassandra/connection.py":854
 *                 self._exception = response
 *             else:
 *                 self._exception = ConnectionException("Received unexpected response to OptionsMessage: %s"             # <<<<<<<<<<<<<<
 *                                                       % (response,))
 * 
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConnectionException); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);

      /* "cassandra/connection.py":855
 *             else:
 *                 self._exception = ConnectionException("Received unexpected response to OptionsMessage: %s"
 *                                                       % (response,))             # <<<<<<<<<<<<<<
 * 
 *         log.debug("Received options response on connection (%s) from %s",
 */
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_response);
      __Pyx_GIVEREF(__pyx_v_response);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_response);
      __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_Received_unexpected_response_to, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "cassandra/connection.py":854
 *                 self._exception = response
 *             else:
 *                 self._exception = ConnectionException("Received unexpected response to OptionsMessage: %s"             # <<<<<<<<<<<<<<
 *                                                       % (response,))
 * 
 */
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_exception_2, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cassandra/connection.py":857
 *                                                       % (response,))
 * 
 *         log.debug("Received options response on connection (%s) from %s",             # <<<<<<<<<<<<<<
 *                   id(self.connection), self.connection.host)
 *         self._event.set()
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_debug); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cassandra/connection.py":858
 * 
 *         log.debug("Received options response on connection (%s) from %s",
 *                   id(self.connection), self.connection.host)             # <<<<<<<<<<<<<<
 *         self._event.set()
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_connection); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_connection); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_host); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
      __pyx_t_8 = 1;
    }
  }
  __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  if (__pyx_t_6) {
    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
  }
  __Pyx_INCREF(__pyx_kp_s_Received_options_response_on_con);
  __Pyx_GIVEREF(__pyx_kp_s_Received_options_response_on_con);
  PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_kp_s_Received_options_response_on_con);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_5);
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":859
 *         log.debug("Received options response on connection (%s) from %s",
 *                   id(self.connection), self.connection.host)
 *         self._event.set()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_event_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_set); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  if (__pyx_t_7) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":849
 *             raise OperationTimedOut()
 * 
 *     def _options_callback(self, response):             # <<<<<<<<<<<<<<
 *         if not isinstance(response, SupportedMessage):
 *             if isinstance(response, ConnectionException):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("cassandra.connection.HeartbeatFuture._options_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":864
 * class ConnectionHeartbeat(Thread):
 * 
 *     def __init__(self, interval_sec, get_connection_holders):             # <<<<<<<<<<<<<<
 *         Thread.__init__(self, name="Connection heartbeat")
 *         self._interval = interval_sec
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_19ConnectionHeartbeat_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_19ConnectionHeartbeat_1__init__ = {"__init__", (PyCFunction)__pyx_pw_9cassandra_10connection_19ConnectionHeartbeat_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_19ConnectionHeartbeat_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_interval_sec = 0;
  PyObject *__pyx_v_get_connection_holders = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_interval_sec,&__pyx_n_s_get_connection_holders,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_interval_sec)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_get_connection_holders)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_interval_sec = values[1];
    __pyx_v_get_connection_holders = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.ConnectionHeartbeat.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_19ConnectionHeartbeat___init__(__pyx_self, __pyx_v_self, __pyx_v_interval_sec, __pyx_v_get_connection_holders);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_19ConnectionHeartbeat___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_interval_sec, PyObject *__pyx_v_get_connection_holders) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cassandra/connection.py":865
 * 
 *     def __init__(self, interval_sec, get_connection_holders):
 *         Thread.__init__(self, name="Connection heartbeat")             # <<<<<<<<<<<<<<
 *         self._interval = interval_sec
 *         self._get_connection_holders = get_connection_holders
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Thread); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_name_2, __pyx_kp_s_Connection_heartbeat) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cassandra/connection.py":866
 *     def __init__(self, interval_sec, get_connection_holders):
 *         Thread.__init__(self, name="Connection heartbeat")
 *         self._interval = interval_sec             # <<<<<<<<<<<<<<
 *         self._get_connection_holders = get_connection_holders
 *         self._shutdown_event = Event()
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_interval, __pyx_v_interval_sec) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":867
 *         Thread.__init__(self, name="Connection heartbeat")
 *         self._interval = interval_sec
 *         self._get_connection_holders = get_connection_holders             # <<<<<<<<<<<<<<
 *         self._shutdown_event = Event()
 *         self.daemon = True
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_get_connection_holders_2, __pyx_v_get_connection_holders) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":868
 *         self._interval = interval_sec
 *         self._get_connection_holders = get_connection_holders
 *         self._shutdown_event = Event()             # <<<<<<<<<<<<<<
 *         self.daemon = True
 *         self.start()
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Event); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_1) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_shutdown_event, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cassandra/connection.py":869
 *         self._get_connection_holders = get_connection_holders
 *         self._shutdown_event = Event()
 *         self.daemon = True             # <<<<<<<<<<<<<<
 *         self.start()
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_daemon, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":870
 *         self._shutdown_event = Event()
 *         self.daemon = True
 *         self.start()             # <<<<<<<<<<<<<<
 * 
 *     class ShutdownException(Exception):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_start); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_1) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "cassandra/connection.py":864
 * class ConnectionHeartbeat(Thread):
 * 
 *     def __init__(self, interval_sec, get_connection_holders):             # <<<<<<<<<<<<<<
 *         Thread.__init__(self, name="Connection heartbeat")
 *         self._interval = interval_sec
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cassandra.connection.ConnectionHeartbeat.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":875
 *         pass
 * 
 *     def run(self):             # <<<<<<<<<<<<<<
 *         self._shutdown_event.wait(self._interval)
 *         while not self._shutdown_event.is_set():
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_19ConnectionHeartbeat_3run(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_19ConnectionHeartbeat_3run = {"run", (PyCFunction)__pyx_pw_9cassandra_10connection_19ConnectionHeartbeat_3run, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_19ConnectionHeartbeat_3run(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("run (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_19ConnectionHeartbeat_2run(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_19ConnectionHeartbeat_2run(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_start_time = NULL;
  PyObject *__pyx_v_futures = NULL;
  PyObject *__pyx_v_failed_connections = NULL;
  PyObject *__pyx_v_connections = NULL;
  PyObject *__pyx_v_owner = NULL;
  PyObject *__pyx_v_connection = NULL;
  PyObject *__pyx_v_f = NULL;
  PyObject *__pyx_v_elapsed = NULL;
  PyObject *__pyx_v_o = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  Py_ssize_t __pyx_t_11;
  PyObject *(*__pyx_t_12)(PyObject *);
  PyObject *(*__pyx_t_13)(PyObject *);
  Py_ssize_t __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  Py_ssize_t __pyx_t_18;
  PyObject *__pyx_t_19 = NULL;
  int __pyx_t_20;
  int __pyx_t_21;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  PyObject *__pyx_t_27 = NULL;
  PyObject *__pyx_t_28 = NULL;
  PyObject *__pyx_t_29 = NULL;
  double __pyx_t_30;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("run", 0);

  /* "cassandra/connection.py":876
 * 
 *     def run(self):
 *         self._shutdown_event.wait(self._interval)             # <<<<<<<<<<<<<<
 *         while not self._shutdown_event.is_set():
 *             start_time = time.time()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_shutdown_event); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_wait); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_interval); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":877
 *     def run(self):
 *         self._shutdown_event.wait(self._interval)
 *         while not self._shutdown_event.is_set():             # <<<<<<<<<<<<<<
 *             start_time = time.time()
 * 
 */
  while (1) {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_shutdown_event); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_is_set); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = ((!__pyx_t_6) != 0);
    if (!__pyx_t_7) break;

    /* "cassandra/connection.py":878
 *         self._shutdown_event.wait(self._interval)
 *         while not self._shutdown_event.is_set():
 *             start_time = time.time()             # <<<<<<<<<<<<<<
 * 
 *             futures = []
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_time); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_time); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_5) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_start_time, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "cassandra/connection.py":880
 *             start_time = time.time()
 * 
 *             futures = []             # <<<<<<<<<<<<<<
 *             failed_connections = []
 *             try:
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_futures, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cassandra/connection.py":881
 * 
 *             futures = []
 *             failed_connections = []             # <<<<<<<<<<<<<<
 *             try:
 *                 for connections, owner in [(o.get_connections(), o) for o in self._get_connection_holders()]:
 */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_failed_connections, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "cassandra/connection.py":882
 *             futures = []
 *             failed_connections = []
 *             try:             # <<<<<<<<<<<<<<
 *                 for connections, owner in [(o.get_connections(), o) for o in self._get_connection_holders()]:
 *                     for connection in connections:
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      /*try:*/ {

        /* "cassandra/connection.py":883
 *             failed_connections = []
 *             try:
 *                 for connections, owner in [(o.get_connections(), o) for o in self._get_connection_holders()]:             # <<<<<<<<<<<<<<
 *                     for connection in connections:
 *                         self._raise_if_stopped()
 */
        __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_get_connection_holders_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = NULL;
        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_2)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_2);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        if (__pyx_t_2) {
          __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        } else {
          __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        }
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
          __pyx_t_5 = __pyx_t_3; __Pyx_INCREF(__pyx_t_5); __pyx_t_11 = 0;
          __pyx_t_12 = NULL;
        } else {
          __pyx_t_11 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_12 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        for (;;) {
          if (likely(!__pyx_t_12)) {
            if (likely(PyList_CheckExact(__pyx_t_5))) {
              if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_5)) break;
              #if CYTHON_COMPILING_IN_CPYTHON
              __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_11); __Pyx_INCREF(__pyx_t_3); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
              #else
              __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
              __Pyx_GOTREF(__pyx_t_3);
              #endif
            } else {
              if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
              #if CYTHON_COMPILING_IN_CPYTHON
              __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_11); __Pyx_INCREF(__pyx_t_3); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
              #else
              __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
              __Pyx_GOTREF(__pyx_t_3);
              #endif
            }
          } else {
            __pyx_t_3 = __pyx_t_12(__pyx_t_5);
            if (unlikely(!__pyx_t_3)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_3);
          }
          __Pyx_XDECREF_SET(__pyx_v_o, __pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_o, __pyx_n_s_get_connections); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = NULL;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_4)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_4);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
            }
          }
          if (__pyx_t_4) {
            __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          } else {
            __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          }
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_o);
          __Pyx_GIVEREF(__pyx_v_o);
          PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_o);
          __pyx_t_3 = 0;
          if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = __pyx_t_1; __Pyx_INCREF(__pyx_t_5); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        for (;;) {
          if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_11); __Pyx_INCREF(__pyx_t_1); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_1);
          #endif
          if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
            PyObject* sequence = __pyx_t_1;
            #if CYTHON_COMPILING_IN_CPYTHON
            Py_ssize_t size = Py_SIZE(sequence);
            #else
            Py_ssize_t size = PySequence_Size(sequence);
            #endif
            if (unlikely(size != 2)) {
              if (size > 2) __Pyx_RaiseTooManyValuesError(2);
              else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            }
            #if CYTHON_COMPILING_IN_CPYTHON
            if (likely(PyTuple_CheckExact(sequence))) {
              __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
              __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
            } else {
              __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
              __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
            }
            __Pyx_INCREF(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_3);
            #else
            __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_GOTREF(__pyx_t_3);
            #endif
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          } else {
            Py_ssize_t index = -1;
            __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_13 = Py_TYPE(__pyx_t_4)->tp_iternext;
            index = 0; __pyx_t_2 = __pyx_t_13(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L17_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_2);
            index = 1; __pyx_t_3 = __pyx_t_13(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L17_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_3);
            if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __pyx_t_13 = NULL;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            goto __pyx_L18_unpacking_done;
            __pyx_L17_unpacking_failed:;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_13 = NULL;
            if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __pyx_L18_unpacking_done:;
          }
          __Pyx_XDECREF_SET(__pyx_v_connections, __pyx_t_2);
          __pyx_t_2 = 0;
          __Pyx_XDECREF_SET(__pyx_v_owner, __pyx_t_3);
          __pyx_t_3 = 0;

          /* "cassandra/connection.py":884
 *             try:
 *                 for connections, owner in [(o.get_connections(), o) for o in self._get_connection_holders()]:
 *                     for connection in connections:             # <<<<<<<<<<<<<<
 *                         self._raise_if_stopped()
 *                         if not (connection.is_defunct or connection.is_closed):
 */
          if (likely(PyList_CheckExact(__pyx_v_connections)) || PyTuple_CheckExact(__pyx_v_connections)) {
            __pyx_t_1 = __pyx_v_connections; __Pyx_INCREF(__pyx_t_1); __pyx_t_14 = 0;
            __pyx_t_12 = NULL;
          } else {
            __pyx_t_14 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_connections); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_12 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          }
          for (;;) {
            if (likely(!__pyx_t_12)) {
              if (likely(PyList_CheckExact(__pyx_t_1))) {
                if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_1)) break;
                #if CYTHON_COMPILING_IN_CPYTHON
                __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_14); __Pyx_INCREF(__pyx_t_3); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
                #else
                __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
                __Pyx_GOTREF(__pyx_t_3);
                #endif
              } else {
                if (__pyx_t_14 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
                #if CYTHON_COMPILING_IN_CPYTHON
                __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_14); __Pyx_INCREF(__pyx_t_3); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
                #else
                __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
                __Pyx_GOTREF(__pyx_t_3);
                #endif
              }
            } else {
              __pyx_t_3 = __pyx_t_12(__pyx_t_1);
              if (unlikely(!__pyx_t_3)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                  else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
                }
                break;
              }
              __Pyx_GOTREF(__pyx_t_3);
            }
            __Pyx_XDECREF_SET(__pyx_v_connection, __pyx_t_3);
            __pyx_t_3 = 0;

            /* "cassandra/connection.py":885
 *                 for connections, owner in [(o.get_connections(), o) for o in self._get_connection_holders()]:
 *                     for connection in connections:
 *                         self._raise_if_stopped()             # <<<<<<<<<<<<<<
 *                         if not (connection.is_defunct or connection.is_closed):
 *                             if connection.is_idle:
 */
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_raise_if_stopped); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_4 = NULL;
            if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
              if (likely(__pyx_t_4)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_2, function);
              }
            }
            if (__pyx_t_4) {
              __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            } else {
              __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            }
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "cassandra/connection.py":886
 *                     for connection in connections:
 *                         self._raise_if_stopped()
 *                         if not (connection.is_defunct or connection.is_closed):             # <<<<<<<<<<<<<<
 *                             if connection.is_idle:
 *                                 try:
 */
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_connection, __pyx_n_s_is_defunct); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (!__pyx_t_6) {
            } else {
              __pyx_t_7 = __pyx_t_6;
              goto __pyx_L22_bool_binop_done;
            }
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_connection, __pyx_n_s_is_closed); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_7 = __pyx_t_6;
            __pyx_L22_bool_binop_done:;
            __pyx_t_6 = ((!__pyx_t_7) != 0);
            if (__pyx_t_6) {

              /* "cassandra/connection.py":887
 *                         self._raise_if_stopped()
 *                         if not (connection.is_defunct or connection.is_closed):
 *                             if connection.is_idle:             # <<<<<<<<<<<<<<
 *                                 try:
 *                                     futures.append(HeartbeatFuture(connection, owner))
 */
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_connection, __pyx_n_s_is_idle); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (__pyx_t_6) {

                /* "cassandra/connection.py":888
 *                         if not (connection.is_defunct or connection.is_closed):
 *                             if connection.is_idle:
 *                                 try:             # <<<<<<<<<<<<<<
 *                                     futures.append(HeartbeatFuture(connection, owner))
 *                                 except Exception:
 */
                {
                  __Pyx_ExceptionSave(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
                  __Pyx_XGOTREF(__pyx_t_15);
                  __Pyx_XGOTREF(__pyx_t_16);
                  __Pyx_XGOTREF(__pyx_t_17);
                  /*try:*/ {

                    /* "cassandra/connection.py":889
 *                             if connection.is_idle:
 *                                 try:
 *                                     futures.append(HeartbeatFuture(connection, owner))             # <<<<<<<<<<<<<<
 *                                 except Exception:
 *                                     log.warning("Failed sending heartbeat message on connection (%s) to %s",
 */
                    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_HeartbeatFuture); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
                    __Pyx_GOTREF(__pyx_t_2);
                    __pyx_t_4 = NULL;
                    __pyx_t_18 = 0;
                    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
                      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
                      if (likely(__pyx_t_4)) {
                        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
                        __Pyx_INCREF(__pyx_t_4);
                        __Pyx_INCREF(function);
                        __Pyx_DECREF_SET(__pyx_t_2, function);
                        __pyx_t_18 = 1;
                      }
                    }
                    __pyx_t_19 = PyTuple_New(2+__pyx_t_18); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
                    __Pyx_GOTREF(__pyx_t_19);
                    if (__pyx_t_4) {
                      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_4); __pyx_t_4 = NULL;
                    }
                    __Pyx_INCREF(__pyx_v_connection);
                    __Pyx_GIVEREF(__pyx_v_connection);
                    PyTuple_SET_ITEM(__pyx_t_19, 0+__pyx_t_18, __pyx_v_connection);
                    __Pyx_INCREF(__pyx_v_owner);
                    __Pyx_GIVEREF(__pyx_v_owner);
                    PyTuple_SET_ITEM(__pyx_t_19, 1+__pyx_t_18, __pyx_v_owner);
                    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_19, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
                    __Pyx_GOTREF(__pyx_t_3);
                    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_futures, __pyx_t_3); if (unlikely(__pyx_t_20 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L25_error;}
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  }
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                  __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                  goto __pyx_L32_try_end;
                  __pyx_L25_error:;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

                  /* "cassandra/connection.py":890
 *                                 try:
 *                                     futures.append(HeartbeatFuture(connection, owner))
 *                                 except Exception:             # <<<<<<<<<<<<<<
 *                                     log.warning("Failed sending heartbeat message on connection (%s) to %s",
 *                                                 id(connection), connection.host, exc_info=True)
 */
                  __pyx_t_21 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
                  if (__pyx_t_21) {
                    __Pyx_AddTraceback("cassandra.connection.ConnectionHeartbeat.run", __pyx_clineno, __pyx_lineno, __pyx_filename);
                    if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_19) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
                    __Pyx_GOTREF(__pyx_t_3);
                    __Pyx_GOTREF(__pyx_t_2);
                    __Pyx_GOTREF(__pyx_t_19);

                    /* "cassandra/connection.py":891
 *                                     futures.append(HeartbeatFuture(connection, owner))
 *                                 except Exception:
 *                                     log.warning("Failed sending heartbeat message on connection (%s) to %s",             # <<<<<<<<<<<<<<
 *                                                 id(connection), connection.host, exc_info=True)
 *                                     failed_connections.append((connection, owner))
 */
                    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
                    __Pyx_GOTREF(__pyx_t_4);
                    __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_warning); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
                    __Pyx_GOTREF(__pyx_t_22);
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                    /* "cassandra/connection.py":892
 *                                 except Exception:
 *                                     log.warning("Failed sending heartbeat message on connection (%s) to %s",
 *                                                 id(connection), connection.host, exc_info=True)             # <<<<<<<<<<<<<<
 *                                     failed_connections.append((connection, owner))
 *                             else:
 */
                    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
                    __Pyx_GOTREF(__pyx_t_4);
                    __Pyx_INCREF(__pyx_v_connection);
                    __Pyx_GIVEREF(__pyx_v_connection);
                    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_connection);
                    __pyx_t_23 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_4, NULL); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
                    __Pyx_GOTREF(__pyx_t_23);
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_connection, __pyx_n_s_host); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
                    __Pyx_GOTREF(__pyx_t_4);

                    /* "cassandra/connection.py":891
 *                                     futures.append(HeartbeatFuture(connection, owner))
 *                                 except Exception:
 *                                     log.warning("Failed sending heartbeat message on connection (%s) to %s",             # <<<<<<<<<<<<<<
 *                                                 id(connection), connection.host, exc_info=True)
 *                                     failed_connections.append((connection, owner))
 */
                    __pyx_t_24 = PyTuple_New(3); if (unlikely(!__pyx_t_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
                    __Pyx_GOTREF(__pyx_t_24);
                    __Pyx_INCREF(__pyx_kp_s_Failed_sending_heartbeat_message);
                    __Pyx_GIVEREF(__pyx_kp_s_Failed_sending_heartbeat_message);
                    PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_kp_s_Failed_sending_heartbeat_message);
                    __Pyx_GIVEREF(__pyx_t_23);
                    PyTuple_SET_ITEM(__pyx_t_24, 1, __pyx_t_23);
                    __Pyx_GIVEREF(__pyx_t_4);
                    PyTuple_SET_ITEM(__pyx_t_24, 2, __pyx_t_4);
                    __pyx_t_23 = 0;
                    __pyx_t_4 = 0;
                    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
                    __Pyx_GOTREF(__pyx_t_4);

                    /* "cassandra/connection.py":892
 *                                 except Exception:
 *                                     log.warning("Failed sending heartbeat message on connection (%s) to %s",
 *                                                 id(connection), connection.host, exc_info=True)             # <<<<<<<<<<<<<<
 *                                     failed_connections.append((connection, owner))
 *                             else:
 */
                    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_exc_info, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}

                    /* "cassandra/connection.py":891
 *                                     futures.append(HeartbeatFuture(connection, owner))
 *                                 except Exception:
 *                                     log.warning("Failed sending heartbeat message on connection (%s) to %s",             # <<<<<<<<<<<<<<
 *                                                 id(connection), connection.host, exc_info=True)
 *                                     failed_connections.append((connection, owner))
 */
                    __pyx_t_23 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_t_24, __pyx_t_4); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
                    __Pyx_GOTREF(__pyx_t_23);
                    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

                    /* "cassandra/connection.py":893
 *                                     log.warning("Failed sending heartbeat message on connection (%s) to %s",
 *                                                 id(connection), connection.host, exc_info=True)
 *                                     failed_connections.append((connection, owner))             # <<<<<<<<<<<<<<
 *                             else:
 *                                 connection.reset_idle()
 */
                    __pyx_t_23 = PyTuple_New(2); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
                    __Pyx_GOTREF(__pyx_t_23);
                    __Pyx_INCREF(__pyx_v_connection);
                    __Pyx_GIVEREF(__pyx_v_connection);
                    PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_v_connection);
                    __Pyx_INCREF(__pyx_v_owner);
                    __Pyx_GIVEREF(__pyx_v_owner);
                    PyTuple_SET_ITEM(__pyx_t_23, 1, __pyx_v_owner);
                    __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_failed_connections, __pyx_t_23); if (unlikely(__pyx_t_20 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L27_except_error;}
                    __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                    goto __pyx_L26_exception_handled;
                  }
                  goto __pyx_L27_except_error;
                  __pyx_L27_except_error:;
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_XGIVEREF(__pyx_t_16);
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                  goto __pyx_L5_error;
                  __pyx_L26_exception_handled:;
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_XGIVEREF(__pyx_t_16);
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                  __pyx_L32_try_end:;
                }
                goto __pyx_L24;
              }
              /*else*/ {

                /* "cassandra/connection.py":895
 *                                     failed_connections.append((connection, owner))
 *                             else:
 *                                 connection.reset_idle()             # <<<<<<<<<<<<<<
 *                         else:
 *                             # make sure the owner sees this defunt/closed connection
 */
                __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_connection, __pyx_n_s_reset_idle); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_3 = NULL;
                if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
                  __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
                  if (likely(__pyx_t_3)) {
                    PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
                    __Pyx_INCREF(__pyx_t_3);
                    __Pyx_INCREF(function);
                    __Pyx_DECREF_SET(__pyx_t_2, function);
                  }
                }
                if (__pyx_t_3) {
                  __pyx_t_19 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                } else {
                  __pyx_t_19 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
                }
                __Pyx_GOTREF(__pyx_t_19);
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
              }
              __pyx_L24:;
              goto __pyx_L21;
            }
            /*else*/ {

              /* "cassandra/connection.py":898
 *                         else:
 *                             # make sure the owner sees this defunt/closed connection
 *                             owner.return_connection(connection)             # <<<<<<<<<<<<<<
 *                     self._raise_if_stopped()
 * 
 */
              __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_owner, __pyx_n_s_return_connection); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_3 = NULL;
              if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
                __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
                if (likely(__pyx_t_3)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
                  __Pyx_INCREF(__pyx_t_3);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_2, function);
                }
              }
              if (!__pyx_t_3) {
                __pyx_t_19 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_connection); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
                __Pyx_GOTREF(__pyx_t_19);
              } else {
                __pyx_t_23 = PyTuple_New(1+1); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
                __Pyx_GOTREF(__pyx_t_23);
                __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_t_3); __pyx_t_3 = NULL;
                __Pyx_INCREF(__pyx_v_connection);
                __Pyx_GIVEREF(__pyx_v_connection);
                PyTuple_SET_ITEM(__pyx_t_23, 0+1, __pyx_v_connection);
                __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_23, NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
                __Pyx_GOTREF(__pyx_t_19);
                __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
              }
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            }
            __pyx_L21:;

            /* "cassandra/connection.py":884
 *             try:
 *                 for connections, owner in [(o.get_connections(), o) for o in self._get_connection_holders()]:
 *                     for connection in connections:             # <<<<<<<<<<<<<<
 *                         self._raise_if_stopped()
 *                         if not (connection.is_defunct or connection.is_closed):
 */
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "cassandra/connection.py":899
 *                             # make sure the owner sees this defunt/closed connection
 *                             owner.return_connection(connection)
 *                     self._raise_if_stopped()             # <<<<<<<<<<<<<<
 * 
 *                 for f in futures:
 */
          __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_raise_if_stopped); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_19);
          __pyx_t_2 = NULL;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_19))) {
            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_19);
            if (likely(__pyx_t_2)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_19, function);
            }
          }
          if (__pyx_t_2) {
            __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_19, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          } else {
            __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_19); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          }
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "cassandra/connection.py":883
 *             failed_connections = []
 *             try:
 *                 for connections, owner in [(o.get_connections(), o) for o in self._get_connection_holders()]:             # <<<<<<<<<<<<<<
 *                     for connection in connections:
 *                         self._raise_if_stopped()
 */
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "cassandra/connection.py":901
 *                     self._raise_if_stopped()
 * 
 *                 for f in futures:             # <<<<<<<<<<<<<<
 *                     self._raise_if_stopped()
 *                     connection = f.connection
 */
        __pyx_t_5 = __pyx_v_futures; __Pyx_INCREF(__pyx_t_5); __pyx_t_11 = 0;
        for (;;) {
          if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_11); __Pyx_INCREF(__pyx_t_1); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          #else
          __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_1);
          #endif
          __Pyx_XDECREF_SET(__pyx_v_f, __pyx_t_1);
          __pyx_t_1 = 0;

          /* "cassandra/connection.py":902
 * 
 *                 for f in futures:
 *                     self._raise_if_stopped()             # <<<<<<<<<<<<<<
 *                     connection = f.connection
 *                     try:
 */
          __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_raise_if_stopped); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_19);
          __pyx_t_2 = NULL;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_19))) {
            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_19);
            if (likely(__pyx_t_2)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_19, function);
            }
          }
          if (__pyx_t_2) {
            __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_19, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          } else {
            __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_19); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          }
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "cassandra/connection.py":903
 *                 for f in futures:
 *                     self._raise_if_stopped()
 *                     connection = f.connection             # <<<<<<<<<<<<<<
 *                     try:
 *                         f.wait(self._interval)
 */
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_connection); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_XDECREF_SET(__pyx_v_connection, __pyx_t_1);
          __pyx_t_1 = 0;

          /* "cassandra/connection.py":904
 *                     self._raise_if_stopped()
 *                     connection = f.connection
 *                     try:             # <<<<<<<<<<<<<<
 *                         f.wait(self._interval)
 *                         # TODO: move this, along with connection locks in pool, down into Connection
 */
          {
            __Pyx_ExceptionSave(&__pyx_t_17, &__pyx_t_16, &__pyx_t_15);
            __Pyx_XGOTREF(__pyx_t_17);
            __Pyx_XGOTREF(__pyx_t_16);
            __Pyx_XGOTREF(__pyx_t_15);
            /*try:*/ {

              /* "cassandra/connection.py":905
 *                     connection = f.connection
 *                     try:
 *                         f.wait(self._interval)             # <<<<<<<<<<<<<<
 *                         # TODO: move this, along with connection locks in pool, down into Connection
 *                         with connection.lock:
 */
              __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_wait); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L37_error;}
              __Pyx_GOTREF(__pyx_t_19);
              __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_interval); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L37_error;}
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_23 = NULL;
              if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_19))) {
                __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_19);
                if (likely(__pyx_t_23)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19);
                  __Pyx_INCREF(__pyx_t_23);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_19, function);
                }
              }
              if (!__pyx_t_23) {
                __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_19, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L37_error;}
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_GOTREF(__pyx_t_1);
              } else {
                __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L37_error;}
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_GIVEREF(__pyx_t_23); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_23); __pyx_t_23 = NULL;
                __Pyx_GIVEREF(__pyx_t_2);
                PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_2);
                __pyx_t_2 = 0;
                __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L37_error;}
                __Pyx_GOTREF(__pyx_t_1);
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              }
              __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

              /* "cassandra/connection.py":907
 *                         f.wait(self._interval)
 *                         # TODO: move this, along with connection locks in pool, down into Connection
 *                         with connection.lock:             # <<<<<<<<<<<<<<
 *                             connection.in_flight -= 1
 *                         connection.reset_idle()
 */
              /*with:*/ {
                __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_connection, __pyx_n_s_lock); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L37_error;}
                __Pyx_GOTREF(__pyx_t_1);
                __pyx_t_25 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L37_error;}
                __Pyx_GOTREF(__pyx_t_25);
                __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L45_error;}
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_2 = NULL;
                if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
                  __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
                  if (likely(__pyx_t_2)) {
                    PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                    __Pyx_INCREF(__pyx_t_2);
                    __Pyx_INCREF(function);
                    __Pyx_DECREF_SET(__pyx_t_3, function);
                  }
                }
                if (__pyx_t_2) {
                  __pyx_t_19 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L45_error;}
                  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                } else {
                  __pyx_t_19 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L45_error;}
                }
                __Pyx_GOTREF(__pyx_t_19);
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                /*try:*/ {
                  {
                    __Pyx_ExceptionSave(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28);
                    __Pyx_XGOTREF(__pyx_t_26);
                    __Pyx_XGOTREF(__pyx_t_27);
                    __Pyx_XGOTREF(__pyx_t_28);
                    /*try:*/ {

                      /* "cassandra/connection.py":908
 *                         # TODO: move this, along with connection locks in pool, down into Connection
 *                         with connection.lock:
 *                             connection.in_flight -= 1             # <<<<<<<<<<<<<<
 *                         connection.reset_idle()
 *                     except Exception:
 */
                      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_connection, __pyx_n_s_in_flight); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L51_error;}
                      __Pyx_GOTREF(__pyx_t_1);
                      __pyx_t_19 = PyNumber_InPlaceSubtract(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L51_error;}
                      __Pyx_GOTREF(__pyx_t_19);
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      if (__Pyx_PyObject_SetAttrStr(__pyx_v_connection, __pyx_n_s_in_flight, __pyx_t_19) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L51_error;}
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                    }
                    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                    __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                    __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
                    goto __pyx_L58_try_end;
                    __pyx_L51_error:;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;

                    /* "cassandra/connection.py":907
 *                         f.wait(self._interval)
 *                         # TODO: move this, along with connection locks in pool, down into Connection
 *                         with connection.lock:             # <<<<<<<<<<<<<<
 *                             connection.in_flight -= 1
 *                         connection.reset_idle()
 */
                    /*except:*/ {
                      __Pyx_AddTraceback("cassandra.connection.ConnectionHeartbeat.run", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_19, &__pyx_t_1, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L53_except_error;}
                      __Pyx_GOTREF(__pyx_t_19);
                      __Pyx_GOTREF(__pyx_t_1);
                      __Pyx_GOTREF(__pyx_t_3);
                      __pyx_t_2 = PyTuple_Pack(3, __pyx_t_19, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L53_except_error;}
                      __Pyx_GOTREF(__pyx_t_2);
                      __pyx_t_29 = __Pyx_PyObject_Call(__pyx_t_25, __pyx_t_2, NULL);
                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L53_except_error;}
                      __Pyx_GOTREF(__pyx_t_29);
                      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_29);
                      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
                      if (__pyx_t_6 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L53_except_error;}
                      __pyx_t_7 = ((!(__pyx_t_6 != 0)) != 0);
                      if (__pyx_t_7) {
                        __Pyx_GIVEREF(__pyx_t_19);
                        __Pyx_GIVEREF(__pyx_t_1);
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __Pyx_ErrRestore(__pyx_t_19, __pyx_t_1, __pyx_t_3);
                        __pyx_t_19 = 0; __pyx_t_1 = 0; __pyx_t_3 = 0; 
                        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L53_except_error;}
                      }
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      goto __pyx_L52_exception_handled;
                    }
                    __pyx_L53_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_26);
                    __Pyx_XGIVEREF(__pyx_t_27);
                    __Pyx_XGIVEREF(__pyx_t_28);
                    __Pyx_ExceptionReset(__pyx_t_26, __pyx_t_27, __pyx_t_28);
                    goto __pyx_L37_error;
                    __pyx_L52_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_26);
                    __Pyx_XGIVEREF(__pyx_t_27);
                    __Pyx_XGIVEREF(__pyx_t_28);
                    __Pyx_ExceptionReset(__pyx_t_26, __pyx_t_27, __pyx_t_28);
                    __pyx_L58_try_end:;
                  }
                }
                /*finally:*/ {
                  /*normal exit:*/{
                    if (__pyx_t_25) {
                      __pyx_t_28 = __Pyx_PyObject_Call(__pyx_t_25, __pyx_tuple__30, NULL);
                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                      if (unlikely(!__pyx_t_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L37_error;}
                      __Pyx_GOTREF(__pyx_t_28);
                      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
                    }
                    goto __pyx_L50;
                  }
                  __pyx_L50:;
                }
                goto __pyx_L62;
                __pyx_L45_error:;
                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                goto __pyx_L37_error;
                __pyx_L62:;
              }

              /* "cassandra/connection.py":909
 *                         with connection.lock:
 *                             connection.in_flight -= 1
 *                         connection.reset_idle()             # <<<<<<<<<<<<<<
 *                     except Exception:
 *                         log.warning("Heartbeat failed for connection (%s) to %s",
 */
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_connection, __pyx_n_s_reset_idle); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L37_error;}
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_19 = NULL;
              if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
                __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_1);
                if (likely(__pyx_t_19)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
                  __Pyx_INCREF(__pyx_t_19);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_1, function);
                }
              }
              if (__pyx_t_19) {
                __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_19); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L37_error;}
                __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
              } else {
                __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L37_error;}
              }
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            }
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            goto __pyx_L44_try_end;
            __pyx_L37_error:;
            __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "cassandra/connection.py":910
 *                             connection.in_flight -= 1
 *                         connection.reset_idle()
 *                     except Exception:             # <<<<<<<<<<<<<<
 *                         log.warning("Heartbeat failed for connection (%s) to %s",
 *                                     id(connection), connection.host, exc_info=True)
 */
            __pyx_t_21 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
            if (__pyx_t_21) {
              __Pyx_AddTraceback("cassandra.connection.ConnectionHeartbeat.run", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_19) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 910; __pyx_clineno = __LINE__; goto __pyx_L39_except_error;}
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_GOTREF(__pyx_t_19);

              /* "cassandra/connection.py":911
 *                         connection.reset_idle()
 *                     except Exception:
 *                         log.warning("Heartbeat failed for connection (%s) to %s",             # <<<<<<<<<<<<<<
 *                                     id(connection), connection.host, exc_info=True)
 *                         failed_connections.append((f.connection, f.owner))
 */
              __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L39_except_error;}
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_warning); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L39_except_error;}
              __Pyx_GOTREF(__pyx_t_23);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

              /* "cassandra/connection.py":912
 *                     except Exception:
 *                         log.warning("Heartbeat failed for connection (%s) to %s",
 *                                     id(connection), connection.host, exc_info=True)             # <<<<<<<<<<<<<<
 *                         failed_connections.append((f.connection, f.owner))
 * 
 */
              __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L39_except_error;}
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_INCREF(__pyx_v_connection);
              __Pyx_GIVEREF(__pyx_v_connection);
              PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_connection);
              __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L39_except_error;}
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_connection, __pyx_n_s_host); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L39_except_error;}
              __Pyx_GOTREF(__pyx_t_2);

              /* "cassandra/connection.py":911
 *                         connection.reset_idle()
 *                     except Exception:
 *                         log.warning("Heartbeat failed for connection (%s) to %s",             # <<<<<<<<<<<<<<
 *                                     id(connection), connection.host, exc_info=True)
 *                         failed_connections.append((f.connection, f.owner))
 */
              __pyx_t_24 = PyTuple_New(3); if (unlikely(!__pyx_t_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L39_except_error;}
              __Pyx_GOTREF(__pyx_t_24);
              __Pyx_INCREF(__pyx_kp_s_Heartbeat_failed_for_connection);
              __Pyx_GIVEREF(__pyx_kp_s_Heartbeat_failed_for_connection);
              PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_kp_s_Heartbeat_failed_for_connection);
              __Pyx_GIVEREF(__pyx_t_4);
              PyTuple_SET_ITEM(__pyx_t_24, 1, __pyx_t_4);
              __Pyx_GIVEREF(__pyx_t_2);
              PyTuple_SET_ITEM(__pyx_t_24, 2, __pyx_t_2);
              __pyx_t_4 = 0;
              __pyx_t_2 = 0;
              __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L39_except_error;}
              __Pyx_GOTREF(__pyx_t_2);

              /* "cassandra/connection.py":912
 *                     except Exception:
 *                         log.warning("Heartbeat failed for connection (%s) to %s",
 *                                     id(connection), connection.host, exc_info=True)             # <<<<<<<<<<<<<<
 *                         failed_connections.append((f.connection, f.owner))
 * 
 */
              if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_exc_info, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L39_except_error;}

              /* "cassandra/connection.py":911
 *                         connection.reset_idle()
 *                     except Exception:
 *                         log.warning("Heartbeat failed for connection (%s) to %s",             # <<<<<<<<<<<<<<
 *                                     id(connection), connection.host, exc_info=True)
 *                         failed_connections.append((f.connection, f.owner))
 */
              __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_23, __pyx_t_24, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L39_except_error;}
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

              /* "cassandra/connection.py":913
 *                         log.warning("Heartbeat failed for connection (%s) to %s",
 *                                     id(connection), connection.host, exc_info=True)
 *                         failed_connections.append((f.connection, f.owner))             # <<<<<<<<<<<<<<
 * 
 *                 for connection, owner in failed_connections:
 */
              __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_connection); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L39_except_error;}
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_owner); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L39_except_error;}
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_24 = PyTuple_New(2); if (unlikely(!__pyx_t_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L39_except_error;}
              __Pyx_GOTREF(__pyx_t_24);
              __Pyx_GIVEREF(__pyx_t_4);
              PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_4);
              __Pyx_GIVEREF(__pyx_t_2);
              PyTuple_SET_ITEM(__pyx_t_24, 1, __pyx_t_2);
              __pyx_t_4 = 0;
              __pyx_t_2 = 0;
              __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_failed_connections, __pyx_t_24); if (unlikely(__pyx_t_20 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L39_except_error;}
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
              goto __pyx_L38_exception_handled;
            }
            goto __pyx_L39_except_error;
            __pyx_L39_except_error:;
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_15);
            __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_16, __pyx_t_15);
            goto __pyx_L5_error;
            __pyx_L38_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_15);
            __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_16, __pyx_t_15);
            __pyx_L44_try_end:;
          }

          /* "cassandra/connection.py":901
 *                     self._raise_if_stopped()
 * 
 *                 for f in futures:             # <<<<<<<<<<<<<<
 *                     self._raise_if_stopped()
 *                     connection = f.connection
 */
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "cassandra/connection.py":915
 *                         failed_connections.append((f.connection, f.owner))
 * 
 *                 for connection, owner in failed_connections:             # <<<<<<<<<<<<<<
 *                     self._raise_if_stopped()
 *                     connection.defunct(Exception('Connection heartbeat failure'))
 */
        __pyx_t_5 = __pyx_v_failed_connections; __Pyx_INCREF(__pyx_t_5); __pyx_t_11 = 0;
        for (;;) {
          if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_19 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_11); __Pyx_INCREF(__pyx_t_19); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          #else
          __pyx_t_19 = PySequence_ITEM(__pyx_t_5, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_19);
          #endif
          if ((likely(PyTuple_CheckExact(__pyx_t_19))) || (PyList_CheckExact(__pyx_t_19))) {
            PyObject* sequence = __pyx_t_19;
            #if CYTHON_COMPILING_IN_CPYTHON
            Py_ssize_t size = Py_SIZE(sequence);
            #else
            Py_ssize_t size = PySequence_Size(sequence);
            #endif
            if (unlikely(size != 2)) {
              if (size > 2) __Pyx_RaiseTooManyValuesError(2);
              else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            }
            #if CYTHON_COMPILING_IN_CPYTHON
            if (likely(PyTuple_CheckExact(sequence))) {
              __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
              __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
            } else {
              __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
              __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
            }
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_3);
            #else
            __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_GOTREF(__pyx_t_3);
            #endif
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          } else {
            Py_ssize_t index = -1;
            __pyx_t_24 = PyObject_GetIter(__pyx_t_19); if (unlikely(!__pyx_t_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_GOTREF(__pyx_t_24);
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            __pyx_t_13 = Py_TYPE(__pyx_t_24)->tp_iternext;
            index = 0; __pyx_t_1 = __pyx_t_13(__pyx_t_24); if (unlikely(!__pyx_t_1)) goto __pyx_L67_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_1);
            index = 1; __pyx_t_3 = __pyx_t_13(__pyx_t_24); if (unlikely(!__pyx_t_3)) goto __pyx_L67_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_3);
            if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_24), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __pyx_t_13 = NULL;
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            goto __pyx_L68_unpacking_done;
            __pyx_L67_unpacking_failed:;
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            __pyx_t_13 = NULL;
            if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __pyx_L68_unpacking_done:;
          }
          __Pyx_XDECREF_SET(__pyx_v_connection, __pyx_t_1);
          __pyx_t_1 = 0;
          __Pyx_XDECREF_SET(__pyx_v_owner, __pyx_t_3);
          __pyx_t_3 = 0;

          /* "cassandra/connection.py":916
 * 
 *                 for connection, owner in failed_connections:
 *                     self._raise_if_stopped()             # <<<<<<<<<<<<<<
 *                     connection.defunct(Exception('Connection heartbeat failure'))
 *                     owner.return_connection(connection)
 */
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_raise_if_stopped); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_1 = NULL;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
            if (likely(__pyx_t_1)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_3, function);
            }
          }
          if (__pyx_t_1) {
            __pyx_t_19 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          } else {
            __pyx_t_19 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          }
          __Pyx_GOTREF(__pyx_t_19);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

          /* "cassandra/connection.py":917
 *                 for connection, owner in failed_connections:
 *                     self._raise_if_stopped()
 *                     connection.defunct(Exception('Connection heartbeat failure'))             # <<<<<<<<<<<<<<
 *                     owner.return_connection(connection)
 *             except self.ShutdownException:
 */
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_connection, __pyx_n_s_defunct); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_Exception, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_24 = NULL;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_3);
            if (likely(__pyx_t_24)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_24);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_3, function);
            }
          }
          if (!__pyx_t_24) {
            __pyx_t_19 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_GOTREF(__pyx_t_19);
          } else {
            __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_24); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_24); __pyx_t_24 = NULL;
            __Pyx_GIVEREF(__pyx_t_1);
            PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_1);
            __pyx_t_1 = 0;
            __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_GOTREF(__pyx_t_19);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          }
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

          /* "cassandra/connection.py":918
 *                     self._raise_if_stopped()
 *                     connection.defunct(Exception('Connection heartbeat failure'))
 *                     owner.return_connection(connection)             # <<<<<<<<<<<<<<
 *             except self.ShutdownException:
 *                 pass
 */
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_owner, __pyx_n_s_return_connection); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_2 = NULL;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
            if (likely(__pyx_t_2)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_3, function);
            }
          }
          if (!__pyx_t_2) {
            __pyx_t_19 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_connection); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_GOTREF(__pyx_t_19);
          } else {
            __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL;
            __Pyx_INCREF(__pyx_v_connection);
            __Pyx_GIVEREF(__pyx_v_connection);
            PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_connection);
            __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
            __Pyx_GOTREF(__pyx_t_19);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          }
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

          /* "cassandra/connection.py":915
 *                         failed_connections.append((f.connection, f.owner))
 * 
 *                 for connection, owner in failed_connections:             # <<<<<<<<<<<<<<
 *                     self._raise_if_stopped()
 *                     connection.defunct(Exception('Connection heartbeat failure'))
 */
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L12_try_end;
      __pyx_L5_error:;
      __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
      __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "cassandra/connection.py":919
 *                     connection.defunct(Exception('Connection heartbeat failure'))
 *                     owner.return_connection(connection)
 *             except self.ShutdownException:             # <<<<<<<<<<<<<<
 *                 pass
 *             except Exception:
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ShutdownException); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_21 = PyErr_ExceptionMatches(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_21) {
        PyErr_Restore(0,0,0);
        goto __pyx_L6_exception_handled;
      }

      /* "cassandra/connection.py":921
 *             except self.ShutdownException:
 *                 pass
 *             except Exception:             # <<<<<<<<<<<<<<
 *                 log.error("Failed connection heartbeat", exc_info=True)
 * 
 */
      __pyx_t_21 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
      if (__pyx_t_21) {
        __Pyx_AddTraceback("cassandra.connection.ConnectionHeartbeat.run", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_19, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GOTREF(__pyx_t_19);
        __Pyx_GOTREF(__pyx_t_3);

        /* "cassandra/connection.py":922
 *                 pass
 *             except Exception:
 *                 log.error("Failed connection heartbeat", exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *             elapsed = time.time() - start_time
 */
        __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_error); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_1);
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_exc_info, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __pyx_t_24 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__32, __pyx_t_1); if (unlikely(!__pyx_t_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_24);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L6_exception_handled;
      }
      goto __pyx_L7_except_error;
      __pyx_L7_except_error:;
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      goto __pyx_L1_error;
      __pyx_L6_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      __pyx_L12_try_end:;
    }

    /* "cassandra/connection.py":924
 *                 log.error("Failed connection heartbeat", exc_info=True)
 * 
 *             elapsed = time.time() - start_time             # <<<<<<<<<<<<<<
 *             self._shutdown_event.wait(max(self._interval - elapsed, 0.01))
 * 
 */
    __pyx_t_19 = __Pyx_GetModuleGlobalName(__pyx_n_s_time); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_19);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_n_s_time); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    __pyx_t_19 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_19)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_19);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (__pyx_t_19) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_19); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Subtract(__pyx_t_3, __pyx_v_start_time); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_elapsed, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "cassandra/connection.py":925
 * 
 *             elapsed = time.time() - start_time
 *             self._shutdown_event.wait(max(self._interval - elapsed, 0.01))             # <<<<<<<<<<<<<<
 * 
 *     def stop(self):
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_shutdown_event); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_wait); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_19);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_30 = 0.01;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_interval); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_24 = PyNumber_Subtract(__pyx_t_3, __pyx_v_elapsed); if (unlikely(!__pyx_t_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_24);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = PyFloat_FromDouble(__pyx_t_30); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_24, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_7) {
      __pyx_t_2 = PyFloat_FromDouble(__pyx_t_30); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __pyx_t_2;
      __pyx_t_2 = 0;
    } else {
      __Pyx_INCREF(__pyx_t_24);
      __pyx_t_3 = __pyx_t_24;
    }
    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
    __pyx_t_24 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_19))) {
      __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_19);
      if (likely(__pyx_t_24)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19);
        __Pyx_INCREF(__pyx_t_24);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_19, function);
      }
    }
    if (!__pyx_t_24) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_19, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_24); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_24); __pyx_t_24 = NULL;
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_3);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }

  /* "cassandra/connection.py":875
 *         pass
 * 
 *     def run(self):             # <<<<<<<<<<<<<<
 *         self._shutdown_event.wait(self._interval)
 *         while not self._shutdown_event.is_set():
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_24);
  __Pyx_AddTraceback("cassandra.connection.ConnectionHeartbeat.run", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_start_time);
  __Pyx_XDECREF(__pyx_v_futures);
  __Pyx_XDECREF(__pyx_v_failed_connections);
  __Pyx_XDECREF(__pyx_v_connections);
  __Pyx_XDECREF(__pyx_v_owner);
  __Pyx_XDECREF(__pyx_v_connection);
  __Pyx_XDECREF(__pyx_v_f);
  __Pyx_XDECREF(__pyx_v_elapsed);
  __Pyx_XDECREF(__pyx_v_o);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":927
 *             self._shutdown_event.wait(max(self._interval - elapsed, 0.01))
 * 
 *     def stop(self):             # <<<<<<<<<<<<<<
 *         self._shutdown_event.set()
 *         self.join()
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_19ConnectionHeartbeat_5stop(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_19ConnectionHeartbeat_5stop = {"stop", (PyCFunction)__pyx_pw_9cassandra_10connection_19ConnectionHeartbeat_5stop, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_19ConnectionHeartbeat_5stop(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_19ConnectionHeartbeat_4stop(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_19ConnectionHeartbeat_4stop(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("stop", 0);

  /* "cassandra/connection.py":928
 * 
 *     def stop(self):
 *         self._shutdown_event.set()             # <<<<<<<<<<<<<<
 *         self.join()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_shutdown_event); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_set); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":929
 *     def stop(self):
 *         self._shutdown_event.set()
 *         self.join()             # <<<<<<<<<<<<<<
 * 
 *     def _raise_if_stopped(self):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_join); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":927
 *             self._shutdown_event.wait(max(self._interval - elapsed, 0.01))
 * 
 *     def stop(self):             # <<<<<<<<<<<<<<
 *         self._shutdown_event.set()
 *         self.join()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cassandra.connection.ConnectionHeartbeat.stop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":931
 *         self.join()
 * 
 *     def _raise_if_stopped(self):             # <<<<<<<<<<<<<<
 *         if self._shutdown_event.is_set():
 *             raise self.ShutdownException()
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_19ConnectionHeartbeat_7_raise_if_stopped(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_19ConnectionHeartbeat_7_raise_if_stopped = {"_raise_if_stopped", (PyCFunction)__pyx_pw_9cassandra_10connection_19ConnectionHeartbeat_7_raise_if_stopped, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_19ConnectionHeartbeat_7_raise_if_stopped(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_raise_if_stopped (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_19ConnectionHeartbeat_6_raise_if_stopped(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_19ConnectionHeartbeat_6_raise_if_stopped(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_raise_if_stopped", 0);

  /* "cassandra/connection.py":932
 * 
 *     def _raise_if_stopped(self):
 *         if self._shutdown_event.is_set():             # <<<<<<<<<<<<<<
 *             raise self.ShutdownException()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_shutdown_event); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_is_set); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {

    /* "cassandra/connection.py":933
 *     def _raise_if_stopped(self):
 *         if self._shutdown_event.is_set():
 *             raise self.ShutdownException()             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_ShutdownException); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_2) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "cassandra/connection.py":931
 *         self.join()
 * 
 *     def _raise_if_stopped(self):             # <<<<<<<<<<<<<<
 *         if self._shutdown_event.is_set():
 *             raise self.ShutdownException()
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cassandra.connection.ConnectionHeartbeat._raise_if_stopped", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":940
 *     canceled = False
 * 
 *     def __init__(self, timeout, callback):             # <<<<<<<<<<<<<<
 *         self.end = time.time() + timeout
 *         self.callback = callback
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_5Timer_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_5Timer_1__init__ = {"__init__", (PyCFunction)__pyx_pw_9cassandra_10connection_5Timer_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_5Timer_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_timeout = 0;
  PyObject *__pyx_v_callback = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_timeout,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_self = values[0];
    __pyx_v_timeout = values[1];
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Timer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_5Timer___init__(__pyx_self, __pyx_v_self, __pyx_v_timeout, __pyx_v_callback);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_5Timer___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_timeout, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cassandra/connection.py":941
 * 
 *     def __init__(self, timeout, callback):
 *         self.end = time.time() + timeout             # <<<<<<<<<<<<<<
 *         self.callback = callback
 *         if timeout < 0:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_time); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_time); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_v_timeout); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_end, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cassandra/connection.py":942
 *     def __init__(self, timeout, callback):
 *         self.end = time.time() + timeout
 *         self.callback = callback             # <<<<<<<<<<<<<<
 *         if timeout < 0:
 *             self.callback()
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_callback, __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":943
 *         self.end = time.time() + timeout
 *         self.callback = callback
 *         if timeout < 0:             # <<<<<<<<<<<<<<
 *             self.callback()
 * 
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_timeout, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "cassandra/connection.py":944
 *         self.callback = callback
 *         if timeout < 0:
 *             self.callback()             # <<<<<<<<<<<<<<
 * 
 *     def cancel(self):
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_callback); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (__pyx_t_2) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cassandra/connection.py":940
 *     canceled = False
 * 
 *     def __init__(self, timeout, callback):             # <<<<<<<<<<<<<<
 *         self.end = time.time() + timeout
 *         self.callback = callback
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cassandra.connection.Timer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":946
 *             self.callback()
 * 
 *     def cancel(self):             # <<<<<<<<<<<<<<
 *         self.canceled = True
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_5Timer_3cancel(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_5Timer_3cancel = {"cancel", (PyCFunction)__pyx_pw_9cassandra_10connection_5Timer_3cancel, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_5Timer_3cancel(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("cancel (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_5Timer_2cancel(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_5Timer_2cancel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("cancel", 0);

  /* "cassandra/connection.py":947
 * 
 *     def cancel(self):
 *         self.canceled = True             # <<<<<<<<<<<<<<
 * 
 *     def finish(self, time_now):
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_canceled, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":946
 *             self.callback()
 * 
 *     def cancel(self):             # <<<<<<<<<<<<<<
 *         self.canceled = True
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("cassandra.connection.Timer.cancel", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":949
 *         self.canceled = True
 * 
 *     def finish(self, time_now):             # <<<<<<<<<<<<<<
 *         if self.canceled:
 *             return True
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_5Timer_5finish(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_5Timer_5finish = {"finish", (PyCFunction)__pyx_pw_9cassandra_10connection_5Timer_5finish, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_9cassandra_10connection_5Timer_5finish(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_time_now = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("finish (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_time_now,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_time_now)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("finish", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "finish") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_time_now = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("finish", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.Timer.finish", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_5Timer_4finish(__pyx_self, __pyx_v_self, __pyx_v_time_now);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_5Timer_4finish(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_time_now) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("finish", 0);

  /* "cassandra/connection.py":950
 * 
 *     def finish(self, time_now):
 *         if self.canceled:             # <<<<<<<<<<<<<<
 *             return True
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_canceled); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cassandra/connection.py":951
 *     def finish(self, time_now):
 *         if self.canceled:
 *             return True             # <<<<<<<<<<<<<<
 * 
 *         if time_now >= self.end:
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_True);
    __pyx_r = Py_True;
    goto __pyx_L0;
  }

  /* "cassandra/connection.py":953
 *             return True
 * 
 *         if time_now >= self.end:             # <<<<<<<<<<<<<<
 *             self.callback()
 *             return True
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_end); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_time_now, __pyx_t_1, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {

    /* "cassandra/connection.py":954
 * 
 *         if time_now >= self.end:
 *             self.callback()             # <<<<<<<<<<<<<<
 *             return True
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_callback); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "cassandra/connection.py":955
 *         if time_now >= self.end:
 *             self.callback()
 *             return True             # <<<<<<<<<<<<<<
 * 
 *         return False
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_True);
    __pyx_r = Py_True;
    goto __pyx_L0;
  }

  /* "cassandra/connection.py":957
 *             return True
 * 
 *         return False             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_False);
  __pyx_r = Py_False;
  goto __pyx_L0;

  /* "cassandra/connection.py":949
 *         self.canceled = True
 * 
 *     def finish(self, time_now):             # <<<<<<<<<<<<<<
 *         if self.canceled:
 *             return True
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("cassandra.connection.Timer.finish", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":962
 * class TimerManager(object):
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self._queue = []
 *         self._new_timers = []
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_12TimerManager_1__init__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_12TimerManager_1__init__ = {"__init__", (PyCFunction)__pyx_pw_9cassandra_10connection_12TimerManager_1__init__, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_12TimerManager_1__init__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_12TimerManager___init__(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_12TimerManager___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "cassandra/connection.py":963
 * 
 *     def __init__(self):
 *         self._queue = []             # <<<<<<<<<<<<<<
 *         self._new_timers = []
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_queue, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":964
 *     def __init__(self):
 *         self._queue = []
 *         self._new_timers = []             # <<<<<<<<<<<<<<
 * 
 *     def add_timer(self, timer):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_new_timers, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":962
 * class TimerManager(object):
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self._queue = []
 *         self._new_timers = []
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("cassandra.connection.TimerManager.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":966
 *         self._new_timers = []
 * 
 *     def add_timer(self, timer):             # <<<<<<<<<<<<<<
 *         """
 *         called from client thread with a Timer object
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_12TimerManager_3add_timer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_9cassandra_10connection_12TimerManager_2add_timer[] = "\n        called from client thread with a Timer object\n        ";
static PyMethodDef __pyx_mdef_9cassandra_10connection_12TimerManager_3add_timer = {"add_timer", (PyCFunction)__pyx_pw_9cassandra_10connection_12TimerManager_3add_timer, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9cassandra_10connection_12TimerManager_2add_timer};
static PyObject *__pyx_pw_9cassandra_10connection_12TimerManager_3add_timer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_timer = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_timer (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_timer,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timer)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_timer", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_timer") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_timer = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_timer", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("cassandra.connection.TimerManager.add_timer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_9cassandra_10connection_12TimerManager_2add_timer(__pyx_self, __pyx_v_self, __pyx_v_timer);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_12TimerManager_2add_timer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_timer) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_timer", 0);

  /* "cassandra/connection.py":970
 *         called from client thread with a Timer object
 *         """
 *         self._new_timers.append((timer.end, timer))             # <<<<<<<<<<<<<<
 * 
 *     def service_timeouts(self):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_new_timers); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_timer, __pyx_n_s_end); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_timer);
  __Pyx_GIVEREF(__pyx_v_timer);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_timer);
  __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_t_3); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "cassandra/connection.py":966
 *         self._new_timers = []
 * 
 *     def add_timer(self, timer):             # <<<<<<<<<<<<<<
 *         """
 *         called from client thread with a Timer object
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cassandra.connection.TimerManager.add_timer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":972
 *         self._new_timers.append((timer.end, timer))
 * 
 *     def service_timeouts(self):             # <<<<<<<<<<<<<<
 *         """
 *         run callbacks on all expired timers
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_12TimerManager_5service_timeouts(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_9cassandra_10connection_12TimerManager_4service_timeouts[] = "\n        run callbacks on all expired timers\n        Called from the event thread\n        :return: next end time, or None\n        ";
static PyMethodDef __pyx_mdef_9cassandra_10connection_12TimerManager_5service_timeouts = {"service_timeouts", (PyCFunction)__pyx_pw_9cassandra_10connection_12TimerManager_5service_timeouts, METH_O, __pyx_doc_9cassandra_10connection_12TimerManager_4service_timeouts};
static PyObject *__pyx_pw_9cassandra_10connection_12TimerManager_5service_timeouts(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("service_timeouts (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_12TimerManager_4service_timeouts(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_12TimerManager_4service_timeouts(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_queue = NULL;
  PyObject *__pyx_v_new_timers = NULL;
  PyObject *__pyx_v_now = NULL;
  PyObject *__pyx_v_timer = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("service_timeouts", 0);

  /* "cassandra/connection.py":978
 *         :return: next end time, or None
 *         """
 *         queue = self._queue             # <<<<<<<<<<<<<<
 *         if self._new_timers:
 *             new_timers = self._new_timers
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_queue); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_queue = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "cassandra/connection.py":979
 *         """
 *         queue = self._queue
 *         if self._new_timers:             # <<<<<<<<<<<<<<
 *             new_timers = self._new_timers
 *             while new_timers:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_new_timers); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "cassandra/connection.py":980
 *         queue = self._queue
 *         if self._new_timers:
 *             new_timers = self._new_timers             # <<<<<<<<<<<<<<
 *             while new_timers:
 *                 heappush(queue, new_timers.pop())
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_new_timers); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_new_timers = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cassandra/connection.py":981
 *         if self._new_timers:
 *             new_timers = self._new_timers
 *             while new_timers:             # <<<<<<<<<<<<<<
 *                 heappush(queue, new_timers.pop())
 * 
 */
    while (1) {
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_new_timers); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (!__pyx_t_2) break;

      /* "cassandra/connection.py":982
 *             new_timers = self._new_timers
 *             while new_timers:
 *                 heappush(queue, new_timers.pop())             # <<<<<<<<<<<<<<
 * 
 *         if queue:
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_heappush); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_Pop(__pyx_v_new_timers); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_6 = 1;
        }
      }
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_queue);
      __Pyx_GIVEREF(__pyx_v_queue);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_queue);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "cassandra/connection.py":984
 *                 heappush(queue, new_timers.pop())
 * 
 *         if queue:             # <<<<<<<<<<<<<<
 *             now = time.time()
 *             while queue:
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_queue); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {

    /* "cassandra/connection.py":985
 * 
 *         if queue:
 *             now = time.time()             # <<<<<<<<<<<<<<
 *             while queue:
 *                 try:
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_time); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_time); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    if (__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_now = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "cassandra/connection.py":986
 *         if queue:
 *             now = time.time()
 *             while queue:             # <<<<<<<<<<<<<<
 *                 try:
 *                     timer = queue[0][1]
 */
    while (1) {
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_queue); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (!__pyx_t_2) break;

      /* "cassandra/connection.py":987
 *             now = time.time()
 *             while queue:
 *                 try:             # <<<<<<<<<<<<<<
 *                     timer = queue[0][1]
 *                     if timer.finish(now):
 */
      {
        __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
        __Pyx_XGOTREF(__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_9);
        __Pyx_XGOTREF(__pyx_t_10);
        /*try:*/ {

          /* "cassandra/connection.py":988
 *             while queue:
 *                 try:
 *                     timer = queue[0][1]             # <<<<<<<<<<<<<<
 *                     if timer.finish(now):
 *                         heappop(queue)
 */
          __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_queue, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L9_error;};
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L9_error;};
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF_SET(__pyx_v_timer, __pyx_t_7);
          __pyx_t_7 = 0;

          /* "cassandra/connection.py":989
 *                 try:
 *                     timer = queue[0][1]
 *                     if timer.finish(now):             # <<<<<<<<<<<<<<
 *                         heappop(queue)
 *                     else:
 */
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_timer, __pyx_n_s_finish); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 989; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = NULL;
          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
            if (likely(__pyx_t_3)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_1, function);
            }
          }
          if (!__pyx_t_3) {
            __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_now); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 989; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
            __Pyx_GOTREF(__pyx_t_7);
          } else {
            __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 989; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
            __Pyx_INCREF(__pyx_v_now);
            __Pyx_GIVEREF(__pyx_v_now);
            PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_now);
            __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 989; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 989; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (__pyx_t_2) {

            /* "cassandra/connection.py":990
 *                     timer = queue[0][1]
 *                     if timer.finish(now):
 *                         heappop(queue)             # <<<<<<<<<<<<<<
 *                     else:
 *                         return timer.end
 */
            __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_heappop); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_4 = NULL;
            if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
              if (likely(__pyx_t_4)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_1, function);
              }
            }
            if (!__pyx_t_4) {
              __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_queue); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
              __Pyx_GOTREF(__pyx_t_7);
            } else {
              __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
              __Pyx_INCREF(__pyx_v_queue);
              __Pyx_GIVEREF(__pyx_v_queue);
              PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_queue);
              __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            }
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            goto __pyx_L17;
          }
          /*else*/ {

            /* "cassandra/connection.py":992
 *                         heappop(queue)
 *                     else:
 *                         return timer.end             # <<<<<<<<<<<<<<
 *                 except Exception:
 *                     log.exception("Exception while servicing timeout callback: ")
 */
            __Pyx_XDECREF(__pyx_r);
            __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_timer, __pyx_n_s_end); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L9_error;}
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_r = __pyx_t_7;
            __pyx_t_7 = 0;
            goto __pyx_L13_try_return;
          }
          __pyx_L17:;
        }
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L16_try_end;
        __pyx_L9_error:;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "cassandra/connection.py":993
 *                     else:
 *                         return timer.end
 *                 except Exception:             # <<<<<<<<<<<<<<
 *                     log.exception("Exception while servicing timeout callback: ")
 * 
 */
        __pyx_t_11 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
        if (__pyx_t_11) {
          __Pyx_AddTraceback("cassandra.connection.TimerManager.service_timeouts", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_1, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L11_except_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_3);

          /* "cassandra/connection.py":994
 *                         return timer.end
 *                 except Exception:
 *                     log.exception("Exception while servicing timeout callback: ")             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
          __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L11_except_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_exception); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L11_except_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L11_except_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          goto __pyx_L10_exception_handled;
        }
        goto __pyx_L11_except_error;
        __pyx_L11_except_error:;
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        goto __pyx_L1_error;
        __pyx_L13_try_return:;
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        goto __pyx_L0;
        __pyx_L10_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        __pyx_L16_try_end:;
      }
    }
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "cassandra/connection.py":972
 *         self._new_timers.append((timer.end, timer))
 * 
 *     def service_timeouts(self):             # <<<<<<<<<<<<<<
 *         """
 *         run callbacks on all expired timers
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("cassandra.connection.TimerManager.service_timeouts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_queue);
  __Pyx_XDECREF(__pyx_v_new_timers);
  __Pyx_XDECREF(__pyx_v_now);
  __Pyx_XDECREF(__pyx_v_timer);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "cassandra/connection.py":997
 * 
 *     @property
 *     def next_timeout(self):             # <<<<<<<<<<<<<<
 *         try:
 *             return self._queue[0][0]
 */

/* Python wrapper */
static PyObject *__pyx_pw_9cassandra_10connection_12TimerManager_7next_timeout(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_9cassandra_10connection_12TimerManager_7next_timeout = {"next_timeout", (PyCFunction)__pyx_pw_9cassandra_10connection_12TimerManager_7next_timeout, METH_O, 0};
static PyObject *__pyx_pw_9cassandra_10connection_12TimerManager_7next_timeout(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("next_timeout (wrapper)", 0);
  __pyx_r = __pyx_pf_9cassandra_10connection_12TimerManager_6next_timeout(__pyx_self, ((PyObject *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_9cassandra_10connection_12TimerManager_6next_timeout(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("next_timeout", 0);

  /* "cassandra/connection.py":998
 *     @property
 *     def next_timeout(self):
 *         try:             # <<<<<<<<<<<<<<
 *             return self._queue[0][0]
 *         except IndexError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "cassandra/connection.py":999
 *     def next_timeout(self):
 *         try:
 *             return self._queue[0][0]             # <<<<<<<<<<<<<<
 *         except IndexError:
 *             pass
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_queue); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L3_error;};
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L7_try_return;
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "cassandra/connection.py":1000
 *         try:
 *             return self._queue[0][0]
 *         except IndexError:             # <<<<<<<<<<<<<<
 *             pass
 */
    __pyx_t_6 = PyErr_ExceptionMatches(__pyx_builtin_IndexError);
    if (__pyx_t_6) {
      PyErr_Restore(0,0,0);
      goto __pyx_L4_exception_handled;
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  }

  /* "cassandra/connection.py":997
 * 
 *     @property
 *     def next_timeout(self):             # <<<<<<<<<<<<<<
 *         try:
 *             return self._queue[0][0]
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("cassandra.connection.TimerManager.next_timeout", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error *__pyx_freelist_9cassandra_10connection___pyx_scope_struct__defunct_on_error[8];
static int __pyx_freecount_9cassandra_10connection___pyx_scope_struct__defunct_on_error = 0;

static PyObject *__pyx_tp_new_9cassandra_10connection___pyx_scope_struct__defunct_on_error(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9cassandra_10connection___pyx_scope_struct__defunct_on_error > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error)))) {
    o = (PyObject*)__pyx_freelist_9cassandra_10connection___pyx_scope_struct__defunct_on_error[--__pyx_freecount_9cassandra_10connection___pyx_scope_struct__defunct_on_error];
    memset(o, 0, sizeof(struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9cassandra_10connection___pyx_scope_struct__defunct_on_error(PyObject *o) {
  struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error *p = (struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_f);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9cassandra_10connection___pyx_scope_struct__defunct_on_error < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error)))) {
    __pyx_freelist_9cassandra_10connection___pyx_scope_struct__defunct_on_error[__pyx_freecount_9cassandra_10connection___pyx_scope_struct__defunct_on_error++] = ((struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9cassandra_10connection___pyx_scope_struct__defunct_on_error(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error *p = (struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error *)o;
  if (p->__pyx_v_f) {
    e = (*v)(p->__pyx_v_f, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9cassandra_10connection___pyx_scope_struct__defunct_on_error(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error *p = (struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error *)o;
  tmp = ((PyObject*)p->__pyx_v_f);
  p->__pyx_v_f = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_9cassandra_10connection___pyx_scope_struct__defunct_on_error = {
  PyVarObject_HEAD_INIT(0, 0)
  "cassandra.connection.__pyx_scope_struct__defunct_on_error", /*tp_name*/
  sizeof(struct __pyx_obj_9cassandra_10connection___pyx_scope_struct__defunct_on_error), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9cassandra_10connection___pyx_scope_struct__defunct_on_error, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9cassandra_10connection___pyx_scope_struct__defunct_on_error, /*tp_traverse*/
  __pyx_tp_clear_9cassandra_10connection___pyx_scope_struct__defunct_on_error, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9cassandra_10connection___pyx_scope_struct__defunct_on_error, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async *__pyx_freelist_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async[8];
static int __pyx_freecount_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async = 0;

static PyObject *__pyx_tp_new_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async)))) {
    o = (PyObject*)__pyx_freelist_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async[--__pyx_freecount_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async];
    memset(o, 0, sizeof(struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async(PyObject *o) {
  struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async *p = (struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_callback);
  Py_CLEAR(p->__pyx_v_keyspace);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async)))) {
    __pyx_freelist_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async[__pyx_freecount_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async++] = ((struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async *p = (struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async *)o;
  if (p->__pyx_v_callback) {
    e = (*v)(p->__pyx_v_callback, a); if (e) return e;
  }
  if (p->__pyx_v_keyspace) {
    e = (*v)(p->__pyx_v_keyspace, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async *p = (struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async *)o;
  tmp = ((PyObject*)p->__pyx_v_callback);
  p->__pyx_v_callback = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_keyspace);
  p->__pyx_v_keyspace = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async = {
  PyVarObject_HEAD_INIT(0, 0)
  "cassandra.connection.__pyx_scope_struct_1_set_keyspace_async", /*tp_name*/
  sizeof(struct __pyx_obj_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async, /*tp_traverse*/
  __pyx_tp_clear_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
  #if PY_VERSION_HEX < 0x03020000
    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  #else
    PyModuleDef_HEAD_INIT,
  #endif
    "connection",
    0, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_127_0_0_1, __pyx_k_127_0_0_1, sizeof(__pyx_k_127_0_0_1), 0, 0, 1, 0},
  {&__pyx_kp_s_3_0_0, __pyx_k_3_0_0, sizeof(__pyx_k_3_0_0), 0, 0, 1, 0},
  {&__pyx_n_s_AF_UNSPEC, __pyx_k_AF_UNSPEC, sizeof(__pyx_k_AF_UNSPEC), 0, 0, 1, 1},
  {&__pyx_kp_s_An_attempt_was_made_to_send_a_m, __pyx_k_An_attempt_was_made_to_send_a_m, sizeof(__pyx_k_An_attempt_was_made_to_send_a_m), 0, 0, 1, 0},
  {&__pyx_kp_s_An_unrecoverable_error_was_hit, __pyx_k_An_unrecoverable_error_was_hit, sizeof(__pyx_k_An_unrecoverable_error_was_hit), 0, 0, 1, 0},
  {&__pyx_n_s_AuthChallengeMessage, __pyx_k_AuthChallengeMessage, sizeof(__pyx_k_AuthChallengeMessage), 0, 0, 1, 1},
  {&__pyx_n_s_AuthResponseMessage, __pyx_k_AuthResponseMessage, sizeof(__pyx_k_AuthResponseMessage), 0, 0, 1, 1},
  {&__pyx_n_s_AuthSuccessMessage, __pyx_k_AuthSuccessMessage, sizeof(__pyx_k_AuthSuccessMessage), 0, 0, 1, 1},
  {&__pyx_n_s_AuthenticateMessage, __pyx_k_AuthenticateMessage, sizeof(__pyx_k_AuthenticateMessage), 0, 0, 1, 1},
  {&__pyx_n_s_AuthenticationFailed, __pyx_k_AuthenticationFailed, sizeof(__pyx_k_AuthenticationFailed), 0, 0, 1, 1},
  {&__pyx_kp_s_BbBi, __pyx_k_BbBi, sizeof(__pyx_k_BbBi), 0, 0, 1, 0},
  {&__pyx_kp_s_BhBi, __pyx_k_BhBi, sizeof(__pyx_k_BhBi), 0, 0, 1, 0},
  {&__pyx_n_s_BytesIO, __pyx_k_BytesIO, sizeof(__pyx_k_BytesIO), 0, 0, 1, 1},
  {&__pyx_n_s_COMPRESSION, __pyx_k_COMPRESSION, sizeof(__pyx_k_COMPRESSION), 0, 0, 1, 1},
  {&__pyx_kp_s_Callback_handler_errored_ignorin, __pyx_k_Callback_handler_errored_ignorin, sizeof(__pyx_k_Callback_handler_errored_ignorin), 0, 0, 1, 0},
  {&__pyx_kp_s_Closing_connection_s_due_to_prot, __pyx_k_Closing_connection_s_due_to_prot, sizeof(__pyx_k_Closing_connection_s_due_to_prot), 0, 0, 1, 0},
  {&__pyx_kp_s_Communication_did_not_match_the, __pyx_k_Communication_did_not_match_the, sizeof(__pyx_k_Communication_did_not_match_the), 0, 0, 1, 0},
  {&__pyx_n_s_Connection, __pyx_k_Connection, sizeof(__pyx_k_Connection), 0, 0, 1, 1},
  {&__pyx_n_s_ConnectionBusy, __pyx_k_ConnectionBusy, sizeof(__pyx_k_ConnectionBusy), 0, 0, 1, 1},
  {&__pyx_n_s_ConnectionException, __pyx_k_ConnectionException, sizeof(__pyx_k_ConnectionException), 0, 0, 1, 1},
  {&__pyx_n_s_ConnectionException___init, __pyx_k_ConnectionException___init, sizeof(__pyx_k_ConnectionException___init), 0, 0, 1, 1},
  {&__pyx_n_s_ConnectionHeartbeat, __pyx_k_ConnectionHeartbeat, sizeof(__pyx_k_ConnectionHeartbeat), 0, 0, 1, 1},
  {&__pyx_n_s_ConnectionHeartbeat_ShutdownExce, __pyx_k_ConnectionHeartbeat_ShutdownExce, sizeof(__pyx_k_ConnectionHeartbeat_ShutdownExce), 0, 0, 1, 1},
  {&__pyx_n_s_ConnectionHeartbeat___init, __pyx_k_ConnectionHeartbeat___init, sizeof(__pyx_k_ConnectionHeartbeat___init), 0, 0, 1, 1},
  {&__pyx_n_s_ConnectionHeartbeat__raise_if_st, __pyx_k_ConnectionHeartbeat__raise_if_st, sizeof(__pyx_k_ConnectionHeartbeat__raise_if_st), 0, 0, 1, 1},
  {&__pyx_n_s_ConnectionHeartbeat_run, __pyx_k_ConnectionHeartbeat_run, sizeof(__pyx_k_ConnectionHeartbeat_run), 0, 0, 1, 1},
  {&__pyx_n_s_ConnectionHeartbeat_stop, __pyx_k_ConnectionHeartbeat_stop, sizeof(__pyx_k_ConnectionHeartbeat_stop), 0, 0, 1, 1},
  {&__pyx_n_s_ConnectionShutdown, __pyx_k_ConnectionShutdown, sizeof(__pyx_k_ConnectionShutdown), 0, 0, 1, 1},
  {&__pyx_n_s_Connection___init, __pyx_k_Connection___init, sizeof(__pyx_k_Connection___init), 0, 0, 1, 1},
  {&__pyx_n_s_Connection___str, __pyx_k_Connection___str, sizeof(__pyx_k_Connection___str), 0, 0, 1, 1},
  {&__pyx_n_s_Connection__connect_socket, __pyx_k_Connection__connect_socket, sizeof(__pyx_k_Connection__connect_socket), 0, 0, 1, 1},
  {&__pyx_n_s_Connection__handle_auth_response, __pyx_k_Connection__handle_auth_response, sizeof(__pyx_k_Connection__handle_auth_response), 0, 0, 1, 1},
  {&__pyx_n_s_Connection__handle_options_respo, __pyx_k_Connection__handle_options_respo, sizeof(__pyx_k_Connection__handle_options_respo), 0, 0, 1, 1},
  {&__pyx_n_s_Connection__handle_startup_respo, __pyx_k_Connection__handle_startup_respo, sizeof(__pyx_k_Connection__handle_startup_respo), 0, 0, 1, 1},
  {&__pyx_n_s_Connection__read_frame_header, __pyx_k_Connection__read_frame_header, sizeof(__pyx_k_Connection__read_frame_header), 0, 0, 1, 1},
  {&__pyx_n_s_Connection__reset_frame, __pyx_k_Connection__reset_frame, sizeof(__pyx_k_Connection__reset_frame), 0, 0, 1, 1},
  {&__pyx_n_s_Connection__send_options_message, __pyx_k_Connection__send_options_message, sizeof(__pyx_k_Connection__send_options_message), 0, 0, 1, 1},
  {&__pyx_n_s_Connection__send_startup_message, __pyx_k_Connection__send_startup_message, sizeof(__pyx_k_Connection__send_startup_message), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_close, __pyx_k_Connection_close, sizeof(__pyx_k_Connection_close), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_control_conn_disposed, __pyx_k_Connection_control_conn_disposed, sizeof(__pyx_k_Connection_control_conn_disposed), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_create_timer, __pyx_k_Connection_create_timer, sizeof(__pyx_k_Connection_create_timer), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_defunct, __pyx_k_Connection_defunct, sizeof(__pyx_k_Connection_defunct), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_error_all_requests, __pyx_k_Connection_error_all_requests, sizeof(__pyx_k_Connection_error_all_requests), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_factory, __pyx_k_Connection_factory, sizeof(__pyx_k_Connection_factory), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_get_request_id, __pyx_k_Connection_get_request_id, sizeof(__pyx_k_Connection_get_request_id), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_handle_fork, __pyx_k_Connection_handle_fork, sizeof(__pyx_k_Connection_handle_fork), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_handle_pushed, __pyx_k_Connection_handle_pushed, sizeof(__pyx_k_Connection_handle_pushed), 0, 0, 1, 1},
  {&__pyx_kp_s_Connection_heartbeat, __pyx_k_Connection_heartbeat, sizeof(__pyx_k_Connection_heartbeat), 0, 0, 1, 0},
  {&__pyx_kp_s_Connection_heartbeat_failure, __pyx_k_Connection_heartbeat_failure, sizeof(__pyx_k_Connection_heartbeat_failure), 0, 0, 1, 0},
  {&__pyx_n_s_Connection_initialize_reactor, __pyx_k_Connection_initialize_reactor, sizeof(__pyx_k_Connection_initialize_reactor), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_is_idle, __pyx_k_Connection_is_idle, sizeof(__pyx_k_Connection_is_idle), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_process_io_buffer, __pyx_k_Connection_process_io_buffer, sizeof(__pyx_k_Connection_process_io_buffer), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_process_msg, __pyx_k_Connection_process_msg, sizeof(__pyx_k_Connection_process_msg), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_register_watcher, __pyx_k_Connection_register_watcher, sizeof(__pyx_k_Connection_register_watcher), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_register_watchers, __pyx_k_Connection_register_watchers, sizeof(__pyx_k_Connection_register_watchers), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_reset_idle, __pyx_k_Connection_reset_idle, sizeof(__pyx_k_Connection_reset_idle), 0, 0, 1, 1},
  {&__pyx_kp_s_Connection_s_is_already_closed, __pyx_k_Connection_s_is_already_closed, sizeof(__pyx_k_Connection_s_is_already_closed), 0, 0, 1, 0},
  {&__pyx_kp_s_Connection_s_successfully_authen, __pyx_k_Connection_s_successfully_authen, sizeof(__pyx_k_Connection_s_successfully_authen), 0, 0, 1, 0},
  {&__pyx_n_s_Connection_send_msg, __pyx_k_Connection_send_msg, sizeof(__pyx_k_Connection_send_msg), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_set_keyspace_async, __pyx_k_Connection_set_keyspace_async, sizeof(__pyx_k_Connection_set_keyspace_async), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_set_keyspace_async_lo, __pyx_k_Connection_set_keyspace_async_lo, sizeof(__pyx_k_Connection_set_keyspace_async_lo), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_set_keyspace_blocking, __pyx_k_Connection_set_keyspace_blocking, sizeof(__pyx_k_Connection_set_keyspace_blocking), 0, 0, 1, 1},
  {&__pyx_kp_s_Connection_to_s_is_closed, __pyx_k_Connection_to_s_is_closed, sizeof(__pyx_k_Connection_to_s_is_closed), 0, 0, 1, 0},
  {&__pyx_kp_s_Connection_to_s_is_defunct, __pyx_k_Connection_to_s_is_defunct, sizeof(__pyx_k_Connection_to_s_is_defunct), 0, 0, 1, 0},
  {&__pyx_kp_s_Connection_to_s_was_closed_durin, __pyx_k_Connection_to_s_was_closed_durin, sizeof(__pyx_k_Connection_to_s_was_closed_durin), 0, 0, 1, 0},
  {&__pyx_kp_s_Connection_to_s_was_closed_durin_2, __pyx_k_Connection_to_s_was_closed_durin_2, sizeof(__pyx_k_Connection_to_s_was_closed_durin_2), 0, 0, 1, 0},
  {&__pyx_n_s_Connection_wait_for_response, __pyx_k_Connection_wait_for_response, sizeof(__pyx_k_Connection_wait_for_response), 0, 0, 1, 1},
  {&__pyx_n_s_Connection_wait_for_responses, __pyx_k_Connection_wait_for_responses, sizeof(__pyx_k_Connection_wait_for_responses), 0, 0, 1, 1},
  {&__pyx_n_s_ConsistencyLevel, __pyx_k_ConsistencyLevel, sizeof(__pyx_k_ConsistencyLevel), 0, 0, 1, 1},
  {&__pyx_n_s_CredentialsMessage, __pyx_k_CredentialsMessage, sizeof(__pyx_k_CredentialsMessage), 0, 0, 1, 1},
  {&__pyx_n_s_DEFAULT_CQL_VERSION, __pyx_k_DEFAULT_CQL_VERSION, sizeof(__pyx_k_DEFAULT_CQL_VERSION), 0, 0, 1, 1},
  {&__pyx_kp_s_Defuncting_connection_s_to_s, __pyx_k_Defuncting_connection_s_to_s, sizeof(__pyx_k_Defuncting_connection_s_to_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Did_not_get_expected_SupportedMe, __pyx_k_Did_not_get_expected_SupportedMe, sizeof(__pyx_k_Did_not_get_expected_SupportedMe), 0, 0, 1, 0},
  {&__pyx_n_s_EAGAIN, __pyx_k_EAGAIN, sizeof(__pyx_k_EAGAIN), 0, 0, 1, 1},
  {&__pyx_n_s_EWOULDBLOCK, __pyx_k_EWOULDBLOCK, sizeof(__pyx_k_EWOULDBLOCK), 0, 0, 1, 1},
  {&__pyx_n_s_Empty, __pyx_k_Empty, sizeof(__pyx_k_Empty), 0, 0, 1, 1},
  {&__pyx_n_s_ErrorMessage, __pyx_k_ErrorMessage, sizeof(__pyx_k_ErrorMessage), 0, 0, 1, 1},
  {&__pyx_kp_s_Error_decoding_response_from_Cas, __pyx_k_Error_decoding_response_from_Cas, sizeof(__pyx_k_Error_decoding_response_from_Cas), 0, 0, 1, 0},
  {&__pyx_n_s_Event, __pyx_k_Event, sizeof(__pyx_k_Event), 0, 0, 1, 1},
  {&__pyx_n_s_Exception, __pyx_k_Exception, sizeof(__pyx_k_Exception), 0, 0, 1, 1},
  {&__pyx_kp_s_Exception_while_servicing_timeou, __pyx_k_Exception_while_servicing_timeou, sizeof(__pyx_k_Exception_while_servicing_timeou), 0, 0, 1, 0},
  {&__pyx_kp_s_Failed_connection_heartbeat, __pyx_k_Failed_connection_heartbeat, sizeof(__pyx_k_Failed_connection_heartbeat), 0, 0, 1, 0},
  {&__pyx_kp_s_Failed_sending_heartbeat_message, __pyx_k_Failed_sending_heartbeat_message, sizeof(__pyx_k_Failed_sending_heartbeat_message), 0, 0, 1, 0},
  {&__pyx_kp_s_Failed_to_authenticate_to_s_s, __pyx_k_Failed_to_authenticate_to_s_s, sizeof(__pyx_k_Failed_to_authenticate_to_s_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Failed_to_initialize_new_connect, __pyx_k_Failed_to_initialize_new_connect, sizeof(__pyx_k_Failed_to_initialize_new_connect), 0, 0, 1, 0},
  {&__pyx_kp_s_Failed_to_send_heartbeat_because, __pyx_k_Failed_to_send_heartbeat_because, sizeof(__pyx_k_Failed_to_send_heartbeat_because), 0, 0, 1, 0},
  {&__pyx_n_s_Frame, __pyx_k_Frame, sizeof(__pyx_k_Frame), 0, 0, 1, 1},
  {&__pyx_n_s_Frame_2, __pyx_k_Frame_2, sizeof(__pyx_k_Frame_2), 0, 0, 1, 1},
  {&__pyx_kp_s_Got_AuthenticateMessage_on_new_c, __pyx_k_Got_AuthenticateMessage_on_new_c, sizeof(__pyx_k_Got_AuthenticateMessage_on_new_c), 0, 0, 1, 0},
  {&__pyx_kp_s_Got_ReadyMessage_on_new_connecti, __pyx_k_Got_ReadyMessage_on_new_connecti, sizeof(__pyx_k_Got_ReadyMessage_on_new_connecti), 0, 0, 1, 0},
  {&__pyx_n_s_HEADER_DIRECTION_FROM_CLIENT, __pyx_k_HEADER_DIRECTION_FROM_CLIENT, sizeof(__pyx_k_HEADER_DIRECTION_FROM_CLIENT), 0, 0, 1, 1},
  {&__pyx_n_s_HEADER_DIRECTION_MASK, __pyx_k_HEADER_DIRECTION_MASK, sizeof(__pyx_k_HEADER_DIRECTION_MASK), 0, 0, 1, 1},
  {&__pyx_n_s_HEADER_DIRECTION_TO_CLIENT, __pyx_k_HEADER_DIRECTION_TO_CLIENT, sizeof(__pyx_k_HEADER_DIRECTION_TO_CLIENT), 0, 0, 1, 1},
  {&__pyx_n_s_HeartbeatFuture, __pyx_k_HeartbeatFuture, sizeof(__pyx_k_HeartbeatFuture), 0, 0, 1, 1},
  {&__pyx_n_s_HeartbeatFuture___init, __pyx_k_HeartbeatFuture___init, sizeof(__pyx_k_HeartbeatFuture___init), 0, 0, 1, 1},
  {&__pyx_n_s_HeartbeatFuture__options_callbac, __pyx_k_HeartbeatFuture__options_callbac, sizeof(__pyx_k_HeartbeatFuture__options_callbac), 0, 0, 1, 1},
  {&__pyx_n_s_HeartbeatFuture_wait, __pyx_k_HeartbeatFuture_wait, sizeof(__pyx_k_HeartbeatFuture_wait), 0, 0, 1, 1},
  {&__pyx_kp_s_Heartbeat_failed_for_connection, __pyx_k_Heartbeat_failed_for_connection, sizeof(__pyx_k_Heartbeat_failed_for_connection), 0, 0, 1, 0},
  {&__pyx_kp_s_Ignoring_unhandled_exception_whi, __pyx_k_Ignoring_unhandled_exception_whi, sizeof(__pyx_k_Ignoring_unhandled_exception_whi), 0, 0, 1, 0},
  {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
  {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
  {&__pyx_n_s_InvalidRequestException, __pyx_k_InvalidRequestException, sizeof(__pyx_k_InvalidRequestException), 0, 0, 1, 1},
  {&__pyx_n_s_MAX_SUPPORTED_VERSION, __pyx_k_MAX_SUPPORTED_VERSION, sizeof(__pyx_k_MAX_SUPPORTED_VERSION), 0, 0, 1, 1},
  {&__pyx_kp_s_Message_pushed_from_server_r, __pyx_k_Message_pushed_from_server_r, sizeof(__pyx_k_Message_pushed_from_server_r), 0, 0, 1, 0},
  {&__pyx_n_s_NONBLOCKING, __pyx_k_NONBLOCKING, sizeof(__pyx_k_NONBLOCKING), 0, 0, 1, 1},
  {&__pyx_kp_s_No_available_compression_types_s, __pyx_k_No_available_compression_types_s, sizeof(__pyx_k_No_available_compression_types_s), 0, 0, 1, 0},
  {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1},
  {&__pyx_kp_s_Not_sending_options_message_for, __pyx_k_Not_sending_options_message_for, sizeof(__pyx_k_Not_sending_options_message_for), 0, 0, 1, 0},
  {&__pyx_n_s_ONE, __pyx_k_ONE, sizeof(__pyx_k_ONE), 0, 0, 1, 1},
  {&__pyx_n_s_OperationTimedOut, __pyx_k_OperationTimedOut, sizeof(__pyx_k_OperationTimedOut), 0, 0, 1, 1},
  {&__pyx_n_s_OptionsMessage, __pyx_k_OptionsMessage, sizeof(__pyx_k_OptionsMessage), 0, 0, 1, 1},
  {&__pyx_n_s_OrderedDict, __pyx_k_OrderedDict, sizeof(__pyx_k_OrderedDict), 0, 0, 1, 1},
  {&__pyx_n_s_PROTOCOL_VERSION_MASK, __pyx_k_PROTOCOL_VERSION_MASK, sizeof(__pyx_k_PROTOCOL_VERSION_MASK), 0, 0, 1, 1},
  {&__pyx_kp_s_Problem_while_setting_keyspace_r, __pyx_k_Problem_while_setting_keyspace_r, sizeof(__pyx_k_Problem_while_setting_keyspace_r), 0, 0, 1, 0},
  {&__pyx_n_s_ProtocolError, __pyx_k_ProtocolError, sizeof(__pyx_k_ProtocolError), 0, 0, 1, 1},
  {&__pyx_n_s_ProtocolException, __pyx_k_ProtocolException, sizeof(__pyx_k_ProtocolException), 0, 0, 1, 1},
  {&__pyx_n_s_ProtocolHandler, __pyx_k_ProtocolHandler, sizeof(__pyx_k_ProtocolHandler), 0, 0, 1, 1},
  {&__pyx_n_s_ProtocolVersionUnsupported, __pyx_k_ProtocolVersionUnsupported, sizeof(__pyx_k_ProtocolVersionUnsupported), 0, 0, 1, 1},
  {&__pyx_n_s_ProtocolVersionUnsupported___ini, __pyx_k_ProtocolVersionUnsupported___ini, sizeof(__pyx_k_ProtocolVersionUnsupported___ini), 0, 0, 1, 1},
  {&__pyx_kp_s_Pushed_event_handler_errored_ign, __pyx_k_Pushed_event_handler_errored_ign, sizeof(__pyx_k_Pushed_event_handler_errored_ign), 0, 0, 1, 0},
  {&__pyx_n_s_QueryMessage, __pyx_k_QueryMessage, sizeof(__pyx_k_QueryMessage), 0, 0, 1, 1},
  {&__pyx_n_s_Queue, __pyx_k_Queue, sizeof(__pyx_k_Queue), 0, 0, 1, 1},
  {&__pyx_n_s_RLock, __pyx_k_RLock, sizeof(__pyx_k_RLock), 0, 0, 1, 1},
  {&__pyx_kp_s_Raised_when_a_connection_has_be, __pyx_k_Raised_when_a_connection_has_be, sizeof(__pyx_k_Raised_when_a_connection_has_be), 0, 0, 1, 0},
  {&__pyx_n_s_ReadyMessage, __pyx_k_ReadyMessage, sizeof(__pyx_k_ReadyMessage), 0, 0, 1, 1},
  {&__pyx_kp_s_Received_ErrorMessage_on_new_con, __pyx_k_Received_ErrorMessage_on_new_con, sizeof(__pyx_k_Received_ErrorMessage_on_new_con), 0, 0, 1, 0},
  {&__pyx_kp_s_Received_negative_body_length_r, __pyx_k_Received_negative_body_length_r, sizeof(__pyx_k_Received_negative_body_length_r), 0, 0, 1, 0},
  {&__pyx_kp_s_Received_options_response_on_con, __pyx_k_Received_options_response_on_con, sizeof(__pyx_k_Received_options_response_on_con), 0, 0, 1, 0},
  {&__pyx_kp_s_Received_options_response_on_new, __pyx_k_Received_options_response_on_new, sizeof(__pyx_k_Received_options_response_on_new), 0, 0, 1, 0},
  {&__pyx_kp_s_Received_unexpected_response_to, __pyx_k_Received_unexpected_response_to, sizeof(__pyx_k_Received_unexpected_response_to), 0, 0, 1, 0},
  {&__pyx_n_s_RegisterMessage, __pyx_k_RegisterMessage, sizeof(__pyx_k_RegisterMessage), 0, 0, 1, 1},
  {&__pyx_kp_s_Remote_end_requires_authenticati, __pyx_k_Remote_end_requires_authenticati, sizeof(__pyx_k_Remote_end_requires_authenticati), 0, 0, 1, 0},
  {&__pyx_kp_s_Responding_to_auth_challenge_on, __pyx_k_Responding_to_auth_challenge_on, sizeof(__pyx_k_Responding_to_auth_challenge_on), 0, 0, 1, 0},
  {&__pyx_n_s_ResponseWaiter, __pyx_k_ResponseWaiter, sizeof(__pyx_k_ResponseWaiter), 0, 0, 1, 1},
  {&__pyx_n_s_ResponseWaiter___init, __pyx_k_ResponseWaiter___init, sizeof(__pyx_k_ResponseWaiter___init), 0, 0, 1, 1},
  {&__pyx_n_s_ResponseWaiter_deliver, __pyx_k_ResponseWaiter_deliver, sizeof(__pyx_k_ResponseWaiter_deliver), 0, 0, 1, 1},
  {&__pyx_n_s_ResponseWaiter_got_response, __pyx_k_ResponseWaiter_got_response, sizeof(__pyx_k_ResponseWaiter_got_response), 0, 0, 1, 1},
  {&__pyx_n_s_ResultMessage, __pyx_k_ResultMessage, sizeof(__pyx_k_ResultMessage), 0, 0, 1, 1},
  {&__pyx_n_s_SOCK_STREAM, __pyx_k_SOCK_STREAM, sizeof(__pyx_k_SOCK_STREAM), 0, 0, 1, 1},
  {&__pyx_kp_s_Sending_SASL_based_auth_response, __pyx_k_Sending_SASL_based_auth_response, sizeof(__pyx_k_Sending_SASL_based_auth_response), 0, 0, 1, 0},
  {&__pyx_kp_s_Sending_StartupMessage_on_s, __pyx_k_Sending_StartupMessage_on_s, sizeof(__pyx_k_Sending_StartupMessage_on_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Sending_credentials_based_auth_r, __pyx_k_Sending_credentials_based_auth_r, sizeof(__pyx_k_Sending_credentials_based_auth_r), 0, 0, 1, 0},
  {&__pyx_kp_s_Sending_initial_options_message, __pyx_k_Sending_initial_options_message, sizeof(__pyx_k_Sending_initial_options_message), 0, 0, 1, 0},
  {&__pyx_kp_s_Sending_options_message_heartbea, __pyx_k_Sending_options_message_heartbea, sizeof(__pyx_k_Sending_options_message_heartbea), 0, 0, 1, 0},
  {&__pyx_kp_s_Sent_StartupMessage_on_s, __pyx_k_Sent_StartupMessage_on_s, sizeof(__pyx_k_Sent_StartupMessage_on_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Server_rejected_startup_message, __pyx_k_Server_rejected_startup_message, sizeof(__pyx_k_Server_rejected_startup_message), 0, 0, 1, 0},
  {&__pyx_n_s_ShutdownException, __pyx_k_ShutdownException, sizeof(__pyx_k_ShutdownException), 0, 0, 1, 1},
  {&__pyx_n_s_StartupMessage, __pyx_k_StartupMessage, sizeof(__pyx_k_StartupMessage), 0, 0, 1, 1},
  {&__pyx_n_s_Struct, __pyx_k_Struct, sizeof(__pyx_k_Struct), 0, 0, 1, 1},
  {&__pyx_n_s_SupportedMessage, __pyx_k_SupportedMessage, sizeof(__pyx_k_SupportedMessage), 0, 0, 1, 1},
  {&__pyx_kp_s_The_requested_compression_type_s, __pyx_k_The_requested_compression_type_s, sizeof(__pyx_k_The_requested_compression_type_s), 0, 0, 1, 0},
  {&__pyx_kp_s_This_version_of_Python_was_not_c, __pyx_k_This_version_of_Python_was_not_c, sizeof(__pyx_k_This_version_of_Python_was_not_c), 0, 0, 1, 0},
  {&__pyx_kp_s_This_version_of_the_driver_does, __pyx_k_This_version_of_the_driver_does, sizeof(__pyx_k_This_version_of_the_driver_does), 0, 0, 1, 0},
  {&__pyx_n_s_Thread, __pyx_k_Thread, sizeof(__pyx_k_Thread), 0, 0, 1, 1},
  {&__pyx_kp_s_Timed_out_creating_connection_s, __pyx_k_Timed_out_creating_connection_s, sizeof(__pyx_k_Timed_out_creating_connection_s), 0, 0, 1, 0},
  {&__pyx_n_s_Timer, __pyx_k_Timer, sizeof(__pyx_k_Timer), 0, 0, 1, 1},
  {&__pyx_n_s_TimerManager, __pyx_k_TimerManager, sizeof(__pyx_k_TimerManager), 0, 0, 1, 1},
  {&__pyx_n_s_TimerManager___init, __pyx_k_TimerManager___init, sizeof(__pyx_k_TimerManager___init), 0, 0, 1, 1},
  {&__pyx_n_s_TimerManager_add_timer, __pyx_k_TimerManager_add_timer, sizeof(__pyx_k_TimerManager_add_timer), 0, 0, 1, 1},
  {&__pyx_n_s_TimerManager_next_timeout, __pyx_k_TimerManager_next_timeout, sizeof(__pyx_k_TimerManager_next_timeout), 0, 0, 1, 1},
  {&__pyx_n_s_TimerManager_service_timeouts, __pyx_k_TimerManager_service_timeouts, sizeof(__pyx_k_TimerManager_service_timeouts), 0, 0, 1, 1},
  {&__pyx_n_s_Timer___init, __pyx_k_Timer___init, sizeof(__pyx_k_Timer___init), 0, 0, 1, 1},
  {&__pyx_n_s_Timer_cancel, __pyx_k_Timer_cancel, sizeof(__pyx_k_Timer_cancel), 0, 0, 1, 1},
  {&__pyx_n_s_Timer_finish, __pyx_k_Timer_finish, sizeof(__pyx_k_Timer_finish), 0, 0, 1, 1},
  {&__pyx_kp_s_Tried_connecting_to_s_Last_error, __pyx_k_Tried_connecting_to_s_Last_error, sizeof(__pyx_k_Tried_connecting_to_s_Last_error), 0, 0, 1, 0},
  {&__pyx_kp_s_USE_s, __pyx_k_USE_s, sizeof(__pyx_k_USE_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Unexpected_response_during_Conne, __pyx_k_Unexpected_response_during_Conne, sizeof(__pyx_k_Unexpected_response_during_Conne), 0, 0, 1, 0},
  {&__pyx_kp_s_Unexpected_response_during_Conne_2, __pyx_k_Unexpected_response_during_Conne_2, sizeof(__pyx_k_Unexpected_response_during_Conne_2), 0, 0, 1, 0},
  {&__pyx_kp_s_Unsupported_protocol_version_on, __pyx_k_Unsupported_protocol_version_on, sizeof(__pyx_k_Unsupported_protocol_version_on), 0, 0, 1, 0},
  {&__pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_k_Users_adamholmberg_git_python_m, sizeof(__pyx_k_Users_adamholmberg_git_python_m), 0, 0, 1, 0},
  {&__pyx_kp_s__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 0, 1, 0},
  {&__pyx_kp_s__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 0, 1, 0},
  {&__pyx_n_s__67, __pyx_k__67, sizeof(__pyx_k__67), 0, 0, 1, 1},
  {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
  {&__pyx_n_s_add, __pyx_k_add, sizeof(__pyx_k_add), 0, 0, 1, 1},
  {&__pyx_n_s_add_timer, __pyx_k_add_timer, sizeof(__pyx_k_add_timer), 0, 0, 1, 1},
  {&__pyx_n_s_addresses, __pyx_k_addresses, sizeof(__pyx_k_addresses), 0, 0, 1, 1},
  {&__pyx_n_s_af, __pyx_k_af, sizeof(__pyx_k_af), 0, 0, 1, 1},
  {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  {&__pyx_n_s_auth_response, __pyx_k_auth_response, sizeof(__pyx_k_auth_response), 0, 0, 1, 1},
  {&__pyx_n_s_authenticator, __pyx_k_authenticator, sizeof(__pyx_k_authenticator), 0, 0, 1, 1},
  {&__pyx_n_s_authenticator_class, __pyx_k_authenticator_class, sizeof(__pyx_k_authenticator_class), 0, 0, 1, 1},
  {&__pyx_n_s_available, __pyx_k_available, sizeof(__pyx_k_available), 0, 0, 1, 1},
  {&__pyx_n_s_body, __pyx_k_body, sizeof(__pyx_k_body), 0, 0, 1, 1},
  {&__pyx_n_s_body_len, __pyx_k_body_len, sizeof(__pyx_k_body_len), 0, 0, 1, 1},
  {&__pyx_n_s_body_offset, __pyx_k_body_offset, sizeof(__pyx_k_body_offset), 0, 0, 1, 1},
  {&__pyx_n_s_buf, __pyx_k_buf, sizeof(__pyx_k_buf), 0, 0, 1, 1},
  {&__pyx_n_s_byts, __pyx_k_byts, sizeof(__pyx_k_byts), 0, 0, 1, 1},
  {&__pyx_n_s_callback, __pyx_k_callback, sizeof(__pyx_k_callback), 0, 0, 1, 1},
  {&__pyx_n_s_cancel, __pyx_k_cancel, sizeof(__pyx_k_cancel), 0, 0, 1, 1},
  {&__pyx_n_s_canceled, __pyx_k_canceled, sizeof(__pyx_k_canceled), 0, 0, 1, 1},
  {&__pyx_n_s_canonname, __pyx_k_canonname, sizeof(__pyx_k_canonname), 0, 0, 1, 1},
  {&__pyx_n_s_cassandra, __pyx_k_cassandra, sizeof(__pyx_k_cassandra), 0, 0, 1, 1},
  {&__pyx_n_s_cassandra_connection, __pyx_k_cassandra_connection, sizeof(__pyx_k_cassandra_connection), 0, 0, 1, 1},
  {&__pyx_n_s_cassandra_marshal, __pyx_k_cassandra_marshal, sizeof(__pyx_k_cassandra_marshal), 0, 0, 1, 1},
  {&__pyx_n_s_cassandra_protocol, __pyx_k_cassandra_protocol, sizeof(__pyx_k_cassandra_protocol), 0, 0, 1, 1},
  {&__pyx_n_s_cassandra_util, __pyx_k_cassandra_util, sizeof(__pyx_k_cassandra_util), 0, 0, 1, 1},
  {&__pyx_n_s_cb, __pyx_k_cb, sizeof(__pyx_k_cb), 0, 0, 1, 1},
  {&__pyx_n_s_challenge, __pyx_k_challenge, sizeof(__pyx_k_challenge), 0, 0, 1, 1},
  {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
  {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  {&__pyx_kp_s_closed, __pyx_k_closed, sizeof(__pyx_k_closed), 0, 0, 1, 0},
  {&__pyx_n_s_cls, __pyx_k_cls, sizeof(__pyx_k_cls), 0, 0, 1, 1},
  {&__pyx_n_s_cm, __pyx_k_cm, sizeof(__pyx_k_cm), 0, 0, 1, 1},
  {&__pyx_n_s_collections, __pyx_k_collections, sizeof(__pyx_k_collections), 0, 0, 1, 1},
  {&__pyx_n_s_compress, __pyx_k_compress, sizeof(__pyx_k_compress), 0, 0, 1, 1},
  {&__pyx_n_s_compression, __pyx_k_compression, sizeof(__pyx_k_compression), 0, 0, 1, 1},
  {&__pyx_n_s_compression_type, __pyx_k_compression_type, sizeof(__pyx_k_compression_type), 0, 0, 1, 1},
  {&__pyx_n_s_compressor, __pyx_k_compressor, sizeof(__pyx_k_compressor), 0, 0, 1, 1},
  {&__pyx_n_s_compressor_2, __pyx_k_compressor_2, sizeof(__pyx_k_compressor_2), 0, 0, 1, 1},
  {&__pyx_n_s_conn, __pyx_k_conn, sizeof(__pyx_k_conn), 0, 0, 1, 1},
  {&__pyx_n_s_conn_exc, __pyx_k_conn_exc, sizeof(__pyx_k_conn_exc), 0, 0, 1, 1},
  {&__pyx_n_s_connect, __pyx_k_connect, sizeof(__pyx_k_connect), 0, 0, 1, 1},
  {&__pyx_n_s_connect_socket, __pyx_k_connect_socket, sizeof(__pyx_k_connect_socket), 0, 0, 1, 1},
  {&__pyx_n_s_connected_event, __pyx_k_connected_event, sizeof(__pyx_k_connected_event), 0, 0, 1, 1},
  {&__pyx_n_s_connection, __pyx_k_connection, sizeof(__pyx_k_connection), 0, 0, 1, 1},
  {&__pyx_n_s_connections, __pyx_k_connections, sizeof(__pyx_k_connections), 0, 0, 1, 1},
  {&__pyx_n_s_consistency_level, __pyx_k_consistency_level, sizeof(__pyx_k_consistency_level), 0, 0, 1, 1},
  {&__pyx_n_s_control_conn_disposed, __pyx_k_control_conn_disposed, sizeof(__pyx_k_control_conn_disposed), 0, 0, 1, 1},
  {&__pyx_n_s_cql_version, __pyx_k_cql_version, sizeof(__pyx_k_cql_version), 0, 0, 1, 1},
  {&__pyx_kp_s_cql_version_r_is_not_supported_b, __pyx_k_cql_version_r_is_not_supported_b, sizeof(__pyx_k_cql_version_r_is_not_supported_b), 0, 0, 1, 0},
  {&__pyx_n_s_cql_versions, __pyx_k_cql_versions, sizeof(__pyx_k_cql_versions), 0, 0, 1, 1},
  {&__pyx_n_s_cqlversion, __pyx_k_cqlversion, sizeof(__pyx_k_cqlversion), 0, 0, 1, 1},
  {&__pyx_n_s_create_timer, __pyx_k_create_timer, sizeof(__pyx_k_create_timer), 0, 0, 1, 1},
  {&__pyx_n_s_creds, __pyx_k_creds, sizeof(__pyx_k_creds), 0, 0, 1, 1},
  {&__pyx_n_s_current_frame, __pyx_k_current_frame, sizeof(__pyx_k_current_frame), 0, 0, 1, 1},
  {&__pyx_n_s_daemon, __pyx_k_daemon, sizeof(__pyx_k_daemon), 0, 0, 1, 1},
  {&__pyx_n_s_debug, __pyx_k_debug, sizeof(__pyx_k_debug), 0, 0, 1, 1},
  {&__pyx_n_s_decode_message, __pyx_k_decode_message, sizeof(__pyx_k_decode_message), 0, 0, 1, 1},
  {&__pyx_n_s_decoder, __pyx_k_decoder, sizeof(__pyx_k_decoder), 0, 0, 1, 1},
  {&__pyx_n_s_decompress, __pyx_k_decompress, sizeof(__pyx_k_decompress), 0, 0, 1, 1},
  {&__pyx_n_s_decompressor, __pyx_k_decompressor, sizeof(__pyx_k_decompressor), 0, 0, 1, 1},
  {&__pyx_n_s_defaultdict, __pyx_k_defaultdict, sizeof(__pyx_k_defaultdict), 0, 0, 1, 1},
  {&__pyx_n_s_defunct, __pyx_k_defunct, sizeof(__pyx_k_defunct), 0, 0, 1, 1},
  {&__pyx_kp_s_defunct_2, __pyx_k_defunct_2, sizeof(__pyx_k_defunct_2), 0, 0, 1, 0},
  {&__pyx_n_s_defunct_on_error, __pyx_k_defunct_on_error, sizeof(__pyx_k_defunct_on_error), 0, 0, 1, 1},
  {&__pyx_n_s_defunct_on_error_locals_wrapper, __pyx_k_defunct_on_error_locals_wrapper, sizeof(__pyx_k_defunct_on_error_locals_wrapper), 0, 0, 1, 1},
  {&__pyx_n_s_deliver, __pyx_k_deliver, sizeof(__pyx_k_deliver), 0, 0, 1, 1},
  {&__pyx_n_s_deque, __pyx_k_deque, sizeof(__pyx_k_deque), 0, 0, 1, 1},
  {&__pyx_n_s_did_authenticate, __pyx_k_did_authenticate, sizeof(__pyx_k_did_authenticate), 0, 0, 1, 1},
  {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  {&__pyx_n_s_elapsed, __pyx_k_elapsed, sizeof(__pyx_k_elapsed), 0, 0, 1, 1},
  {&__pyx_n_s_encode_message, __pyx_k_encode_message, sizeof(__pyx_k_encode_message), 0, 0, 1, 1},
  {&__pyx_n_s_encoder, __pyx_k_encoder, sizeof(__pyx_k_encoder), 0, 0, 1, 1},
  {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1},
  {&__pyx_n_s_end_pos, __pyx_k_end_pos, sizeof(__pyx_k_end_pos), 0, 0, 1, 1},
  {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
  {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  {&__pyx_n_s_err, __pyx_k_err, sizeof(__pyx_k_err), 0, 0, 1, 1},
  {&__pyx_n_s_errno, __pyx_k_errno, sizeof(__pyx_k_errno), 0, 0, 1, 1},
  {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
  {&__pyx_n_s_error_all_requests, __pyx_k_error_all_requests, sizeof(__pyx_k_error_all_requests), 0, 0, 1, 1},
  {&__pyx_n_s_evaluate_challenge, __pyx_k_evaluate_challenge, sizeof(__pyx_k_evaluate_challenge), 0, 0, 1, 1},
  {&__pyx_n_s_event, __pyx_k_event, sizeof(__pyx_k_event), 0, 0, 1, 1},
  {&__pyx_n_s_event_2, __pyx_k_event_2, sizeof(__pyx_k_event_2), 0, 0, 1, 1},
  {&__pyx_n_s_event_args, __pyx_k_event_args, sizeof(__pyx_k_event_args), 0, 0, 1, 1},
  {&__pyx_n_s_event_list, __pyx_k_event_list, sizeof(__pyx_k_event_list), 0, 0, 1, 1},
  {&__pyx_n_s_event_type, __pyx_k_event_type, sizeof(__pyx_k_event_type), 0, 0, 1, 1},
  {&__pyx_n_s_exc, __pyx_k_exc, sizeof(__pyx_k_exc), 0, 0, 1, 1},
  {&__pyx_n_s_exc_info, __pyx_k_exc_info, sizeof(__pyx_k_exc_info), 0, 0, 1, 1},
  {&__pyx_n_s_exception, __pyx_k_exception, sizeof(__pyx_k_exception), 0, 0, 1, 1},
  {&__pyx_n_s_exception_2, __pyx_k_exception_2, sizeof(__pyx_k_exception_2), 0, 0, 1, 1},
  {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
  {&__pyx_n_s_f, __pyx_k_f, sizeof(__pyx_k_f), 0, 0, 1, 1},
  {&__pyx_n_s_factory, __pyx_k_factory, sizeof(__pyx_k_factory), 0, 0, 1, 1},
  {&__pyx_n_s_fail_on_error, __pyx_k_fail_on_error, sizeof(__pyx_k_fail_on_error), 0, 0, 1, 1},
  {&__pyx_n_s_failed_connections, __pyx_k_failed_connections, sizeof(__pyx_k_failed_connections), 0, 0, 1, 1},
  {&__pyx_n_s_finish, __pyx_k_finish, sizeof(__pyx_k_finish), 0, 0, 1, 1},
  {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
  {&__pyx_n_s_frame, __pyx_k_frame, sizeof(__pyx_k_frame), 0, 0, 1, 1},
  {&__pyx_n_s_frame_header, __pyx_k_frame_header, sizeof(__pyx_k_frame_header), 0, 0, 1, 1},
  {&__pyx_n_s_frame_header_v1_v2, __pyx_k_frame_header_v1_v2, sizeof(__pyx_k_frame_header_v1_v2), 0, 0, 1, 1},
  {&__pyx_n_s_frame_header_v3, __pyx_k_frame_header_v3, sizeof(__pyx_k_frame_header_v3), 0, 0, 1, 1},
  {&__pyx_n_s_functools, __pyx_k_functools, sizeof(__pyx_k_functools), 0, 0, 1, 1},
  {&__pyx_n_s_futures, __pyx_k_futures, sizeof(__pyx_k_futures), 0, 0, 1, 1},
  {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  {&__pyx_n_s_getLogger, __pyx_k_getLogger, sizeof(__pyx_k_getLogger), 0, 0, 1, 1},
  {&__pyx_n_s_get_connection_holders, __pyx_k_get_connection_holders, sizeof(__pyx_k_get_connection_holders), 0, 0, 1, 1},
  {&__pyx_n_s_get_connection_holders_2, __pyx_k_get_connection_holders_2, sizeof(__pyx_k_get_connection_holders_2), 0, 0, 1, 1},
  {&__pyx_n_s_get_connections, __pyx_k_get_connections, sizeof(__pyx_k_get_connections), 0, 0, 1, 1},
  {&__pyx_n_s_get_request_id, __pyx_k_get_request_id, sizeof(__pyx_k_get_request_id), 0, 0, 1, 1},
  {&__pyx_n_s_getaddrinfo, __pyx_k_getaddrinfo, sizeof(__pyx_k_getaddrinfo), 0, 0, 1, 1},
  {&__pyx_kp_s_gevent_monkey, __pyx_k_gevent_monkey, sizeof(__pyx_k_gevent_monkey), 0, 0, 1, 0},
  {&__pyx_n_s_gevent_queue, __pyx_k_gevent_queue, sizeof(__pyx_k_gevent_queue), 0, 0, 1, 1},
  {&__pyx_n_s_got_response, __pyx_k_got_response, sizeof(__pyx_k_got_response), 0, 0, 1, 1},
  {&__pyx_n_s_handle_auth_response, __pyx_k_handle_auth_response, sizeof(__pyx_k_handle_auth_response), 0, 0, 1, 1},
  {&__pyx_n_s_handle_fork, __pyx_k_handle_fork, sizeof(__pyx_k_handle_fork), 0, 0, 1, 1},
  {&__pyx_n_s_handle_options_response, __pyx_k_handle_options_response, sizeof(__pyx_k_handle_options_response), 0, 0, 1, 1},
  {&__pyx_n_s_handle_pushed, __pyx_k_handle_pushed, sizeof(__pyx_k_handle_pushed), 0, 0, 1, 1},
  {&__pyx_n_s_handle_startup_response, __pyx_k_handle_startup_response, sizeof(__pyx_k_handle_startup_response), 0, 0, 1, 1},
  {&__pyx_n_s_header, __pyx_k_header, sizeof(__pyx_k_header), 0, 0, 1, 1},
  {&__pyx_n_s_header_size, __pyx_k_header_size, sizeof(__pyx_k_header_size), 0, 0, 1, 1},
  {&__pyx_n_s_heappop, __pyx_k_heappop, sizeof(__pyx_k_heappop), 0, 0, 1, 1},
  {&__pyx_n_s_heappush, __pyx_k_heappush, sizeof(__pyx_k_heappush), 0, 0, 1, 1},
  {&__pyx_n_s_heapq, __pyx_k_heapq, sizeof(__pyx_k_heapq), 0, 0, 1, 1},
  {&__pyx_n_s_highest_request_id, __pyx_k_highest_request_id, sizeof(__pyx_k_highest_request_id), 0, 0, 1, 1},
  {&__pyx_n_s_host, __pyx_k_host, sizeof(__pyx_k_host), 0, 0, 1, 1},
  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_in_buffer_size, __pyx_k_in_buffer_size, sizeof(__pyx_k_in_buffer_size), 0, 0, 1, 1},
  {&__pyx_n_s_in_flight, __pyx_k_in_flight, sizeof(__pyx_k_in_flight), 0, 0, 1, 1},
  {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1},
  {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
  {&__pyx_n_s_initial_response, __pyx_k_initial_response, sizeof(__pyx_k_initial_response), 0, 0, 1, 1},
  {&__pyx_n_s_initialize_reactor, __pyx_k_initialize_reactor, sizeof(__pyx_k_initialize_reactor), 0, 0, 1, 1},
  {&__pyx_n_s_int32_pack, __pyx_k_int32_pack, sizeof(__pyx_k_int32_pack), 0, 0, 1, 1},
  {&__pyx_n_s_interval, __pyx_k_interval, sizeof(__pyx_k_interval), 0, 0, 1, 1},
  {&__pyx_n_s_interval_sec, __pyx_k_interval_sec, sizeof(__pyx_k_interval_sec), 0, 0, 1, 1},
  {&__pyx_n_s_io, __pyx_k_io, sizeof(__pyx_k_io), 0, 0, 1, 1},
  {&__pyx_n_s_iobuf, __pyx_k_iobuf, sizeof(__pyx_k_iobuf), 0, 0, 1, 1},
  {&__pyx_n_s_ire, __pyx_k_ire, sizeof(__pyx_k_ire), 0, 0, 1, 1},
  {&__pyx_n_s_is_closed, __pyx_k_is_closed, sizeof(__pyx_k_is_closed), 0, 0, 1, 1},
  {&__pyx_n_s_is_control_connection, __pyx_k_is_control_connection, sizeof(__pyx_k_is_control_connection), 0, 0, 1, 1},
  {&__pyx_n_s_is_defunct, __pyx_k_is_defunct, sizeof(__pyx_k_is_defunct), 0, 0, 1, 1},
  {&__pyx_n_s_is_idle, __pyx_k_is_idle, sizeof(__pyx_k_is_idle), 0, 0, 1, 1},
  {&__pyx_n_s_is_set, __pyx_k_is_set, sizeof(__pyx_k_is_set), 0, 0, 1, 1},
  {&__pyx_n_s_is_unsupported_proto_version, __pyx_k_is_unsupported_proto_version, sizeof(__pyx_k_is_unsupported_proto_version), 0, 0, 1, 1},
  {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
  {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
  {&__pyx_n_s_k, __pyx_k_k, sizeof(__pyx_k_k), 0, 0, 1, 1},
  {&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1},
  {&__pyx_n_s_keyspace, __pyx_k_keyspace, sizeof(__pyx_k_keyspace), 0, 0, 1, 1},
  {&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
  {&__pyx_n_s_last_error, __pyx_k_last_error, sizeof(__pyx_k_last_error), 0, 0, 1, 1},
  {&__pyx_n_s_leftover, __pyx_k_leftover, sizeof(__pyx_k_leftover), 0, 0, 1, 1},
  {&__pyx_n_s_locally_supported_compressions, __pyx_k_locally_supported_compressions, sizeof(__pyx_k_locally_supported_compressions), 0, 0, 1, 1},
  {&__pyx_n_s_lock, __pyx_k_lock, sizeof(__pyx_k_lock), 0, 0, 1, 1},
  {&__pyx_n_s_log, __pyx_k_log, sizeof(__pyx_k_log), 0, 0, 1, 1},
  {&__pyx_n_s_logging, __pyx_k_logging, sizeof(__pyx_k_logging), 0, 0, 1, 1},
  {&__pyx_n_s_lz4, __pyx_k_lz4, sizeof(__pyx_k_lz4), 0, 0, 1, 1},
  {&__pyx_n_s_lz4_compress, __pyx_k_lz4_compress, sizeof(__pyx_k_lz4_compress), 0, 0, 1, 1},
  {&__pyx_n_s_lz4_decompress, __pyx_k_lz4_decompress, sizeof(__pyx_k_lz4_decompress), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_max_request_id, __pyx_k_max_request_id, sizeof(__pyx_k_max_request_id), 0, 0, 1, 1},
  {&__pyx_n_s_message, __pyx_k_message, sizeof(__pyx_k_message), 0, 0, 1, 1},
  {&__pyx_n_s_messages_sent, __pyx_k_messages_sent, sizeof(__pyx_k_messages_sent), 0, 0, 1, 1},
  {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  {&__pyx_n_s_modules, __pyx_k_modules, sizeof(__pyx_k_modules), 0, 0, 1, 1},
  {&__pyx_n_s_msg, __pyx_k_msg, sizeof(__pyx_k_msg), 0, 0, 1, 1},
  {&__pyx_n_s_msg_received, __pyx_k_msg_received, sizeof(__pyx_k_msg_received), 0, 0, 1, 1},
  {&__pyx_n_s_msgs, __pyx_k_msgs, sizeof(__pyx_k_msgs), 0, 0, 1, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
  {&__pyx_n_s_namedtuple, __pyx_k_namedtuple, sizeof(__pyx_k_namedtuple), 0, 0, 1, 1},
  {&__pyx_n_s_needed, __pyx_k_needed, sizeof(__pyx_k_needed), 0, 0, 1, 1},
  {&__pyx_n_s_new_exc, __pyx_k_new_exc, sizeof(__pyx_k_new_exc), 0, 0, 1, 1},
  {&__pyx_n_s_new_timers, __pyx_k_new_timers, sizeof(__pyx_k_new_timers), 0, 0, 1, 1},
  {&__pyx_n_s_new_timers_2, __pyx_k_new_timers_2, sizeof(__pyx_k_new_timers_2), 0, 0, 1, 1},
  {&__pyx_n_s_next_timeout, __pyx_k_next_timeout, sizeof(__pyx_k_next_timeout), 0, 0, 1, 1},
  {&__pyx_n_s_now, __pyx_k_now, sizeof(__pyx_k_now), 0, 0, 1, 1},
  {&__pyx_n_s_num_responses, __pyx_k_num_responses, sizeof(__pyx_k_num_responses), 0, 0, 1, 1},
  {&__pyx_n_s_o, __pyx_k_o, sizeof(__pyx_k_o), 0, 0, 1, 1},
  {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
  {&__pyx_n_s_on_authentication_success, __pyx_k_on_authentication_success, sizeof(__pyx_k_on_authentication_success), 0, 0, 1, 1},
  {&__pyx_n_s_op, __pyx_k_op, sizeof(__pyx_k_op), 0, 0, 1, 1},
  {&__pyx_n_s_opcode, __pyx_k_opcode, sizeof(__pyx_k_opcode), 0, 0, 1, 1},
  {&__pyx_n_s_options, __pyx_k_options, sizeof(__pyx_k_options), 0, 0, 1, 1},
  {&__pyx_n_s_options_callback, __pyx_k_options_callback, sizeof(__pyx_k_options_callback), 0, 0, 1, 1},
  {&__pyx_n_s_options_response, __pyx_k_options_response, sizeof(__pyx_k_options_response), 0, 0, 1, 1},
  {&__pyx_n_s_opts, __pyx_k_opts, sizeof(__pyx_k_opts), 0, 0, 1, 1},
  {&__pyx_n_s_out_buffer_size, __pyx_k_out_buffer_size, sizeof(__pyx_k_out_buffer_size), 0, 0, 1, 1},
  {&__pyx_n_s_overlap, __pyx_k_overlap, sizeof(__pyx_k_overlap), 0, 0, 1, 1},
  {&__pyx_n_s_owner, __pyx_k_owner, sizeof(__pyx_k_owner), 0, 0, 1, 1},
  {&__pyx_n_s_partial, __pyx_k_partial, sizeof(__pyx_k_partial), 0, 0, 1, 1},
  {&__pyx_n_s_pending, __pyx_k_pending, sizeof(__pyx_k_pending), 0, 0, 1, 1},
  {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
  {&__pyx_n_s_popleft, __pyx_k_popleft, sizeof(__pyx_k_popleft), 0, 0, 1, 1},
  {&__pyx_n_s_port, __pyx_k_port, sizeof(__pyx_k_port), 0, 0, 1, 1},
  {&__pyx_n_s_pos, __pyx_k_pos, sizeof(__pyx_k_pos), 0, 0, 1, 1},
  {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  {&__pyx_n_s_process_io_buffer, __pyx_k_process_io_buffer, sizeof(__pyx_k_process_io_buffer), 0, 0, 1, 1},
  {&__pyx_n_s_process_msg, __pyx_k_process_msg, sizeof(__pyx_k_process_msg), 0, 0, 1, 1},
  {&__pyx_n_s_process_result, __pyx_k_process_result, sizeof(__pyx_k_process_result), 0, 0, 1, 1},
  {&__pyx_n_s_property, __pyx_k_property, sizeof(__pyx_k_property), 0, 0, 1, 1},
  {&__pyx_n_s_proto, __pyx_k_proto, sizeof(__pyx_k_proto), 0, 0, 1, 1},
  {&__pyx_n_s_protocol_version, __pyx_k_protocol_version, sizeof(__pyx_k_protocol_version), 0, 0, 1, 1},
  {&__pyx_n_s_push, __pyx_k_push, sizeof(__pyx_k_push), 0, 0, 1, 1},
  {&__pyx_n_s_push_watchers, __pyx_k_push_watchers, sizeof(__pyx_k_push_watchers), 0, 0, 1, 1},
  {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  {&__pyx_n_s_query, __pyx_k_query, sizeof(__pyx_k_query), 0, 0, 1, 1},
  {&__pyx_n_s_queue, __pyx_k_queue, sizeof(__pyx_k_queue), 0, 0, 1, 1},
  {&__pyx_n_s_queue_2, __pyx_k_queue_2, sizeof(__pyx_k_queue_2), 0, 0, 1, 1},
  {&__pyx_n_s_raise_if_stopped, __pyx_k_raise_if_stopped, sizeof(__pyx_k_raise_if_stopped), 0, 0, 1, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 0, 1, 1},
  {&__pyx_n_s_read_frame_header, __pyx_k_read_frame_header, sizeof(__pyx_k_read_frame_header), 0, 0, 1, 1},
  {&__pyx_n_s_register_timeout, __pyx_k_register_timeout, sizeof(__pyx_k_register_timeout), 0, 0, 1, 1},
  {&__pyx_n_s_register_watcher, __pyx_k_register_watcher, sizeof(__pyx_k_register_watcher), 0, 0, 1, 1},
  {&__pyx_n_s_register_watchers, __pyx_k_register_watchers, sizeof(__pyx_k_register_watchers), 0, 0, 1, 1},
  {&__pyx_n_s_remote_supported_compressions, __pyx_k_remote_supported_compressions, sizeof(__pyx_k_remote_supported_compressions), 0, 0, 1, 1},
  {&__pyx_n_s_repr, __pyx_k_repr, sizeof(__pyx_k_repr), 0, 0, 1, 1},
  {&__pyx_n_s_request_id, __pyx_k_request_id, sizeof(__pyx_k_request_id), 0, 0, 1, 1},
  {&__pyx_n_s_request_ids, __pyx_k_request_ids, sizeof(__pyx_k_request_ids), 0, 0, 1, 1},
  {&__pyx_n_s_requests, __pyx_k_requests, sizeof(__pyx_k_requests), 0, 0, 1, 1},
  {&__pyx_n_s_requests_2, __pyx_k_requests_2, sizeof(__pyx_k_requests_2), 0, 0, 1, 1},
  {&__pyx_n_s_reset_frame, __pyx_k_reset_frame, sizeof(__pyx_k_reset_frame), 0, 0, 1, 1},
  {&__pyx_n_s_reset_idle, __pyx_k_reset_idle, sizeof(__pyx_k_reset_idle), 0, 0, 1, 1},
  {&__pyx_n_s_response, __pyx_k_response, sizeof(__pyx_k_response), 0, 0, 1, 1},
  {&__pyx_n_s_responses, __pyx_k_responses, sizeof(__pyx_k_responses), 0, 0, 1, 1},
  {&__pyx_n_s_result, __pyx_k_result, sizeof(__pyx_k_result), 0, 0, 1, 1},
  {&__pyx_n_s_return_connection, __pyx_k_return_connection, sizeof(__pyx_k_return_connection), 0, 0, 1, 1},
  {&__pyx_n_s_run, __pyx_k_run, sizeof(__pyx_k_run), 0, 0, 1, 1},
  {&__pyx_kp_s_s_r_s_d_s, __pyx_k_s_r_s_d_s, sizeof(__pyx_k_s_r_s_d_s), 0, 0, 1, 0},
  {&__pyx_n_s_seek, __pyx_k_seek, sizeof(__pyx_k_seek), 0, 0, 1, 1},
  {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  {&__pyx_n_s_send_msg, __pyx_k_send_msg, sizeof(__pyx_k_send_msg), 0, 0, 1, 1},
  {&__pyx_n_s_send_options_message, __pyx_k_send_options_message, sizeof(__pyx_k_send_options_message), 0, 0, 1, 1},
  {&__pyx_n_s_send_startup_message, __pyx_k_send_startup_message, sizeof(__pyx_k_send_startup_message), 0, 0, 1, 1},
  {&__pyx_n_s_service_timeouts, __pyx_k_service_timeouts, sizeof(__pyx_k_service_timeouts), 0, 0, 1, 1},
  {&__pyx_n_s_set, __pyx_k_set, sizeof(__pyx_k_set), 0, 0, 1, 1},
  {&__pyx_n_s_set_keyspace_async, __pyx_k_set_keyspace_async, sizeof(__pyx_k_set_keyspace_async), 0, 0, 1, 1},
  {&__pyx_n_s_set_keyspace_blocking, __pyx_k_set_keyspace_blocking, sizeof(__pyx_k_set_keyspace_blocking), 0, 0, 1, 1},
  {&__pyx_n_s_setsockopt, __pyx_k_setsockopt, sizeof(__pyx_k_setsockopt), 0, 0, 1, 1},
  {&__pyx_n_s_settimeout, __pyx_k_settimeout, sizeof(__pyx_k_settimeout), 0, 0, 1, 1},
  {&__pyx_n_s_shutdown_event, __pyx_k_shutdown_event, sizeof(__pyx_k_shutdown_event), 0, 0, 1, 1},
  {&__pyx_n_s_six, __pyx_k_six, sizeof(__pyx_k_six), 0, 0, 1, 1},
  {&__pyx_n_s_six_moves, __pyx_k_six_moves, sizeof(__pyx_k_six_moves), 0, 0, 1, 1},
  {&__pyx_n_s_six_moves_queue, __pyx_k_six_moves_queue, sizeof(__pyx_k_six_moves_queue), 0, 0, 1, 1},
  {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
  {&__pyx_n_s_sleep, __pyx_k_sleep, sizeof(__pyx_k_sleep), 0, 0, 1, 1},
  {&__pyx_n_s_sm, __pyx_k_sm, sizeof(__pyx_k_sm), 0, 0, 1, 1},
  {&__pyx_n_s_snappy, __pyx_k_snappy, sizeof(__pyx_k_snappy), 0, 0, 1, 1},
  {&__pyx_n_s_sockaddr, __pyx_k_sockaddr, sizeof(__pyx_k_sockaddr), 0, 0, 1, 1},
  {&__pyx_n_s_sockerr, __pyx_k_sockerr, sizeof(__pyx_k_sockerr), 0, 0, 1, 1},
  {&__pyx_n_s_socket, __pyx_k_socket, sizeof(__pyx_k_socket), 0, 0, 1, 1},
  {&__pyx_n_s_socket_2, __pyx_k_socket_2, sizeof(__pyx_k_socket_2), 0, 0, 1, 1},
  {&__pyx_n_s_socket_impl, __pyx_k_socket_impl, sizeof(__pyx_k_socket_impl), 0, 0, 1, 1},
  {&__pyx_n_s_sockopts, __pyx_k_sockopts, sizeof(__pyx_k_sockopts), 0, 0, 1, 1},
  {&__pyx_n_s_socktype, __pyx_k_socktype, sizeof(__pyx_k_socktype), 0, 0, 1, 1},
  {&__pyx_n_s_ssl, __pyx_k_ssl, sizeof(__pyx_k_ssl), 0, 0, 1, 1},
  {&__pyx_n_s_ssl_impl, __pyx_k_ssl_impl, sizeof(__pyx_k_ssl_impl), 0, 0, 1, 1},
  {&__pyx_n_s_ssl_options, __pyx_k_ssl_options, sizeof(__pyx_k_ssl_options), 0, 0, 1, 1},
  {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
  {&__pyx_n_s_start_time, __pyx_k_start_time, sizeof(__pyx_k_start_time), 0, 0, 1, 1},
  {&__pyx_n_s_startup_response, __pyx_k_startup_response, sizeof(__pyx_k_startup_response), 0, 0, 1, 1},
  {&__pyx_n_s_startup_version, __pyx_k_startup_version, sizeof(__pyx_k_startup_version), 0, 0, 1, 1},
  {&__pyx_n_s_status, __pyx_k_status, sizeof(__pyx_k_status), 0, 0, 1, 1},
  {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
  {&__pyx_n_s_str, __pyx_k_str, sizeof(__pyx_k_str), 0, 0, 1, 1},
  {&__pyx_n_s_stream, __pyx_k_stream, sizeof(__pyx_k_stream), 0, 0, 1, 1},
  {&__pyx_n_s_stream_id, __pyx_k_stream_id, sizeof(__pyx_k_stream_id), 0, 0, 1, 1},
  {&__pyx_n_s_strerror, __pyx_k_strerror, sizeof(__pyx_k_strerror), 0, 0, 1, 1},
  {&__pyx_n_s_string_types, __pyx_k_string_types, sizeof(__pyx_k_string_types), 0, 0, 1, 1},
  {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1},
  {&__pyx_n_s_summary_msg, __pyx_k_summary_msg, sizeof(__pyx_k_summary_msg), 0, 0, 1, 1},
  {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1},
  {&__pyx_n_s_supported_cql_versions, __pyx_k_supported_cql_versions, sizeof(__pyx_k_supported_cql_versions), 0, 0, 1, 1},
  {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
  {&__pyx_n_s_tell, __pyx_k_tell, sizeof(__pyx_k_tell), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_threading, __pyx_k_threading, sizeof(__pyx_k_threading), 0, 0, 1, 1},
  {&__pyx_n_s_time, __pyx_k_time, sizeof(__pyx_k_time), 0, 0, 1, 1},
  {&__pyx_n_s_time_now, __pyx_k_time_now, sizeof(__pyx_k_time_now), 0, 0, 1, 1},
  {&__pyx_n_s_timeout, __pyx_k_timeout, sizeof(__pyx_k_timeout), 0, 0, 1, 1},
  {&__pyx_n_s_timer, __pyx_k_timer, sizeof(__pyx_k_timer), 0, 0, 1, 1},
  {&__pyx_n_s_to_exception, __pyx_k_to_exception, sizeof(__pyx_k_to_exception), 0, 0, 1, 1},
  {&__pyx_n_s_token, __pyx_k_token, sizeof(__pyx_k_token), 0, 0, 1, 1},
  {&__pyx_n_s_type_callback_dict, __pyx_k_type_callback_dict, sizeof(__pyx_k_type_callback_dict), 0, 0, 1, 1},
  {&__pyx_n_s_uint8_unpack, __pyx_k_uint8_unpack, sizeof(__pyx_k_uint8_unpack), 0, 0, 1, 1},
  {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1},
  {&__pyx_kp_s_unsupported_protocol_version, __pyx_k_unsupported_protocol_version, sizeof(__pyx_k_unsupported_protocol_version), 0, 0, 1, 0},
  {&__pyx_n_s_user_type_map, __pyx_k_user_type_map, sizeof(__pyx_k_user_type_map), 0, 0, 1, 1},
  {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1},
  {&__pyx_n_s_version, __pyx_k_version, sizeof(__pyx_k_version), 0, 0, 1, 1},
  {&__pyx_n_s_wait, __pyx_k_wait, sizeof(__pyx_k_wait), 0, 0, 1, 1},
  {&__pyx_n_s_wait_for_response, __pyx_k_wait_for_response, sizeof(__pyx_k_wait_for_response), 0, 0, 1, 1},
  {&__pyx_n_s_wait_for_responses, __pyx_k_wait_for_responses, sizeof(__pyx_k_wait_for_responses), 0, 0, 1, 1},
  {&__pyx_n_s_waiter, __pyx_k_waiter, sizeof(__pyx_k_waiter), 0, 0, 1, 1},
  {&__pyx_n_s_warning, __pyx_k_warning, sizeof(__pyx_k_warning), 0, 0, 1, 1},
  {&__pyx_n_s_wrap_socket, __pyx_k_wrap_socket, sizeof(__pyx_k_wrap_socket), 0, 0, 1, 1},
  {&__pyx_n_s_wrapper, __pyx_k_wrapper, sizeof(__pyx_k_wrapper), 0, 0, 1, 1},
  {&__pyx_n_s_wraps, __pyx_k_wraps, sizeof(__pyx_k_wraps), 0, 0, 1, 1},
  {&__pyx_n_s_write, __pyx_k_write, sizeof(__pyx_k_write), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s_Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_property = __Pyx_GetBuiltinName(__pyx_n_s_property); if (!__pyx_builtin_property) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "cassandra/connection.py":72
 *     def lz4_compress(byts):
 *         # write length in big-endian instead of little-endian
 *         return int32_pack(len(byts)) + lz4.compress(byts)[4:]             # <<<<<<<<<<<<<<
 * 
 *     def lz4_decompress(byts):
 */
  __pyx_slice_ = PySlice_New(__pyx_int_4, Py_None, Py_None); if (unlikely(!__pyx_slice_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice_);
  __Pyx_GIVEREF(__pyx_slice_);

  /* "cassandra/connection.py":76
 *     def lz4_decompress(byts):
 *         # flip from big-endian to little-endian
 *         return lz4.decompress(byts[3::-1] + byts[4:])             # <<<<<<<<<<<<<<
 * 
 *     locally_supported_compressions['lz4'] = (lz4_compress, lz4_decompress)
 */
  __pyx_slice__2 = PySlice_New(__pyx_int_3, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__2);
  __Pyx_GIVEREF(__pyx_slice__2);
  __pyx_slice__3 = PySlice_New(__pyx_int_4, Py_None, Py_None); if (unlikely(!__pyx_slice__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__3);
  __Pyx_GIVEREF(__pyx_slice__3);

  /* "cassandra/connection.py":151
 * 
 *     @wraps(f)
 *     def wrapper(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         try:
 *             return f(self, *args, **kwargs)
 */
  __pyx_tuple__6 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_args, __pyx_n_s_kwargs, __pyx_n_s_exc); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);
  __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_wrapper, 151, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":231
 *             # Don't fill the deque with 2**15 items right away. Start with 300 and add
 *             # more if needed.
 *             self.request_ids = deque(range(300))             # <<<<<<<<<<<<<<
 *             self.highest_request_id = 299
 *         else:
 */
  __pyx_tuple__8 = PyTuple_Pack(1, __pyx_int_300); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "cassandra/connection.py":288
 *                 if self.ssl_options:
 *                     if not self._ssl_impl:
 *                         raise Exception("This version of Python was not compiled with SSL support")             # <<<<<<<<<<<<<<
 *                     self._socket = self._ssl_impl.wrap_socket(self._socket, **self.ssl_options)
 *                 self._socket.settimeout(1.0)
 */
  __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_This_version_of_Python_was_not_c); if (unlikely(!__pyx_tuple__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);

  /* "cassandra/connection.py":290
 *                         raise Exception("This version of Python was not compiled with SSL support")
 *                     self._socket = self._ssl_impl.wrap_socket(self._socket, **self.ssl_options)
 *                 self._socket.settimeout(1.0)             # <<<<<<<<<<<<<<
 *                 self._socket.connect(sockaddr)
 *                 sockerr = None
 */
  __pyx_tuple__10 = PyTuple_Pack(1, __pyx_float_1_0); if (unlikely(!__pyx_tuple__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "cassandra/connection.py":311
 * 
 *     def defunct(self, exc):
 *         with self.lock:             # <<<<<<<<<<<<<<
 *             if self.is_defunct or self.is_closed:
 *                 return
 */
  __pyx_tuple__11 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);
  __pyx_tuple__12 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "cassandra/connection.py":326
 * 
 *     def error_all_requests(self, exc):
 *         with self.lock:             # <<<<<<<<<<<<<<
 *             requests = self._requests
 *             self._requests = {}
 */
  __pyx_tuple__13 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);

  /* "cassandra/connection.py":356
 *                 cb(response.event_args)
 *             except Exception:
 *                 log.exception("Pushed event handler errored, ignoring:")             # <<<<<<<<<<<<<<
 * 
 *     def send_msg(self, msg, request_id, cb, encoder=ProtocolHandler.encode_message, decoder=ProtocolHandler.decode_message):
 */
  __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_Pushed_event_handler_errored_ign); if (unlikely(!__pyx_tuple__14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "cassandra/connection.py":392
 *         while True:
 *             needed = len(msgs) - messages_sent
 *             with self.lock:             # <<<<<<<<<<<<<<
 *                 available = min(needed, self.max_request_id - self.in_flight)
 *                 request_ids = [self.get_request_id() for _ in range(available)]
 */
  __pyx_tuple__15 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "cassandra/connection.py":410
 *                     if timeout <= 0.0:
 *                         raise OperationTimedOut()
 *                 time.sleep(0.01)             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  __pyx_tuple__16 = PyTuple_Pack(1, __pyx_float_0_01); if (unlikely(!__pyx_tuple__16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "cassandra/connection.py":448
 *         pos = buf.tell()
 *         if pos:
 *             buf.seek(0)             # <<<<<<<<<<<<<<
 *             version = uint8_unpack(buf.read(1)) & PROTOCOL_VERSION_MASK
 *             if version > MAX_SUPPORTED_VERSION:
 */
  __pyx_tuple__17 = PyTuple_Pack(1, __pyx_int_0); if (unlikely(!__pyx_tuple__17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "cassandra/connection.py":449
 *         if pos:
 *             buf.seek(0)
 *             version = uint8_unpack(buf.read(1)) & PROTOCOL_VERSION_MASK             # <<<<<<<<<<<<<<
 *             if version > MAX_SUPPORTED_VERSION:
 *                 raise ProtocolError("This version of the driver does not support protocol version %d" % version)
 */
  __pyx_tuple__18 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);

  /* "cassandra/connection.py":498
 *         else:
 *             callback, decoder = self._requests.pop(stream_id, None)
 *             with self.lock:             # <<<<<<<<<<<<<<
 *                 self.request_ids.append(stream_id)
 * 
 */
  __pyx_tuple__19 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);

  /* "cassandra/connection.py":527
 *                 self.handle_pushed(response)
 *         except Exception:
 *             log.exception("Callback handler errored, ignoring:")             # <<<<<<<<<<<<<<
 * 
 *     @defunct_on_error
 */
  __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_Callback_handler_errored_ignorin); if (unlikely(!__pyx_tuple__20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "cassandra/connection.py":629
 * 
 *             if self.authenticator is None:
 *                 raise AuthenticationFailed('Remote end requires authentication.')             # <<<<<<<<<<<<<<
 * 
 *             self.authenticator_class = startup_response.authenticator
 */
  __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_Remote_end_requires_authenticati); if (unlikely(!__pyx_tuple__21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);

  /* "cassandra/connection.py":731
 *                              consistency_level=ConsistencyLevel.ONE)
 * 
 *         def process_result(result):             # <<<<<<<<<<<<<<
 *             if isinstance(result, ResultMessage):
 *                 self.keyspace = keyspace
 */
  __pyx_tuple__22 = PyTuple_Pack(1, __pyx_n_s_result); if (unlikely(!__pyx_tuple__22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);
  __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_process_result, 731, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":747
 *         # - it allows us to avoid signaling a condition every time a request completes
 *         while True:
 *             with self.lock:             # <<<<<<<<<<<<<<
 *                 if self.in_flight < self.max_request_id:
 *                     request_id = self.get_request_id()
 */
  __pyx_tuple__24 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);
  __pyx_tuple__25 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "cassandra/connection.py":753
 *                     break
 * 
 *             time.sleep(0.001)             # <<<<<<<<<<<<<<
 * 
 *         self.send_msg(query, request_id, process_result)
 */
  __pyx_tuple__26 = PyTuple_Pack(1, __pyx_float_0_001); if (unlikely(!__pyx_tuple__26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "cassandra/connection.py":786
 * 
 *     def got_response(self, response, index):
 *         with self.connection.lock:             # <<<<<<<<<<<<<<
 *             self.connection.in_flight -= 1
 *         if isinstance(response, Exception):
 */
  __pyx_tuple__27 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);

  /* "cassandra/connection.py":838
 *                 connection.send_msg(OptionsMessage(), connection.get_request_id(), self._options_callback)
 *             else:
 *                 self._exception = Exception("Failed to send heartbeat because connection 'in_flight' exceeds threshold")             # <<<<<<<<<<<<<<
 *                 self._event.set()
 * 
 */
  __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_Failed_to_send_heartbeat_because); if (unlikely(!__pyx_tuple__28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);

  /* "cassandra/connection.py":833
 *         log.debug("Sending options message heartbeat on idle connection (%s) %s",
 *                   id(connection), connection.host)
 *         with connection.lock:             # <<<<<<<<<<<<<<
 *             if connection.in_flight < connection.max_request_id:
 *                 connection.in_flight += 1
 */
  __pyx_tuple__29 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);

  /* "cassandra/connection.py":907
 *                         f.wait(self._interval)
 *                         # TODO: move this, along with connection locks in pool, down into Connection
 *                         with connection.lock:             # <<<<<<<<<<<<<<
 *                             connection.in_flight -= 1
 *                         connection.reset_idle()
 */
  __pyx_tuple__30 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);

  /* "cassandra/connection.py":917
 *                 for connection, owner in failed_connections:
 *                     self._raise_if_stopped()
 *                     connection.defunct(Exception('Connection heartbeat failure'))             # <<<<<<<<<<<<<<
 *                     owner.return_connection(connection)
 *             except self.ShutdownException:
 */
  __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_Connection_heartbeat_failure); if (unlikely(!__pyx_tuple__31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);

  /* "cassandra/connection.py":922
 *                 pass
 *             except Exception:
 *                 log.error("Failed connection heartbeat", exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *             elapsed = time.time() - start_time
 */
  __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_Failed_connection_heartbeat); if (unlikely(!__pyx_tuple__32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);

  /* "cassandra/connection.py":994
 *                         return timer.end
 *                 except Exception:
 *                     log.exception("Exception while servicing timeout callback: ")             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_Exception_while_servicing_timeou); if (unlikely(!__pyx_tuple__33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);

  /* "cassandra/connection.py":70
 *     # functions to handle that
 * 
 *     def lz4_compress(byts):             # <<<<<<<<<<<<<<
 *         # write length in big-endian instead of little-endian
 *         return int32_pack(len(byts)) + lz4.compress(byts)[4:]
 */
  __pyx_tuple__34 = PyTuple_Pack(1, __pyx_n_s_byts); if (unlikely(!__pyx_tuple__34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);
  __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_lz4_compress, 70, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":74
 *         return int32_pack(len(byts)) + lz4.compress(byts)[4:]
 * 
 *     def lz4_decompress(byts):             # <<<<<<<<<<<<<<
 *         # flip from big-endian to little-endian
 *         return lz4.decompress(byts[3::-1] + byts[4:])
 */
  __pyx_tuple__36 = PyTuple_Pack(1, __pyx_n_s_byts); if (unlikely(!__pyx_tuple__36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);
  __pyx_codeobj__37 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_lz4_decompress, 74, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":86
 * else:
 *     # work around apparently buggy snappy decompress
 *     def decompress(byts):             # <<<<<<<<<<<<<<
 *         if byts == '\x00':
 *             return ''
 */
  __pyx_tuple__38 = PyTuple_Pack(1, __pyx_n_s_byts); if (unlikely(!__pyx_tuple__38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);
  __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_decompress, 86, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":99
 * HEADER_DIRECTION_MASK = 0x80
 * 
 * frame_header_v1_v2 = struct.Struct('>BbBi')             # <<<<<<<<<<<<<<
 * frame_header_v3 = struct.Struct('>BhBi')
 * 
 */
  __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_s_BbBi); if (unlikely(!__pyx_tuple__40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);

  /* "cassandra/connection.py":100
 * 
 * frame_header_v1_v2 = struct.Struct('>BbBi')
 * frame_header_v3 = struct.Struct('>BhBi')             # <<<<<<<<<<<<<<
 * 
 * _Frame = namedtuple('Frame', ('version', 'flags', 'stream', 'opcode', 'body_offset', 'end_pos'))
 */
  __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_s_BhBi); if (unlikely(!__pyx_tuple__41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);

  /* "cassandra/connection.py":102
 * frame_header_v3 = struct.Struct('>BhBi')
 * 
 * _Frame = namedtuple('Frame', ('version', 'flags', 'stream', 'opcode', 'body_offset', 'end_pos'))             # <<<<<<<<<<<<<<
 * 
 * NONBLOCKING = (errno.EAGAIN, errno.EWOULDBLOCK)
 */
  __pyx_tuple__42 = PyTuple_Pack(6, __pyx_n_s_version, __pyx_n_s_flags, __pyx_n_s_stream, __pyx_n_s_opcode, __pyx_n_s_body_offset, __pyx_n_s_end_pos); if (unlikely(!__pyx_tuple__42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);
  __pyx_tuple__43 = PyTuple_Pack(2, __pyx_n_s_Frame_2, __pyx_tuple__42); if (unlikely(!__pyx_tuple__43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);

  /* "cassandra/connection.py":113
 *     """
 * 
 *     def __init__(self, message, host=None):             # <<<<<<<<<<<<<<
 *         Exception.__init__(self, message)
 *         self.host = host
 */
  __pyx_tuple__44 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_message, __pyx_n_s_host); if (unlikely(!__pyx_tuple__44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__44);
  __Pyx_GIVEREF(__pyx_tuple__44);
  __pyx_codeobj__45 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_init, 113, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__45)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_tuple__46 = PyTuple_Pack(1, ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__46);
  __Pyx_GIVEREF(__pyx_tuple__46);

  /* "cassandra/connection.py":128
 *     Server rejected startup message due to unsupported protocol version
 *     """
 *     def __init__(self, host, startup_version):             # <<<<<<<<<<<<<<
 *         super(ProtocolVersionUnsupported, self).__init__("Unsupported protocol version on %s: %d",
 *                                                          (host, startup_version))
 */
  __pyx_tuple__47 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_host, __pyx_n_s_startup_version); if (unlikely(!__pyx_tuple__47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);
  __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_init, 128, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":148
 * 
 * 
 * def defunct_on_error(f):             # <<<<<<<<<<<<<<
 * 
 *     @wraps(f)
 */
  __pyx_tuple__49 = PyTuple_Pack(3, __pyx_n_s_f, __pyx_n_s_wrapper, __pyx_n_s_wrapper); if (unlikely(!__pyx_tuple__49)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);
  __pyx_codeobj__50 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_defunct_on_error, 148, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":209
 *     _ssl_impl = ssl
 * 
 *     def __init__(self, host='127.0.0.1', port=9042, authenticator=None,             # <<<<<<<<<<<<<<
 *                  ssl_options=None, sockopts=None, compression=True,
 *                  cql_version=None, protocol_version=MAX_SUPPORTED_VERSION, is_control_connection=False,
 */
  __pyx_tuple__51 = PyTuple_Pack(11, __pyx_n_s_self, __pyx_n_s_host, __pyx_n_s_port, __pyx_n_s_authenticator, __pyx_n_s_ssl_options, __pyx_n_s_sockopts, __pyx_n_s_compression, __pyx_n_s_cql_version, __pyx_n_s_protocol_version, __pyx_n_s_is_control_connection, __pyx_n_s_user_type_map); if (unlikely(!__pyx_tuple__51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__51);
  __Pyx_GIVEREF(__pyx_tuple__51);
  __pyx_codeobj__52 = (PyObject*)__Pyx_PyCode_New(11, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__51, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_init, 209, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":242
 * 
 *     @classmethod
 *     def initialize_reactor(self):             # <<<<<<<<<<<<<<
 *         """
 *         Called once by Cluster.connect().  This should be used by implementations
 */
  __pyx_tuple__53 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__53)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__53);
  __Pyx_GIVEREF(__pyx_tuple__53);
  __pyx_codeobj__54 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__53, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_initialize_reactor, 242, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__54)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":250
 * 
 *     @classmethod
 *     def handle_fork(self):             # <<<<<<<<<<<<<<
 *         """
 *         Called after a forking.  This should cleanup any remaining reactor state
 */
  __pyx_tuple__55 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__55)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__55);
  __Pyx_GIVEREF(__pyx_tuple__55);
  __pyx_codeobj__56 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__55, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_handle_fork, 250, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__56)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":258
 * 
 *     @classmethod
 *     def create_timer(cls, timeout, callback):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError()
 * 
 */
  __pyx_tuple__57 = PyTuple_Pack(3, __pyx_n_s_cls, __pyx_n_s_timeout, __pyx_n_s_callback); if (unlikely(!__pyx_tuple__57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__57);
  __Pyx_GIVEREF(__pyx_tuple__57);
  __pyx_codeobj__58 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__57, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_create_timer, 258, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__58)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":262
 * 
 *     @classmethod
 *     def factory(cls, host, timeout, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """
 *         A factory function which returns connections which have
 */
  __pyx_tuple__59 = PyTuple_Pack(6, __pyx_n_s_cls, __pyx_n_s_host, __pyx_n_s_timeout, __pyx_n_s_args, __pyx_n_s_kwargs, __pyx_n_s_conn); if (unlikely(!__pyx_tuple__59)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__59);
  __Pyx_GIVEREF(__pyx_tuple__59);
  __pyx_codeobj__60 = (PyObject*)__Pyx_PyCode_New(3, 0, 6, 0, CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__59, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_factory, 262, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":280
 *             return conn
 * 
 *     def _connect_socket(self):             # <<<<<<<<<<<<<<
 *         sockerr = None
 *         addresses = socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM)
 */
  __pyx_tuple__61 = PyTuple_Pack(11, __pyx_n_s_self, __pyx_n_s_sockerr, __pyx_n_s_addresses, __pyx_n_s_af, __pyx_n_s_socktype, __pyx_n_s_proto, __pyx_n_s_canonname, __pyx_n_s_sockaddr, __pyx_n_s_err, __pyx_n_s_args, __pyx_n_s_a); if (unlikely(!__pyx_tuple__61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__61);
  __Pyx_GIVEREF(__pyx_tuple__61);
  __pyx_codeobj__62 = (PyObject*)__Pyx_PyCode_New(1, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__61, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_connect_socket, 280, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":307
 *                 self._socket.setsockopt(*args)
 * 
 *     def close(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError()
 * 
 */
  __pyx_tuple__63 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__63);
  __Pyx_GIVEREF(__pyx_tuple__63);
  __pyx_codeobj__64 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__63, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_close, 307, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":310
 *         raise NotImplementedError()
 * 
 *     def defunct(self, exc):             # <<<<<<<<<<<<<<
 *         with self.lock:
 *             if self.is_defunct or self.is_closed:
 */
  __pyx_tuple__65 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_exc); if (unlikely(!__pyx_tuple__65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__65);
  __Pyx_GIVEREF(__pyx_tuple__65);
  __pyx_codeobj__66 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__65, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_defunct, 310, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":325
 *         return exc
 * 
 *     def error_all_requests(self, exc):             # <<<<<<<<<<<<<<
 *         with self.lock:
 *             requests = self._requests
 */
  __pyx_tuple__68 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_exc, __pyx_n_s_requests_2, __pyx_n_s_new_exc, __pyx_n_s_cb, __pyx_n_s__67); if (unlikely(!__pyx_tuple__68)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__68);
  __Pyx_GIVEREF(__pyx_tuple__68);
  __pyx_codeobj__69 = (PyObject*)__Pyx_PyCode_New(2, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__68, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_error_all_requests, 325, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__69)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":338
 *                             id(self), self.host, exc_info=True)
 * 
 *     def get_request_id(self):             # <<<<<<<<<<<<<<
 *         """
 *         This must be called while self.lock is held.
 */
  __pyx_tuple__70 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__70)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__70);
  __Pyx_GIVEREF(__pyx_tuple__70);
  __pyx_codeobj__71 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__70, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_get_request_id, 338, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__71)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":350
 *             return self.highest_request_id
 * 
 *     def handle_pushed(self, response):             # <<<<<<<<<<<<<<
 *         log.debug("Message pushed from server: %r", response)
 *         for cb in self._push_watchers.get(response.event_type, []):
 */
  __pyx_tuple__72 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_response, __pyx_n_s_cb); if (unlikely(!__pyx_tuple__72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__72);
  __Pyx_GIVEREF(__pyx_tuple__72);
  __pyx_codeobj__73 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__72, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_handle_pushed, 350, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__73)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":358
 *                 log.exception("Pushed event handler errored, ignoring:")
 * 
 *     def send_msg(self, msg, request_id, cb, encoder=ProtocolHandler.encode_message, decoder=ProtocolHandler.decode_message):             # <<<<<<<<<<<<<<
 *         if self.is_defunct:
 *             raise ConnectionShutdown("Connection to %s is defunct" % self.host)
 */
  __pyx_tuple__74 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_msg, __pyx_n_s_request_id, __pyx_n_s_cb, __pyx_n_s_encoder, __pyx_n_s_decoder); if (unlikely(!__pyx_tuple__74)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__74);
  __Pyx_GIVEREF(__pyx_tuple__74);
  __pyx_codeobj__75 = (PyObject*)__Pyx_PyCode_New(6, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__74, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_send_msg, 358, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__75)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":370
 *         return request_id
 * 
 *     def wait_for_response(self, msg, timeout=None):             # <<<<<<<<<<<<<<
 *         return self.wait_for_responses(msg, timeout=timeout)[0]
 * 
 */
  __pyx_tuple__76 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_msg, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__76)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__76);
  __Pyx_GIVEREF(__pyx_tuple__76);
  __pyx_codeobj__77 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__76, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_wait_for_response, 370, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__77)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_tuple__78 = PyTuple_Pack(1, ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__78)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__78);
  __Pyx_GIVEREF(__pyx_tuple__78);

  /* "cassandra/connection.py":373
 *         return self.wait_for_responses(msg, timeout=timeout)[0]
 * 
 *     def wait_for_responses(self, *msgs, **kwargs):             # <<<<<<<<<<<<<<
 *         """
 *         Returns a list of (success, response) tuples.  If success
 */
  __pyx_tuple__79 = PyTuple_Pack(14, __pyx_n_s_self, __pyx_n_s_msgs, __pyx_n_s_kwargs, __pyx_n_s_timeout, __pyx_n_s_fail_on_error, __pyx_n_s_waiter, __pyx_n_s_messages_sent, __pyx_n_s_needed, __pyx_n_s_available, __pyx_n_s_request_ids, __pyx_n_s_i, __pyx_n_s_request_id, __pyx_n_s_exc, __pyx_n_s__67); if (unlikely(!__pyx_tuple__79)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__79);
  __Pyx_GIVEREF(__pyx_tuple__79);
  __pyx_codeobj__80 = (PyObject*)__Pyx_PyCode_New(1, 0, 14, 0, CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__79, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_wait_for_responses, 373, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":420
 *             raise
 * 
 *     def register_watcher(self, event_type, callback, register_timeout=None):             # <<<<<<<<<<<<<<
 *         """
 *         Register a callback for a given event type.
 */
  __pyx_tuple__81 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_event_type, __pyx_n_s_callback, __pyx_n_s_register_timeout); if (unlikely(!__pyx_tuple__81)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__81);
  __Pyx_GIVEREF(__pyx_tuple__81);
  __pyx_codeobj__82 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__81, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_register_watcher, 420, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__82)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_tuple__83 = PyTuple_Pack(1, ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__83)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__83);
  __Pyx_GIVEREF(__pyx_tuple__83);

  /* "cassandra/connection.py":429
 *             timeout=register_timeout)
 * 
 *     def register_watchers(self, type_callback_dict, register_timeout=None):             # <<<<<<<<<<<<<<
 *         """
 *         Register multiple callback/event type pairs, expressed as a dict.
 */
  __pyx_tuple__84 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_type_callback_dict, __pyx_n_s_register_timeout, __pyx_n_s_event_type, __pyx_n_s_callback); if (unlikely(!__pyx_tuple__84)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__84);
  __Pyx_GIVEREF(__pyx_tuple__84);
  __pyx_codeobj__85 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__84, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_register_watchers, 429, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__85)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_tuple__86 = PyTuple_Pack(1, ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__86)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__86);
  __Pyx_GIVEREF(__pyx_tuple__86);

  /* "cassandra/connection.py":439
 *             timeout=register_timeout)
 * 
 *     def control_conn_disposed(self):             # <<<<<<<<<<<<<<
 *         self.is_control_connection = False
 *         self._push_watchers = {}
 */
  __pyx_tuple__87 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__87)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__87);
  __Pyx_GIVEREF(__pyx_tuple__87);
  __pyx_codeobj__88 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__87, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_control_conn_disposed, 439, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__88)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":444
 * 
 *     @defunct_on_error
 *     def _read_frame_header(self):             # <<<<<<<<<<<<<<
 *         buf = self._iobuf
 *         pos = buf.tell()
 */
  __pyx_tuple__89 = PyTuple_Pack(10, __pyx_n_s_self, __pyx_n_s_buf, __pyx_n_s_pos, __pyx_n_s_version, __pyx_n_s_frame_header, __pyx_n_s_header_size, __pyx_n_s_flags, __pyx_n_s_stream, __pyx_n_s_op, __pyx_n_s_body_len); if (unlikely(!__pyx_tuple__89)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__89);
  __Pyx_GIVEREF(__pyx_tuple__89);
  __pyx_codeobj__90 = (PyObject*)__Pyx_PyCode_New(1, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__89, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_read_frame_header, 444, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__90)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":465
 *         return pos
 * 
 *     def _reset_frame(self):             # <<<<<<<<<<<<<<
 *         leftover = self._iobuf.read()
 *         self._iobuf = io.BytesIO()
 */
  __pyx_tuple__91 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_leftover); if (unlikely(!__pyx_tuple__91)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__91);
  __Pyx_GIVEREF(__pyx_tuple__91);
  __pyx_codeobj__92 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__91, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_reset_frame, 465, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__92)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":471
 *         self._current_frame = None
 * 
 *     def process_io_buffer(self):             # <<<<<<<<<<<<<<
 *         while True:
 *             if not self._current_frame:
 */
  __pyx_tuple__93 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_pos, __pyx_n_s_frame, __pyx_n_s_msg); if (unlikely(!__pyx_tuple__93)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__93);
  __Pyx_GIVEREF(__pyx_tuple__93);
  __pyx_codeobj__94 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__93, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_process_io_buffer, 471, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__94)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":491
 * 
 *     @defunct_on_error
 *     def process_msg(self, header, body):             # <<<<<<<<<<<<<<
 *         stream_id = header.stream
 *         if stream_id < 0:
 */
  __pyx_tuple__95 = PyTuple_Pack(8, __pyx_n_s_self, __pyx_n_s_header, __pyx_n_s_body, __pyx_n_s_stream_id, __pyx_n_s_callback, __pyx_n_s_decoder, __pyx_n_s_response, __pyx_n_s_exc); if (unlikely(!__pyx_tuple__95)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__95);
  __Pyx_GIVEREF(__pyx_tuple__95);
  __pyx_codeobj__96 = (PyObject*)__Pyx_PyCode_New(3, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__95, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_process_msg, 491, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__96)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":530
 * 
 *     @defunct_on_error
 *     def _send_options_message(self):             # <<<<<<<<<<<<<<
 *         if self.cql_version is None and (not self.compression or not locally_supported_compressions):
 *             log.debug("Not sending options message for new connection(%s) to %s "
 */
  __pyx_tuple__97 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__97)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__97);
  __Pyx_GIVEREF(__pyx_tuple__97);
  __pyx_codeobj__98 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__97, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_send_options_message, 530, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__98)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":543
 * 
 *     @defunct_on_error
 *     def _handle_options_response(self, options_response):             # <<<<<<<<<<<<<<
 *         if self.is_defunct:
 *             return
 */
  __pyx_tuple__99 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_options_response, __pyx_n_s_supported_cql_versions, __pyx_n_s_remote_supported_compressions, __pyx_n_s_compression_type, __pyx_n_s_overlap, __pyx_n_s_k); if (unlikely(!__pyx_tuple__99)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__99);
  __Pyx_GIVEREF(__pyx_tuple__99);
  __pyx_codeobj__100 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__99, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_handle_options_response, 543, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__100)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":606
 * 
 *     @defunct_on_error
 *     def _send_startup_message(self, compression=None):             # <<<<<<<<<<<<<<
 *         log.debug("Sending StartupMessage on %s", self)
 *         opts = {}
 */
  __pyx_tuple__101 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_compression, __pyx_n_s_opts, __pyx_n_s_sm); if (unlikely(!__pyx_tuple__101)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__101);
  __Pyx_GIVEREF(__pyx_tuple__101);
  __pyx_codeobj__102 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__101, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_send_startup_message, 606, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__102)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_tuple__103 = PyTuple_Pack(1, ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__103)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__103);
  __Pyx_GIVEREF(__pyx_tuple__103);

  /* "cassandra/connection.py":616
 * 
 *     @defunct_on_error
 *     def _handle_startup_response(self, startup_response, did_authenticate=False):             # <<<<<<<<<<<<<<
 *         if self.is_defunct:
 *             return
 */
  __pyx_tuple__104 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_startup_response, __pyx_n_s_did_authenticate, __pyx_n_s_cm, __pyx_n_s_callback, __pyx_n_s_initial_response, __pyx_n_s_msg); if (unlikely(!__pyx_tuple__104)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__104);
  __Pyx_GIVEREF(__pyx_tuple__104);
  __pyx_codeobj__105 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__104, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_handle_startup_response, 616, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__105)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_tuple__106 = PyTuple_Pack(1, ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__106)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__106);
  __Pyx_GIVEREF(__pyx_tuple__106);

  /* "cassandra/connection.py":663
 * 
 *     @defunct_on_error
 *     def _handle_auth_response(self, auth_response):             # <<<<<<<<<<<<<<
 *         if self.is_defunct:
 *             return
 */
  __pyx_tuple__107 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_auth_response, __pyx_n_s_response, __pyx_n_s_msg); if (unlikely(!__pyx_tuple__107)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__107);
  __Pyx_GIVEREF(__pyx_tuple__107);
  __pyx_codeobj__108 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__107, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_handle_auth_response, 663, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__108)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":692
 *             raise ProtocolError(msg % (self.host, auth_response))
 * 
 *     def set_keyspace_blocking(self, keyspace):             # <<<<<<<<<<<<<<
 *         if not keyspace or keyspace == self.keyspace:
 *             return
 */
  __pyx_tuple__109 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_keyspace, __pyx_n_s_query, __pyx_n_s_result, __pyx_n_s_ire, __pyx_n_s_exc, __pyx_n_s_conn_exc); if (unlikely(!__pyx_tuple__109)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__109);
  __Pyx_GIVEREF(__pyx_tuple__109);
  __pyx_codeobj__110 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__109, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_set_keyspace_blocking, 692, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__110)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":717
 *             raise conn_exc
 * 
 *     def set_keyspace_async(self, keyspace, callback):             # <<<<<<<<<<<<<<
 *         """
 *         Use this in order to avoid deadlocking the event loop thread.
 */
  __pyx_tuple__111 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_keyspace, __pyx_n_s_callback, __pyx_n_s_query, __pyx_n_s_process_result, __pyx_n_s_process_result, __pyx_n_s_request_id); if (unlikely(!__pyx_tuple__111)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__111);
  __Pyx_GIVEREF(__pyx_tuple__111);
  __pyx_codeobj__112 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__111, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_set_keyspace_async, 717, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__112)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":758
 * 
 *     @property
 *     def is_idle(self):             # <<<<<<<<<<<<<<
 *         return not self.msg_received
 * 
 */
  __pyx_tuple__113 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__113)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__113);
  __Pyx_GIVEREF(__pyx_tuple__113);
  __pyx_codeobj__114 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__113, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_is_idle, 758, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__114)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":761
 *         return not self.msg_received
 * 
 *     def reset_idle(self):             # <<<<<<<<<<<<<<
 *         self.msg_received = False
 * 
 */
  __pyx_tuple__115 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__115)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__115);
  __Pyx_GIVEREF(__pyx_tuple__115);
  __pyx_codeobj__116 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__115, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_reset_idle, 761, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__116)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":764
 *         self.msg_received = False
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         status = ""
 *         if self.is_defunct:
 */
  __pyx_tuple__117 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_status); if (unlikely(!__pyx_tuple__117)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__117);
  __Pyx_GIVEREF(__pyx_tuple__117);
  __pyx_codeobj__118 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__117, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_str, 764, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__118)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":777
 * class ResponseWaiter(object):
 * 
 *     def __init__(self, connection, num_responses, fail_on_error):             # <<<<<<<<<<<<<<
 *         self.connection = connection
 *         self.pending = num_responses
 */
  __pyx_tuple__119 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_connection, __pyx_n_s_num_responses, __pyx_n_s_fail_on_error); if (unlikely(!__pyx_tuple__119)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__119);
  __Pyx_GIVEREF(__pyx_tuple__119);
  __pyx_codeobj__120 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__119, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_init, 777, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__120)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":785
 *         self.event = Event()
 * 
 *     def got_response(self, response, index):             # <<<<<<<<<<<<<<
 *         with self.connection.lock:
 *             self.connection.in_flight -= 1
 */
  __pyx_tuple__121 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_response, __pyx_n_s_index); if (unlikely(!__pyx_tuple__121)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__121);
  __Pyx_GIVEREF(__pyx_tuple__121);
  __pyx_codeobj__122 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__121, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_got_response, 785, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__122)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":806
 *             self.event.set()
 * 
 *     def deliver(self, timeout=None):             # <<<<<<<<<<<<<<
 *         """
 *         If fail_on_error was set to False, a list of (success, response)
 */
  __pyx_tuple__123 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__123)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__123);
  __Pyx_GIVEREF(__pyx_tuple__123);
  __pyx_codeobj__124 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__123, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_deliver, 806, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__124)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_tuple__125 = PyTuple_Pack(1, ((PyObject *)Py_None)); if (unlikely(!__pyx_tuple__125)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__125);
  __Pyx_GIVEREF(__pyx_tuple__125);

  /* "cassandra/connection.py":826
 * 
 * class HeartbeatFuture(object):
 *     def __init__(self, connection, owner):             # <<<<<<<<<<<<<<
 *         self._exception = None
 *         self._event = Event()
 */
  __pyx_tuple__126 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_connection, __pyx_n_s_owner); if (unlikely(!__pyx_tuple__126)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__126);
  __Pyx_GIVEREF(__pyx_tuple__126);
  __pyx_codeobj__127 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__126, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_init, 826, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__127)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":841
 *                 self._event.set()
 * 
 *     def wait(self, timeout):             # <<<<<<<<<<<<<<
 *         self._event.wait(timeout)
 *         if self._event.is_set():
 */
  __pyx_tuple__128 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_timeout); if (unlikely(!__pyx_tuple__128)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__128);
  __Pyx_GIVEREF(__pyx_tuple__128);
  __pyx_codeobj__129 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__128, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_wait, 841, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__129)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":849
 *             raise OperationTimedOut()
 * 
 *     def _options_callback(self, response):             # <<<<<<<<<<<<<<
 *         if not isinstance(response, SupportedMessage):
 *             if isinstance(response, ConnectionException):
 */
  __pyx_tuple__130 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_response); if (unlikely(!__pyx_tuple__130)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__130);
  __Pyx_GIVEREF(__pyx_tuple__130);
  __pyx_codeobj__131 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__130, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_options_callback, 849, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__131)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":864
 * class ConnectionHeartbeat(Thread):
 * 
 *     def __init__(self, interval_sec, get_connection_holders):             # <<<<<<<<<<<<<<
 *         Thread.__init__(self, name="Connection heartbeat")
 *         self._interval = interval_sec
 */
  __pyx_tuple__132 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_interval_sec, __pyx_n_s_get_connection_holders); if (unlikely(!__pyx_tuple__132)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__132);
  __Pyx_GIVEREF(__pyx_tuple__132);
  __pyx_codeobj__133 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__132, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_init, 864, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__133)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":875
 *         pass
 * 
 *     def run(self):             # <<<<<<<<<<<<<<
 *         self._shutdown_event.wait(self._interval)
 *         while not self._shutdown_event.is_set():
 */
  __pyx_tuple__134 = PyTuple_Pack(10, __pyx_n_s_self, __pyx_n_s_start_time, __pyx_n_s_futures, __pyx_n_s_failed_connections, __pyx_n_s_connections, __pyx_n_s_owner, __pyx_n_s_connection, __pyx_n_s_f, __pyx_n_s_elapsed, __pyx_n_s_o); if (unlikely(!__pyx_tuple__134)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__134);
  __Pyx_GIVEREF(__pyx_tuple__134);
  __pyx_codeobj__135 = (PyObject*)__Pyx_PyCode_New(1, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__134, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_run, 875, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__135)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":927
 *             self._shutdown_event.wait(max(self._interval - elapsed, 0.01))
 * 
 *     def stop(self):             # <<<<<<<<<<<<<<
 *         self._shutdown_event.set()
 *         self.join()
 */
  __pyx_tuple__136 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__136)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__136);
  __Pyx_GIVEREF(__pyx_tuple__136);
  __pyx_codeobj__137 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__136, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_stop, 927, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__137)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":931
 *         self.join()
 * 
 *     def _raise_if_stopped(self):             # <<<<<<<<<<<<<<
 *         if self._shutdown_event.is_set():
 *             raise self.ShutdownException()
 */
  __pyx_tuple__138 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__138)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__138);
  __Pyx_GIVEREF(__pyx_tuple__138);
  __pyx_codeobj__139 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__138, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_raise_if_stopped, 931, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__139)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":940
 *     canceled = False
 * 
 *     def __init__(self, timeout, callback):             # <<<<<<<<<<<<<<
 *         self.end = time.time() + timeout
 *         self.callback = callback
 */
  __pyx_tuple__140 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_timeout, __pyx_n_s_callback); if (unlikely(!__pyx_tuple__140)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__140);
  __Pyx_GIVEREF(__pyx_tuple__140);
  __pyx_codeobj__141 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__140, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_init, 940, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__141)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":946
 *             self.callback()
 * 
 *     def cancel(self):             # <<<<<<<<<<<<<<
 *         self.canceled = True
 * 
 */
  __pyx_tuple__142 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__142)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__142);
  __Pyx_GIVEREF(__pyx_tuple__142);
  __pyx_codeobj__143 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__142, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_cancel, 946, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__143)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":949
 *         self.canceled = True
 * 
 *     def finish(self, time_now):             # <<<<<<<<<<<<<<
 *         if self.canceled:
 *             return True
 */
  __pyx_tuple__144 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_time_now); if (unlikely(!__pyx_tuple__144)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__144);
  __Pyx_GIVEREF(__pyx_tuple__144);
  __pyx_codeobj__145 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__144, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_finish, 949, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__145)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":962
 * class TimerManager(object):
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self._queue = []
 *         self._new_timers = []
 */
  __pyx_tuple__146 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__146)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__146);
  __Pyx_GIVEREF(__pyx_tuple__146);
  __pyx_codeobj__147 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__146, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_init, 962, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__147)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":966
 *         self._new_timers = []
 * 
 *     def add_timer(self, timer):             # <<<<<<<<<<<<<<
 *         """
 *         called from client thread with a Timer object
 */
  __pyx_tuple__148 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_timer); if (unlikely(!__pyx_tuple__148)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__148);
  __Pyx_GIVEREF(__pyx_tuple__148);
  __pyx_codeobj__149 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__148, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_add_timer, 966, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__149)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":972
 *         self._new_timers.append((timer.end, timer))
 * 
 *     def service_timeouts(self):             # <<<<<<<<<<<<<<
 *         """
 *         run callbacks on all expired timers
 */
  __pyx_tuple__150 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_queue_2, __pyx_n_s_new_timers_2, __pyx_n_s_now, __pyx_n_s_timer); if (unlikely(!__pyx_tuple__150)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__150);
  __Pyx_GIVEREF(__pyx_tuple__150);
  __pyx_codeobj__151 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__150, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_service_timeouts, 972, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__151)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":997
 * 
 *     @property
 *     def next_timeout(self):             # <<<<<<<<<<<<<<
 *         try:
 *             return self._queue[0][0]
 */
  __pyx_tuple__152 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__152)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__152);
  __Pyx_GIVEREF(__pyx_tuple__152);
  __pyx_codeobj__153 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__152, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_adamholmberg_git_python_m, __pyx_n_s_next_timeout, 997, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__153)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_float_0_0 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_float_0_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_float_1_0 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_float_1_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_float_0_01 = PyFloat_FromDouble(0.01); if (unlikely(!__pyx_float_0_01)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_float_0_001 = PyFloat_FromDouble(0.001); if (unlikely(!__pyx_float_0_001)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_127 = PyInt_FromLong(127); if (unlikely(!__pyx_int_127)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_128 = PyInt_FromLong(128); if (unlikely(!__pyx_int_128)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_299 = PyInt_FromLong(299); if (unlikely(!__pyx_int_299)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_300 = PyInt_FromLong(300); if (unlikely(!__pyx_int_300)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_4096 = PyInt_FromLong(4096); if (unlikely(!__pyx_int_4096)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_9042 = PyInt_FromLong(9042); if (unlikely(!__pyx_int_9042)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_32767 = PyInt_FromLong(32767L); if (unlikely(!__pyx_int_32767)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initconnection(void); /*proto*/
PyMODINIT_FUNC initconnection(void)
#else
PyMODINIT_FUNC PyInit_connection(void); /*proto*/
PyMODINIT_FUNC PyInit_connection(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_connection(void)", 0);
  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __Pyx_CyFunction_USED
  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("connection", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  if (__pyx_module_is_main_cassandra__connection) {
    if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!PyDict_GetItemString(modules, "cassandra.connection")) {
      if (unlikely(PyDict_SetItemString(modules, "cassandra.connection", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  if (PyType_Ready(&__pyx_type_9cassandra_10connection___pyx_scope_struct__defunct_on_error) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_9cassandra_10connection___pyx_scope_struct__defunct_on_error.tp_print = 0;
  __pyx_ptype_9cassandra_10connection___pyx_scope_struct__defunct_on_error = &__pyx_type_9cassandra_10connection___pyx_scope_struct__defunct_on_error;
  if (PyType_Ready(&__pyx_type_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async.tp_print = 0;
  __pyx_ptype_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async = &__pyx_type_9cassandra_10connection___pyx_scope_struct_1_set_keyspace_async;
  /*--- Type import code ---*/
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "cassandra/connection.py":16
 * 
 * from __future__ import absolute_import  # to enable import io from stdlib
 * from collections import defaultdict, deque, namedtuple             # <<<<<<<<<<<<<<
 * import errno
 * from functools import wraps, partial
 */
  __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_defaultdict);
  __Pyx_GIVEREF(__pyx_n_s_defaultdict);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_defaultdict);
  __Pyx_INCREF(__pyx_n_s_deque);
  __Pyx_GIVEREF(__pyx_n_s_deque);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_deque);
  __Pyx_INCREF(__pyx_n_s_namedtuple);
  __Pyx_GIVEREF(__pyx_n_s_namedtuple);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_namedtuple);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_collections, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_defaultdict); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_defaultdict, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_deque); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_deque, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_namedtuple); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_namedtuple, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":17
 * from __future__ import absolute_import  # to enable import io from stdlib
 * from collections import defaultdict, deque, namedtuple
 * import errno             # <<<<<<<<<<<<<<
 * from functools import wraps, partial
 * from heapq import heappush, heappop
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_errno, 0, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_errno, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":18
 * from collections import defaultdict, deque, namedtuple
 * import errno
 * from functools import wraps, partial             # <<<<<<<<<<<<<<
 * from heapq import heappush, heappop
 * import io
 */
  __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_wraps);
  __Pyx_GIVEREF(__pyx_n_s_wraps);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_wraps);
  __Pyx_INCREF(__pyx_n_s_partial);
  __Pyx_GIVEREF(__pyx_n_s_partial);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_partial);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_functools, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_wraps); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_wraps, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_partial); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_partial, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":19
 * import errno
 * from functools import wraps, partial
 * from heapq import heappush, heappop             # <<<<<<<<<<<<<<
 * import io
 * import logging
 */
  __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_heappush);
  __Pyx_GIVEREF(__pyx_n_s_heappush);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_heappush);
  __Pyx_INCREF(__pyx_n_s_heappop);
  __Pyx_GIVEREF(__pyx_n_s_heappop);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_heappop);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_heapq, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_heappush); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_heappush, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_heappop); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_heappop, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":20
 * from functools import wraps, partial
 * from heapq import heappush, heappop
 * import io             # <<<<<<<<<<<<<<
 * import logging
 * import socket
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_io, 0, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_io, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":21
 * from heapq import heappush, heappop
 * import io
 * import logging             # <<<<<<<<<<<<<<
 * import socket
 * import struct
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_logging, 0, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_logging, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":22
 * import io
 * import logging
 * import socket             # <<<<<<<<<<<<<<
 * import struct
 * import sys
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_socket, 0, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_socket, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":23
 * import logging
 * import socket
 * import struct             # <<<<<<<<<<<<<<
 * import sys
 * from threading import Thread, Event, RLock
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_struct, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":24
 * import socket
 * import struct
 * import sys             # <<<<<<<<<<<<<<
 * from threading import Thread, Event, RLock
 * import time
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_sys, 0, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":25
 * import struct
 * import sys
 * from threading import Thread, Event, RLock             # <<<<<<<<<<<<<<
 * import time
 * 
 */
  __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_Thread);
  __Pyx_GIVEREF(__pyx_n_s_Thread);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Thread);
  __Pyx_INCREF(__pyx_n_s_Event);
  __Pyx_GIVEREF(__pyx_n_s_Event);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_Event);
  __Pyx_INCREF(__pyx_n_s_RLock);
  __Pyx_GIVEREF(__pyx_n_s_RLock);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_RLock);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_threading, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Thread); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Thread, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Event); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Event, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_RLock); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_RLock, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":26
 * import sys
 * from threading import Thread, Event, RLock
 * import time             # <<<<<<<<<<<<<<
 * 
 * try:
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_time, 0, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_time, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":28
 * import time
 * 
 * try:             # <<<<<<<<<<<<<<
 *     import ssl
 * except ImportError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "cassandra/connection.py":29
 * 
 * try:
 *     import ssl             # <<<<<<<<<<<<<<
 * except ImportError:
 *     ssl = None  # NOQA
 */
      __pyx_t_1 = __Pyx_Import(__pyx_n_s_ssl, 0, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_ssl, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L9_try_end;
    __pyx_L2_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "cassandra/connection.py":30
 * try:
 *     import ssl
 * except ImportError:             # <<<<<<<<<<<<<<
 *     ssl = None  # NOQA
 * 
 */
    __pyx_t_6 = PyErr_ExceptionMatches(__pyx_builtin_ImportError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("cassandra.connection", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_7);

      /* "cassandra/connection.py":31
 *     import ssl
 * except ImportError:
 *     ssl = None  # NOQA             # <<<<<<<<<<<<<<
 * 
 * if 'gevent.monkey' in sys.modules:
 */
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_ssl, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L3_exception_handled;
    }
    goto __pyx_L4_except_error;
    __pyx_L4_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L3_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    __pyx_L9_try_end:;
  }

  /* "cassandra/connection.py":33
 *     ssl = None  # NOQA
 * 
 * if 'gevent.monkey' in sys.modules:             # <<<<<<<<<<<<<<
 *     from gevent.queue import Queue, Empty
 * else:
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_modules); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_8 = (__Pyx_PySequence_Contains(__pyx_kp_s_gevent_monkey, __pyx_t_2, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_9 = (__pyx_t_8 != 0);
  if (__pyx_t_9) {

    /* "cassandra/connection.py":34
 * 
 * if 'gevent.monkey' in sys.modules:
 *     from gevent.queue import Queue, Empty             # <<<<<<<<<<<<<<
 * else:
 *     from six.moves.queue import Queue, Empty  # noqa
 */
    __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_Queue);
    __Pyx_GIVEREF(__pyx_n_s_Queue);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Queue);
    __Pyx_INCREF(__pyx_n_s_Empty);
    __Pyx_GIVEREF(__pyx_n_s_Empty);
    PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_Empty);
    __pyx_t_7 = __Pyx_Import(__pyx_n_s_gevent_queue, __pyx_t_2, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s_Queue); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_Queue, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s_Empty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_Empty, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L12;
  }
  /*else*/ {

    /* "cassandra/connection.py":36
 *     from gevent.queue import Queue, Empty
 * else:
 *     from six.moves.queue import Queue, Empty  # noqa             # <<<<<<<<<<<<<<
 * 
 * import six
 */
    __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_n_s_Queue);
    __Pyx_GIVEREF(__pyx_n_s_Queue);
    PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_Queue);
    __Pyx_INCREF(__pyx_n_s_Empty);
    __Pyx_GIVEREF(__pyx_n_s_Empty);
    PyList_SET_ITEM(__pyx_t_7, 1, __pyx_n_s_Empty);
    __pyx_t_2 = __Pyx_Import(__pyx_n_s_six_moves_queue, __pyx_t_7, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Queue); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_Queue, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Empty); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_d, __pyx_n_s_Empty, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_L12:;

  /* "cassandra/connection.py":38
 *     from six.moves.queue import Queue, Empty  # noqa
 * 
 * import six             # <<<<<<<<<<<<<<
 * from six.moves import range
 * 
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_six, 0, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_six, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":39
 * 
 * import six
 * from six.moves import range             # <<<<<<<<<<<<<<
 * 
 * from cassandra import ConsistencyLevel, AuthenticationFailed, OperationTimedOut
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_range);
  __Pyx_GIVEREF(__pyx_n_s_range);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_range);
  __pyx_t_7 = __Pyx_Import(__pyx_n_s_six_moves, __pyx_t_2, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s_range); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_range, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cassandra/connection.py":41
 * from six.moves import range
 * 
 * from cassandra import ConsistencyLevel, AuthenticationFailed, OperationTimedOut             # <<<<<<<<<<<<<<
 * from cassandra.marshal import int32_pack, uint8_unpack
 * from cassandra.protocol import (ReadyMessage, AuthenticateMessage, OptionsMessage,
 */
  __pyx_t_7 = PyList_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_n_s_ConsistencyLevel);
  __Pyx_GIVEREF(__pyx_n_s_ConsistencyLevel);
  PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_ConsistencyLevel);
  __Pyx_INCREF(__pyx_n_s_AuthenticationFailed);
  __Pyx_GIVEREF(__pyx_n_s_AuthenticationFailed);
  PyList_SET_ITEM(__pyx_t_7, 1, __pyx_n_s_AuthenticationFailed);
  __Pyx_INCREF(__pyx_n_s_OperationTimedOut);
  __Pyx_GIVEREF(__pyx_n_s_OperationTimedOut);
  PyList_SET_ITEM(__pyx_t_7, 2, __pyx_n_s_OperationTimedOut);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cassandra, __pyx_t_7, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ConsistencyLevel); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ConsistencyLevel, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_AuthenticationFailed); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_AuthenticationFailed, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_OperationTimedOut); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_OperationTimedOut, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":42
 * 
 * from cassandra import ConsistencyLevel, AuthenticationFailed, OperationTimedOut
 * from cassandra.marshal import int32_pack, uint8_unpack             # <<<<<<<<<<<<<<
 * from cassandra.protocol import (ReadyMessage, AuthenticateMessage, OptionsMessage,
 *                                 StartupMessage, ErrorMessage, CredentialsMessage,
 */
  __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_int32_pack);
  __Pyx_GIVEREF(__pyx_n_s_int32_pack);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_int32_pack);
  __Pyx_INCREF(__pyx_n_s_uint8_unpack);
  __Pyx_GIVEREF(__pyx_n_s_uint8_unpack);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_uint8_unpack);
  __pyx_t_7 = __Pyx_Import(__pyx_n_s_cassandra_marshal, __pyx_t_2, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s_int32_pack); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_int32_pack, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s_uint8_unpack); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_uint8_unpack, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cassandra/connection.py":43
 * from cassandra import ConsistencyLevel, AuthenticationFailed, OperationTimedOut
 * from cassandra.marshal import int32_pack, uint8_unpack
 * from cassandra.protocol import (ReadyMessage, AuthenticateMessage, OptionsMessage,             # <<<<<<<<<<<<<<
 *                                 StartupMessage, ErrorMessage, CredentialsMessage,
 *                                 QueryMessage, ResultMessage, ProtocolHandler,
 */
  __pyx_t_7 = PyList_New(17); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_n_s_ReadyMessage);
  __Pyx_GIVEREF(__pyx_n_s_ReadyMessage);
  PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_ReadyMessage);
  __Pyx_INCREF(__pyx_n_s_AuthenticateMessage);
  __Pyx_GIVEREF(__pyx_n_s_AuthenticateMessage);
  PyList_SET_ITEM(__pyx_t_7, 1, __pyx_n_s_AuthenticateMessage);
  __Pyx_INCREF(__pyx_n_s_OptionsMessage);
  __Pyx_GIVEREF(__pyx_n_s_OptionsMessage);
  PyList_SET_ITEM(__pyx_t_7, 2, __pyx_n_s_OptionsMessage);
  __Pyx_INCREF(__pyx_n_s_StartupMessage);
  __Pyx_GIVEREF(__pyx_n_s_StartupMessage);
  PyList_SET_ITEM(__pyx_t_7, 3, __pyx_n_s_StartupMessage);
  __Pyx_INCREF(__pyx_n_s_ErrorMessage);
  __Pyx_GIVEREF(__pyx_n_s_ErrorMessage);
  PyList_SET_ITEM(__pyx_t_7, 4, __pyx_n_s_ErrorMessage);
  __Pyx_INCREF(__pyx_n_s_CredentialsMessage);
  __Pyx_GIVEREF(__pyx_n_s_CredentialsMessage);
  PyList_SET_ITEM(__pyx_t_7, 5, __pyx_n_s_CredentialsMessage);
  __Pyx_INCREF(__pyx_n_s_QueryMessage);
  __Pyx_GIVEREF(__pyx_n_s_QueryMessage);
  PyList_SET_ITEM(__pyx_t_7, 6, __pyx_n_s_QueryMessage);
  __Pyx_INCREF(__pyx_n_s_ResultMessage);
  __Pyx_GIVEREF(__pyx_n_s_ResultMessage);
  PyList_SET_ITEM(__pyx_t_7, 7, __pyx_n_s_ResultMessage);
  __Pyx_INCREF(__pyx_n_s_ProtocolHandler);
  __Pyx_GIVEREF(__pyx_n_s_ProtocolHandler);
  PyList_SET_ITEM(__pyx_t_7, 8, __pyx_n_s_ProtocolHandler);
  __Pyx_INCREF(__pyx_n_s_InvalidRequestException);
  __Pyx_GIVEREF(__pyx_n_s_InvalidRequestException);
  PyList_SET_ITEM(__pyx_t_7, 9, __pyx_n_s_InvalidRequestException);
  __Pyx_INCREF(__pyx_n_s_SupportedMessage);
  __Pyx_GIVEREF(__pyx_n_s_SupportedMessage);
  PyList_SET_ITEM(__pyx_t_7, 10, __pyx_n_s_SupportedMessage);
  __Pyx_INCREF(__pyx_n_s_AuthResponseMessage);
  __Pyx_GIVEREF(__pyx_n_s_AuthResponseMessage);
  PyList_SET_ITEM(__pyx_t_7, 11, __pyx_n_s_AuthResponseMessage);
  __Pyx_INCREF(__pyx_n_s_AuthChallengeMessage);
  __Pyx_GIVEREF(__pyx_n_s_AuthChallengeMessage);
  PyList_SET_ITEM(__pyx_t_7, 12, __pyx_n_s_AuthChallengeMessage);
  __Pyx_INCREF(__pyx_n_s_AuthSuccessMessage);
  __Pyx_GIVEREF(__pyx_n_s_AuthSuccessMessage);
  PyList_SET_ITEM(__pyx_t_7, 13, __pyx_n_s_AuthSuccessMessage);
  __Pyx_INCREF(__pyx_n_s_ProtocolException);
  __Pyx_GIVEREF(__pyx_n_s_ProtocolException);
  PyList_SET_ITEM(__pyx_t_7, 14, __pyx_n_s_ProtocolException);
  __Pyx_INCREF(__pyx_n_s_MAX_SUPPORTED_VERSION);
  __Pyx_GIVEREF(__pyx_n_s_MAX_SUPPORTED_VERSION);
  PyList_SET_ITEM(__pyx_t_7, 15, __pyx_n_s_MAX_SUPPORTED_VERSION);
  __Pyx_INCREF(__pyx_n_s_RegisterMessage);
  __Pyx_GIVEREF(__pyx_n_s_RegisterMessage);
  PyList_SET_ITEM(__pyx_t_7, 16, __pyx_n_s_RegisterMessage);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_cassandra_protocol, __pyx_t_7, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ReadyMessage); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ReadyMessage, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_AuthenticateMessage); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_AuthenticateMessage, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_OptionsMessage); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_OptionsMessage, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_StartupMessage); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_StartupMessage, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ErrorMessage); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ErrorMessage, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_CredentialsMessage); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_CredentialsMessage, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_QueryMessage); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_QueryMessage, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ResultMessage); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ResultMessage, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ProtocolHandler); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ProtocolHandler, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_InvalidRequestException); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_InvalidRequestException, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_SupportedMessage); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_SupportedMessage, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_AuthResponseMessage); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_AuthResponseMessage, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_AuthChallengeMessage); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_AuthChallengeMessage, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_AuthSuccessMessage); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_AuthSuccessMessage, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ProtocolException); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ProtocolException, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_MAX_SUPPORTED_VERSION); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_MAX_SUPPORTED_VERSION, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_RegisterMessage); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_RegisterMessage, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":50
 *                                 AuthSuccessMessage, ProtocolException,
 *                                 MAX_SUPPORTED_VERSION, RegisterMessage)
 * from cassandra.util import OrderedDict             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_OrderedDict);
  __Pyx_GIVEREF(__pyx_n_s_OrderedDict);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_OrderedDict);
  __pyx_t_7 = __Pyx_Import(__pyx_n_s_cassandra_util, __pyx_t_2, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_OrderedDict, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cassandra/connection.py":53
 * 
 * 
 * log = logging.getLogger(__name__)             # <<<<<<<<<<<<<<
 * 
 * # We use an ordered dictionary and specifically add lz4 before
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_logging); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_getLogger); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_10) {
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_7);
  } else {
    __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_log, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cassandra/connection.py":58
 * # snappy so that lz4 will be preferred. Changing the order of this
 * # will change the compression preferences for the driver.
 * locally_supported_compressions = OrderedDict()             # <<<<<<<<<<<<<<
 * 
 * try:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_11 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (__pyx_t_11) {
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_11); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else {
    __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_locally_supported_compressions, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cassandra/connection.py":60
 * locally_supported_compressions = OrderedDict()
 * 
 * try:             # <<<<<<<<<<<<<<
 *     import lz4
 * except ImportError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_4, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "cassandra/connection.py":61
 * 
 * try:
 *     import lz4             # <<<<<<<<<<<<<<
 * except ImportError:
 *     pass
 */
      __pyx_t_7 = __Pyx_Import(__pyx_n_s_lz4, 0, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_lz4, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L13_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    /*else:*/ {

      /* "cassandra/connection.py":70
 *     # functions to handle that
 * 
 *     def lz4_compress(byts):             # <<<<<<<<<<<<<<
 *         # write length in big-endian instead of little-endian
 *         return int32_pack(len(byts)) + lz4.compress(byts)[4:]
 */
      __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_1lz4_compress, 0, __pyx_n_s_lz4_compress, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__35)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_lz4_compress, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "cassandra/connection.py":74
 *         return int32_pack(len(byts)) + lz4.compress(byts)[4:]
 * 
 *     def lz4_decompress(byts):             # <<<<<<<<<<<<<<
 *         # flip from big-endian to little-endian
 *         return lz4.decompress(byts[3::-1] + byts[4:])
 */
      __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_3lz4_decompress, 0, __pyx_n_s_lz4_decompress, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__37)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_lz4_decompress, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "cassandra/connection.py":78
 *         return lz4.decompress(byts[3::-1] + byts[4:])
 * 
 *     locally_supported_compressions['lz4'] = (lz4_compress, lz4_decompress)             # <<<<<<<<<<<<<<
 * 
 * try:
 */
      __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_lz4_compress); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_lz4_decompress); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_1);
      __pyx_t_7 = 0;
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_locally_supported_compressions); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_n_s_lz4, __pyx_t_11) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L15_except_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L20_try_end;
    __pyx_L13_error:;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "cassandra/connection.py":62
 * try:
 *     import lz4
 * except ImportError:             # <<<<<<<<<<<<<<
 *     pass
 * else:
 */
    __pyx_t_6 = PyErr_ExceptionMatches(__pyx_builtin_ImportError);
    if (__pyx_t_6) {
      PyErr_Restore(0,0,0);
      goto __pyx_L14_exception_handled;
    }
    goto __pyx_L15_except_error;
    __pyx_L15_except_error:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L14_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_4, __pyx_t_3);
    __pyx_L20_try_end:;
  }

  /* "cassandra/connection.py":80
 *     locally_supported_compressions['lz4'] = (lz4_compress, lz4_decompress)
 * 
 * try:             # <<<<<<<<<<<<<<
 *     import snappy
 * except ImportError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "cassandra/connection.py":81
 * 
 * try:
 *     import snappy             # <<<<<<<<<<<<<<
 * except ImportError:
 *     pass
 */
      __pyx_t_11 = __Pyx_Import(__pyx_n_s_snappy, 0, 0); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L21_error;}
      __Pyx_GOTREF(__pyx_t_11);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_snappy, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L21_error;}
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    /*else:*/ {

      /* "cassandra/connection.py":86
 * else:
 *     # work around apparently buggy snappy decompress
 *     def decompress(byts):             # <<<<<<<<<<<<<<
 *         if byts == '\x00':
 *             return ''
 */
      __pyx_t_11 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_5decompress, 0, __pyx_n_s_decompress, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__39)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L23_except_error;}
      __Pyx_GOTREF(__pyx_t_11);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_decompress, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L23_except_error;}
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

      /* "cassandra/connection.py":90
 *             return ''
 *         return snappy.decompress(byts)
 *     locally_supported_compressions['snappy'] = (snappy.compress, decompress)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_snappy); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L23_except_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_compress); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L23_except_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_decompress); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L23_except_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L23_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_11);
      __pyx_t_1 = 0;
      __pyx_t_11 = 0;
      __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_locally_supported_compressions); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L23_except_error;}
      __Pyx_GOTREF(__pyx_t_11);
      if (unlikely(PyObject_SetItem(__pyx_t_11, __pyx_n_s_snappy, __pyx_t_7) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L23_except_error;}
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L28_try_end;
    __pyx_L21_error:;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;

    /* "cassandra/connection.py":82
 * try:
 *     import snappy
 * except ImportError:             # <<<<<<<<<<<<<<
 *     pass
 * else:
 */
    __pyx_t_6 = PyErr_ExceptionMatches(__pyx_builtin_ImportError);
    if (__pyx_t_6) {
      PyErr_Restore(0,0,0);
      goto __pyx_L22_exception_handled;
    }
    goto __pyx_L23_except_error;
    __pyx_L23_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L22_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    __pyx_L28_try_end:;
  }

  /* "cassandra/connection.py":93
 * 
 * 
 * PROTOCOL_VERSION_MASK = 0x7f             # <<<<<<<<<<<<<<
 * 
 * HEADER_DIRECTION_FROM_CLIENT = 0x00
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_PROTOCOL_VERSION_MASK, __pyx_int_127) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":95
 * PROTOCOL_VERSION_MASK = 0x7f
 * 
 * HEADER_DIRECTION_FROM_CLIENT = 0x00             # <<<<<<<<<<<<<<
 * HEADER_DIRECTION_TO_CLIENT = 0x80
 * HEADER_DIRECTION_MASK = 0x80
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_HEADER_DIRECTION_FROM_CLIENT, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":96
 * 
 * HEADER_DIRECTION_FROM_CLIENT = 0x00
 * HEADER_DIRECTION_TO_CLIENT = 0x80             # <<<<<<<<<<<<<<
 * HEADER_DIRECTION_MASK = 0x80
 * 
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_HEADER_DIRECTION_TO_CLIENT, __pyx_int_128) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":97
 * HEADER_DIRECTION_FROM_CLIENT = 0x00
 * HEADER_DIRECTION_TO_CLIENT = 0x80
 * HEADER_DIRECTION_MASK = 0x80             # <<<<<<<<<<<<<<
 * 
 * frame_header_v1_v2 = struct.Struct('>BbBi')
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_HEADER_DIRECTION_MASK, __pyx_int_128) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":99
 * HEADER_DIRECTION_MASK = 0x80
 * 
 * frame_header_v1_v2 = struct.Struct('>BbBi')             # <<<<<<<<<<<<<<
 * frame_header_v3 = struct.Struct('>BhBi')
 * 
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_Struct); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_frame_header_v1_v2, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cassandra/connection.py":100
 * 
 * frame_header_v1_v2 = struct.Struct('>BbBi')
 * frame_header_v3 = struct.Struct('>BhBi')             # <<<<<<<<<<<<<<
 * 
 * _Frame = namedtuple('Frame', ('version', 'flags', 'stream', 'opcode', 'body_offset', 'end_pos'))
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_Struct); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_frame_header_v3, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "cassandra/connection.py":102
 * frame_header_v3 = struct.Struct('>BhBi')
 * 
 * _Frame = namedtuple('Frame', ('version', 'flags', 'stream', 'opcode', 'body_offset', 'end_pos'))             # <<<<<<<<<<<<<<
 * 
 * NONBLOCKING = (errno.EAGAIN, errno.EWOULDBLOCK)
 */
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_namedtuple); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Frame, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cassandra/connection.py":104
 * _Frame = namedtuple('Frame', ('version', 'flags', 'stream', 'opcode', 'body_offset', 'end_pos'))
 * 
 * NONBLOCKING = (errno.EAGAIN, errno.EWOULDBLOCK)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_errno); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_EAGAIN); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_errno); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_EWOULDBLOCK); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_1);
  __pyx_t_7 = 0;
  __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_NONBLOCKING, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cassandra/connection.py":107
 * 
 * 
 * class ConnectionException(Exception):             # <<<<<<<<<<<<<<
 *     """
 *     An unrecoverable error was hit when attempting to use a connection,
 */
  __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_INCREF(__pyx_builtin_Exception);
  __Pyx_GIVEREF(__pyx_builtin_Exception);
  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_builtin_Exception);
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_11); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_11, __pyx_n_s_ConnectionException, __pyx_n_s_ConnectionException, (PyObject *) NULL, __pyx_n_s_cassandra_connection, __pyx_kp_s_An_unrecoverable_error_was_hit); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);

  /* "cassandra/connection.py":113
 *     """
 * 
 *     def __init__(self, message, host=None):             # <<<<<<<<<<<<<<
 *         Exception.__init__(self, message)
 *         self.host = host
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_19ConnectionException_1__init__, 0, __pyx_n_s_ConnectionException___init, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__45)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__46);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_init, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":107
 * 
 * 
 * class ConnectionException(Exception):             # <<<<<<<<<<<<<<
 *     """
 *     An unrecoverable error was hit when attempting to use a connection,
 */
  __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_ConnectionException, __pyx_t_11, __pyx_t_7, NULL, 0, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ConnectionException, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cassandra/connection.py":118
 * 
 * 
 * class ConnectionShutdown(ConnectionException):             # <<<<<<<<<<<<<<
 *     """
 *     Raised when a connection has been marked as defunct or has been closed.
 */
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConnectionException); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11);
  __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_7 = __Pyx_Py3MetaclassPrepare(__pyx_t_11, __pyx_t_1, __pyx_n_s_ConnectionShutdown, __pyx_n_s_ConnectionShutdown, (PyObject *) NULL, __pyx_n_s_cassandra_connection, __pyx_kp_s_Raised_when_a_connection_has_be); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_11, __pyx_n_s_ConnectionShutdown, __pyx_t_1, __pyx_t_7, NULL, 0, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ConnectionShutdown, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":124
 *     pass
 * 
 * class ProtocolVersionUnsupported(ConnectionException):             # <<<<<<<<<<<<<<
 *     """
 *     Server rejected startup message due to unsupported protocol version
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_ConnectionException); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_11); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_11, __pyx_n_s_ProtocolVersionUnsupported, __pyx_n_s_ProtocolVersionUnsupported, (PyObject *) NULL, __pyx_n_s_cassandra_connection, __pyx_kp_s_Server_rejected_startup_message); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);

  /* "cassandra/connection.py":128
 *     Server rejected startup message due to unsupported protocol version
 *     """
 *     def __init__(self, host, startup_version):             # <<<<<<<<<<<<<<
 *         super(ProtocolVersionUnsupported, self).__init__("Unsupported protocol version on %s: %d",
 *                                                          (host, startup_version))
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_26ProtocolVersionUnsupported_1__init__, 0, __pyx_n_s_ProtocolVersionUnsupported___ini, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__48)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_init, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":124
 *     pass
 * 
 * class ProtocolVersionUnsupported(ConnectionException):             # <<<<<<<<<<<<<<
 *     """
 *     Server rejected startup message due to unsupported protocol version
 */
  __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_ProtocolVersionUnsupported, __pyx_t_11, __pyx_t_7, NULL, 0, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ProtocolVersionUnsupported, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cassandra/connection.py":133
 *         self.startup_version = startup_version
 * 
 * class ConnectionBusy(Exception):             # <<<<<<<<<<<<<<
 *     """
 *     An attempt was made to send a message through a :class:`.Connection` that
 */
  __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_INCREF(__pyx_builtin_Exception);
  __Pyx_GIVEREF(__pyx_builtin_Exception);
  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_builtin_Exception);
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_11); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_11, __pyx_n_s_ConnectionBusy, __pyx_n_s_ConnectionBusy, (PyObject *) NULL, __pyx_n_s_cassandra_connection, __pyx_kp_s_An_attempt_was_made_to_send_a_m); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_ConnectionBusy, __pyx_t_11, __pyx_t_7, NULL, 0, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ConnectionBusy, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cassandra/connection.py":141
 * 
 * 
 * class ProtocolError(Exception):             # <<<<<<<<<<<<<<
 *     """
 *     Communication did not match the protocol that this driver expects.
 */
  __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_INCREF(__pyx_builtin_Exception);
  __Pyx_GIVEREF(__pyx_builtin_Exception);
  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_builtin_Exception);
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_11); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_11, __pyx_n_s_ProtocolError, __pyx_n_s_ProtocolError, (PyObject *) NULL, __pyx_n_s_cassandra_connection, __pyx_kp_s_Communication_did_not_match_the); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_ProtocolError, __pyx_t_11, __pyx_t_7, NULL, 0, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ProtocolError, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cassandra/connection.py":148
 * 
 * 
 * def defunct_on_error(f):             # <<<<<<<<<<<<<<
 * 
 *     @wraps(f)
 */
  __pyx_t_11 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_7defunct_on_error, 0, __pyx_n_s_defunct_on_error, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__50)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_defunct_on_error, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cassandra/connection.py":159
 * 
 * 
 * DEFAULT_CQL_VERSION = '3.0.0'             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_DEFAULT_CQL_VERSION, __pyx_kp_s_3_0_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":162
 * 
 * 
 * class Connection(object):             # <<<<<<<<<<<<<<
 * 
 *     in_buffer_size = 4096
 */
  __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_INCREF(__pyx_builtin_object);
  __Pyx_GIVEREF(__pyx_builtin_object);
  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_builtin_object);
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_11); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_11, __pyx_n_s_Connection, __pyx_n_s_Connection, (PyObject *) NULL, __pyx_n_s_cassandra_connection, (PyObject *) NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);

  /* "cassandra/connection.py":164
 * class Connection(object):
 * 
 *     in_buffer_size = 4096             # <<<<<<<<<<<<<<
 *     out_buffer_size = 4096
 * 
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_in_buffer_size, __pyx_int_4096) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":165
 * 
 *     in_buffer_size = 4096
 *     out_buffer_size = 4096             # <<<<<<<<<<<<<<
 * 
 *     cql_version = None
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_out_buffer_size, __pyx_int_4096) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":167
 *     out_buffer_size = 4096
 * 
 *     cql_version = None             # <<<<<<<<<<<<<<
 *     protocol_version = MAX_SUPPORTED_VERSION
 * 
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_cql_version, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":168
 * 
 *     cql_version = None
 *     protocol_version = MAX_SUPPORTED_VERSION             # <<<<<<<<<<<<<<
 * 
 *     keyspace = None
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_MAX_SUPPORTED_VERSION); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_protocol_version, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":170
 *     protocol_version = MAX_SUPPORTED_VERSION
 * 
 *     keyspace = None             # <<<<<<<<<<<<<<
 *     compression = True
 *     compressor = None
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_keyspace, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":171
 * 
 *     keyspace = None
 *     compression = True             # <<<<<<<<<<<<<<
 *     compressor = None
 *     decompressor = None
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_compression, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":172
 *     keyspace = None
 *     compression = True
 *     compressor = None             # <<<<<<<<<<<<<<
 *     decompressor = None
 * 
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_compressor, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":173
 *     compression = True
 *     compressor = None
 *     decompressor = None             # <<<<<<<<<<<<<<
 * 
 *     ssl_options = None
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_decompressor, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":175
 *     decompressor = None
 * 
 *     ssl_options = None             # <<<<<<<<<<<<<<
 *     last_error = None
 * 
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_ssl_options, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":176
 * 
 *     ssl_options = None
 *     last_error = None             # <<<<<<<<<<<<<<
 * 
 *     # The current number of operations that are in flight. More precisely,
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_last_error, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":180
 *     # The current number of operations that are in flight. More precisely,
 *     # the number of request IDs that are currently in use.
 *     in_flight = 0             # <<<<<<<<<<<<<<
 * 
 *     # A set of available request IDs.  When using the v3 protocol or higher,
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_in_flight, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":185
 *     # this will not initially include all request IDs in order to save memory,
 *     # but the set will grow if it is exhausted.
 *     request_ids = None             # <<<<<<<<<<<<<<
 * 
 *     # Tracks the highest used request ID in order to help with growing the
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_request_ids, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":189
 *     # Tracks the highest used request ID in order to help with growing the
 *     # request_ids set
 *     highest_request_id = 0             # <<<<<<<<<<<<<<
 * 
 *     is_defunct = False
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_highest_request_id, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":191
 *     highest_request_id = 0
 * 
 *     is_defunct = False             # <<<<<<<<<<<<<<
 *     is_closed = False
 *     lock = None
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_is_defunct, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":192
 * 
 *     is_defunct = False
 *     is_closed = False             # <<<<<<<<<<<<<<
 *     lock = None
 *     user_type_map = None
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_is_closed, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":193
 *     is_defunct = False
 *     is_closed = False
 *     lock = None             # <<<<<<<<<<<<<<
 *     user_type_map = None
 * 
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_lock, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":194
 *     is_closed = False
 *     lock = None
 *     user_type_map = None             # <<<<<<<<<<<<<<
 * 
 *     msg_received = False
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_user_type_map, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":196
 *     user_type_map = None
 * 
 *     msg_received = False             # <<<<<<<<<<<<<<
 * 
 *     is_unsupported_proto_version = False
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_msg_received, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":198
 *     msg_received = False
 * 
 *     is_unsupported_proto_version = False             # <<<<<<<<<<<<<<
 * 
 *     is_control_connection = False
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_is_unsupported_proto_version, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":200
 *     is_unsupported_proto_version = False
 * 
 *     is_control_connection = False             # <<<<<<<<<<<<<<
 *     _iobuf = None
 *     _current_frame = None
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_is_control_connection, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":201
 * 
 *     is_control_connection = False
 *     _iobuf = None             # <<<<<<<<<<<<<<
 *     _current_frame = None
 * 
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_iobuf, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":202
 *     is_control_connection = False
 *     _iobuf = None
 *     _current_frame = None             # <<<<<<<<<<<<<<
 * 
 *     _socket = None
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_current_frame, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":204
 *     _current_frame = None
 * 
 *     _socket = None             # <<<<<<<<<<<<<<
 * 
 *     _socket_impl = socket
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_socket_2, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":206
 *     _socket = None
 * 
 *     _socket_impl = socket             # <<<<<<<<<<<<<<
 *     _ssl_impl = ssl
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_socket); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_socket_impl, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":207
 * 
 *     _socket_impl = socket
 *     _ssl_impl = ssl             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, host='127.0.0.1', port=9042, authenticator=None,
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_ssl); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_ssl_impl, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":209
 *     _ssl_impl = ssl
 * 
 *     def __init__(self, host='127.0.0.1', port=9042, authenticator=None,             # <<<<<<<<<<<<<<
 *                  ssl_options=None, sockopts=None, compression=True,
 *                  cql_version=None, protocol_version=MAX_SUPPORTED_VERSION, is_control_connection=False,
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_1__init__, 0, __pyx_n_s_Connection___init, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__52)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults), 1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":211
 *     def __init__(self, host='127.0.0.1', port=9042, authenticator=None,
 *                  ssl_options=None, sockopts=None, compression=True,
 *                  cql_version=None, protocol_version=MAX_SUPPORTED_VERSION, is_control_connection=False,             # <<<<<<<<<<<<<<
 *                  user_type_map=None):
 *         self.host = host
 */
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_MAX_SUPPORTED_VERSION); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_t_2)->__pyx_arg_protocol_version = __pyx_t_10;
  __Pyx_GIVEREF(__pyx_t_10);
  __pyx_t_10 = 0;
  __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_2, __pyx_pf_9cassandra_10connection_10Connection_62__defaults__);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_init, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":242
 * 
 *     @classmethod
 *     def initialize_reactor(self):             # <<<<<<<<<<<<<<
 *         """
 *         Called once by Cluster.connect().  This should be used by implementations
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_3initialize_reactor, __Pyx_CYFUNCTION_CLASSMETHOD, __pyx_n_s_Connection_initialize_reactor, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__54)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "cassandra/connection.py":241
 *         self.connected_event = Event()
 * 
 *     @classmethod             # <<<<<<<<<<<<<<
 *     def initialize_reactor(self):
 *         """
 */
  __pyx_t_10 = __Pyx_Method_ClassMethod(__pyx_t_2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_initialize_reactor, __pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "cassandra/connection.py":250
 * 
 *     @classmethod
 *     def handle_fork(self):             # <<<<<<<<<<<<<<
 *         """
 *         Called after a forking.  This should cleanup any remaining reactor state
 */
  __pyx_t_10 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_5handle_fork, __Pyx_CYFUNCTION_CLASSMETHOD, __pyx_n_s_Connection_handle_fork, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__56)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);

  /* "cassandra/connection.py":249
 *         pass
 * 
 *     @classmethod             # <<<<<<<<<<<<<<
 *     def handle_fork(self):
 *         """
 */
  __pyx_t_2 = __Pyx_Method_ClassMethod(__pyx_t_10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_handle_fork, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":258
 * 
 *     @classmethod
 *     def create_timer(cls, timeout, callback):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError()
 * 
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_7create_timer, __Pyx_CYFUNCTION_CLASSMETHOD, __pyx_n_s_Connection_create_timer, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__58)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "cassandra/connection.py":257
 *         pass
 * 
 *     @classmethod             # <<<<<<<<<<<<<<
 *     def create_timer(cls, timeout, callback):
 *         raise NotImplementedError()
 */
  __pyx_t_10 = __Pyx_Method_ClassMethod(__pyx_t_2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_create_timer, __pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "cassandra/connection.py":262
 * 
 *     @classmethod
 *     def factory(cls, host, timeout, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         """
 *         A factory function which returns connections which have
 */
  __pyx_t_10 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_9factory, __Pyx_CYFUNCTION_CLASSMETHOD, __pyx_n_s_Connection_factory, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__60)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);

  /* "cassandra/connection.py":261
 *         raise NotImplementedError()
 * 
 *     @classmethod             # <<<<<<<<<<<<<<
 *     def factory(cls, host, timeout, *args, **kwargs):
 *         """
 */
  __pyx_t_2 = __Pyx_Method_ClassMethod(__pyx_t_10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_factory, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":280
 *             return conn
 * 
 *     def _connect_socket(self):             # <<<<<<<<<<<<<<
 *         sockerr = None
 *         addresses = socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM)
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_11_connect_socket, 0, __pyx_n_s_Connection__connect_socket, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__62)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_connect_socket, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":307
 *                 self._socket.setsockopt(*args)
 * 
 *     def close(self):             # <<<<<<<<<<<<<<
 *         raise NotImplementedError()
 * 
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_13close, 0, __pyx_n_s_Connection_close, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__64)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_close, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":310
 *         raise NotImplementedError()
 * 
 *     def defunct(self, exc):             # <<<<<<<<<<<<<<
 *         with self.lock:
 *             if self.is_defunct or self.is_closed:
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_15defunct, 0, __pyx_n_s_Connection_defunct, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__66)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_defunct, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":325
 *         return exc
 * 
 *     def error_all_requests(self, exc):             # <<<<<<<<<<<<<<
 *         with self.lock:
 *             requests = self._requests
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_17error_all_requests, 0, __pyx_n_s_Connection_error_all_requests, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__69)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_error_all_requests, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":338
 *                             id(self), self.host, exc_info=True)
 * 
 *     def get_request_id(self):             # <<<<<<<<<<<<<<
 *         """
 *         This must be called while self.lock is held.
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_19get_request_id, 0, __pyx_n_s_Connection_get_request_id, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__71)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_get_request_id, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":350
 *             return self.highest_request_id
 * 
 *     def handle_pushed(self, response):             # <<<<<<<<<<<<<<
 *         log.debug("Message pushed from server: %r", response)
 *         for cb in self._push_watchers.get(response.event_type, []):
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_21handle_pushed, 0, __pyx_n_s_Connection_handle_pushed, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__73)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_handle_pushed, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":358
 *                 log.exception("Pushed event handler errored, ignoring:")
 * 
 *     def send_msg(self, msg, request_id, cb, encoder=ProtocolHandler.encode_message, decoder=ProtocolHandler.decode_message):             # <<<<<<<<<<<<<<
 *         if self.is_defunct:
 *             raise ConnectionShutdown("Connection to %s is defunct" % self.host)
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_23send_msg, 0, __pyx_n_s_Connection_send_msg, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__75)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults1), 2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_ProtocolHandler); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_encode_message); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_t_2)->__pyx_arg_encoder = __pyx_t_12;
  __Pyx_GIVEREF(__pyx_t_12);
  __pyx_t_12 = 0;
  __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_ProtocolHandler); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_decode_message); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_t_2)->__pyx_arg_decoder = __pyx_t_10;
  __Pyx_GIVEREF(__pyx_t_10);
  __pyx_t_10 = 0;
  __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_2, __pyx_pf_9cassandra_10connection_10Connection_64__defaults__);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_send_msg, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":370
 *         return request_id
 * 
 *     def wait_for_response(self, msg, timeout=None):             # <<<<<<<<<<<<<<
 *         return self.wait_for_responses(msg, timeout=timeout)[0]
 * 
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_25wait_for_response, 0, __pyx_n_s_Connection_wait_for_response, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__77)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__78);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_wait_for_response, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":373
 *         return self.wait_for_responses(msg, timeout=timeout)[0]
 * 
 *     def wait_for_responses(self, *msgs, **kwargs):             # <<<<<<<<<<<<<<
 *         """
 *         Returns a list of (success, response) tuples.  If success
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_27wait_for_responses, 0, __pyx_n_s_Connection_wait_for_responses, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__80)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_wait_for_responses, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":420
 *             raise
 * 
 *     def register_watcher(self, event_type, callback, register_timeout=None):             # <<<<<<<<<<<<<<
 *         """
 *         Register a callback for a given event type.
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_29register_watcher, 0, __pyx_n_s_Connection_register_watcher, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__82)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__83);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_register_watcher, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":429
 *             timeout=register_timeout)
 * 
 *     def register_watchers(self, type_callback_dict, register_timeout=None):             # <<<<<<<<<<<<<<
 *         """
 *         Register multiple callback/event type pairs, expressed as a dict.
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_31register_watchers, 0, __pyx_n_s_Connection_register_watchers, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__85)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__86);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_register_watchers, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":439
 *             timeout=register_timeout)
 * 
 *     def control_conn_disposed(self):             # <<<<<<<<<<<<<<
 *         self.is_control_connection = False
 *         self._push_watchers = {}
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_33control_conn_disposed, 0, __pyx_n_s_Connection_control_conn_disposed, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__88)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_control_conn_disposed, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":443
 *         self._push_watchers = {}
 * 
 *     @defunct_on_error             # <<<<<<<<<<<<<<
 *     def _read_frame_header(self):
 *         buf = self._iobuf
 */
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_defunct_on_error); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);

  /* "cassandra/connection.py":444
 * 
 *     @defunct_on_error
 *     def _read_frame_header(self):             # <<<<<<<<<<<<<<
 *         buf = self._iobuf
 *         pos = buf.tell()
 */
  __pyx_t_12 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_35_read_frame_header, 0, __pyx_n_s_Connection__read_frame_header, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__90)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  if (!__pyx_t_13) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_12); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_14, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_read_frame_header, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":465
 *         return pos
 * 
 *     def _reset_frame(self):             # <<<<<<<<<<<<<<
 *         leftover = self._iobuf.read()
 *         self._iobuf = io.BytesIO()
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_37_reset_frame, 0, __pyx_n_s_Connection__reset_frame, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__92)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_reset_frame, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":471
 *         self._current_frame = None
 * 
 *     def process_io_buffer(self):             # <<<<<<<<<<<<<<
 *         while True:
 *             if not self._current_frame:
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_39process_io_buffer, 0, __pyx_n_s_Connection_process_io_buffer, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__94)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_process_io_buffer, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":490
 *                 self._reset_frame()
 * 
 *     @defunct_on_error             # <<<<<<<<<<<<<<
 *     def process_msg(self, header, body):
 *         stream_id = header.stream
 */
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_defunct_on_error); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);

  /* "cassandra/connection.py":491
 * 
 *     @defunct_on_error
 *     def process_msg(self, header, body):             # <<<<<<<<<<<<<<
 *         stream_id = header.stream
 *         if stream_id < 0:
 */
  __pyx_t_14 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_41process_msg, 0, __pyx_n_s_Connection_process_msg, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__96)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_12 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  if (!__pyx_t_12) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); __pyx_t_12 = NULL;
    __Pyx_GIVEREF(__pyx_t_14);
    PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_14);
    __pyx_t_14 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_13, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_process_msg, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":529
 *             log.exception("Callback handler errored, ignoring:")
 * 
 *     @defunct_on_error             # <<<<<<<<<<<<<<
 *     def _send_options_message(self):
 *         if self.cql_version is None and (not self.compression or not locally_supported_compressions):
 */
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_defunct_on_error); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);

  /* "cassandra/connection.py":530
 * 
 *     @defunct_on_error
 *     def _send_options_message(self):             # <<<<<<<<<<<<<<
 *         if self.cql_version is None and (not self.compression or not locally_supported_compressions):
 *             log.debug("Not sending options message for new connection(%s) to %s "
 */
  __pyx_t_13 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_43_send_options_message, 0, __pyx_n_s_Connection__send_options_message, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__98)); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  if (!__pyx_t_14) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_13); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_14); __pyx_t_14 = NULL;
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_13);
    __pyx_t_13 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_send_options_message, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":542
 *             self.send_msg(OptionsMessage(), self.get_request_id(), self._handle_options_response)
 * 
 *     @defunct_on_error             # <<<<<<<<<<<<<<
 *     def _handle_options_response(self, options_response):
 *         if self.is_defunct:
 */
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_defunct_on_error); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);

  /* "cassandra/connection.py":543
 * 
 *     @defunct_on_error
 *     def _handle_options_response(self, options_response):             # <<<<<<<<<<<<<<
 *         if self.is_defunct:
 *             return
 */
  __pyx_t_12 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_45_handle_options_response, 0, __pyx_n_s_Connection__handle_options_respo, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__100)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  if (!__pyx_t_13) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_12); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_14, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_handle_options_response, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":605
 *         self._send_startup_message(compression_type)
 * 
 *     @defunct_on_error             # <<<<<<<<<<<<<<
 *     def _send_startup_message(self, compression=None):
 *         log.debug("Sending StartupMessage on %s", self)
 */
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_defunct_on_error); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);

  /* "cassandra/connection.py":606
 * 
 *     @defunct_on_error
 *     def _send_startup_message(self, compression=None):             # <<<<<<<<<<<<<<
 *         log.debug("Sending StartupMessage on %s", self)
 *         opts = {}
 */
  __pyx_t_14 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_47_send_startup_message, 0, __pyx_n_s_Connection__send_startup_message, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__102)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_14, __pyx_tuple__103);
  __pyx_t_12 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  if (!__pyx_t_12) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); __pyx_t_12 = NULL;
    __Pyx_GIVEREF(__pyx_t_14);
    PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_14);
    __pyx_t_14 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_13, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_send_startup_message, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":615
 *         log.debug("Sent StartupMessage on %s", self)
 * 
 *     @defunct_on_error             # <<<<<<<<<<<<<<
 *     def _handle_startup_response(self, startup_response, did_authenticate=False):
 *         if self.is_defunct:
 */
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_defunct_on_error); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);

  /* "cassandra/connection.py":616
 * 
 *     @defunct_on_error
 *     def _handle_startup_response(self, startup_response, did_authenticate=False):             # <<<<<<<<<<<<<<
 *         if self.is_defunct:
 *             return
 */
  __pyx_t_13 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_49_handle_startup_response, 0, __pyx_n_s_Connection__handle_startup_respo, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__105)); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_13, __pyx_tuple__106);
  __pyx_t_14 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  if (!__pyx_t_14) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_13); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_14); __pyx_t_14 = NULL;
    __Pyx_GIVEREF(__pyx_t_13);
    PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_13);
    __pyx_t_13 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_handle_startup_response, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":662
 *             raise ProtocolError(msg % (startup_response,))
 * 
 *     @defunct_on_error             # <<<<<<<<<<<<<<
 *     def _handle_auth_response(self, auth_response):
 *         if self.is_defunct:
 */
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_defunct_on_error); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);

  /* "cassandra/connection.py":663
 * 
 *     @defunct_on_error
 *     def _handle_auth_response(self, auth_response):             # <<<<<<<<<<<<<<
 *         if self.is_defunct:
 *             return
 */
  __pyx_t_12 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_51_handle_auth_response, 0, __pyx_n_s_Connection__handle_auth_response, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__108)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  if (!__pyx_t_13) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_12); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_14, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_handle_auth_response, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":692
 *             raise ProtocolError(msg % (self.host, auth_response))
 * 
 *     def set_keyspace_blocking(self, keyspace):             # <<<<<<<<<<<<<<
 *         if not keyspace or keyspace == self.keyspace:
 *             return
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_53set_keyspace_blocking, 0, __pyx_n_s_Connection_set_keyspace_blocking, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__110)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_set_keyspace_blocking, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":717
 *             raise conn_exc
 * 
 *     def set_keyspace_async(self, keyspace, callback):             # <<<<<<<<<<<<<<
 *         """
 *         Use this in order to avoid deadlocking the event loop thread.
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_55set_keyspace_async, 0, __pyx_n_s_Connection_set_keyspace_async, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__112)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_set_keyspace_async, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":758
 * 
 *     @property
 *     def is_idle(self):             # <<<<<<<<<<<<<<
 *         return not self.msg_received
 * 
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_57is_idle, 0, __pyx_n_s_Connection_is_idle, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__114)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "cassandra/connection.py":757
 *         self.send_msg(query, request_id, process_result)
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def is_idle(self):
 *         return not self.msg_received
 */
  __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_property, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_is_idle, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":761
 *         return not self.msg_received
 * 
 *     def reset_idle(self):             # <<<<<<<<<<<<<<
 *         self.msg_received = False
 * 
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_59reset_idle, 0, __pyx_n_s_Connection_reset_idle, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__116)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_reset_idle, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":764
 *         self.msg_received = False
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         status = ""
 *         if self.is_defunct:
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_10Connection_61__str__, 0, __pyx_n_s_Connection___str, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__118)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_str, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":772
 * 
 *         return "<%s(%r) %s:%d%s>" % (self.__class__.__name__, id(self), self.host, self.port, status)
 *     __repr__ = __str__             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyObject_GetItem(__pyx_t_7, __pyx_n_s_str);
  if (unlikely(!__pyx_t_2)) {
    PyErr_Clear();
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_str);
  }
  if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_repr, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":162
 * 
 * 
 * class Connection(object):             # <<<<<<<<<<<<<<
 * 
 *     in_buffer_size = 4096
 */
  __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_Connection, __pyx_t_11, __pyx_t_7, NULL, 0, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Connection, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cassandra/connection.py":775
 * 
 * 
 * class ResponseWaiter(object):             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, connection, num_responses, fail_on_error):
 */
  __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_INCREF(__pyx_builtin_object);
  __Pyx_GIVEREF(__pyx_builtin_object);
  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_builtin_object);
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_11); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_11, __pyx_n_s_ResponseWaiter, __pyx_n_s_ResponseWaiter, (PyObject *) NULL, __pyx_n_s_cassandra_connection, (PyObject *) NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);

  /* "cassandra/connection.py":777
 * class ResponseWaiter(object):
 * 
 *     def __init__(self, connection, num_responses, fail_on_error):             # <<<<<<<<<<<<<<
 *         self.connection = connection
 *         self.pending = num_responses
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_14ResponseWaiter_1__init__, 0, __pyx_n_s_ResponseWaiter___init, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__120)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_init, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":785
 *         self.event = Event()
 * 
 *     def got_response(self, response, index):             # <<<<<<<<<<<<<<
 *         with self.connection.lock:
 *             self.connection.in_flight -= 1
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_14ResponseWaiter_3got_response, 0, __pyx_n_s_ResponseWaiter_got_response, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__122)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_got_response, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":806
 *             self.event.set()
 * 
 *     def deliver(self, timeout=None):             # <<<<<<<<<<<<<<
 *         """
 *         If fail_on_error was set to False, a list of (success, response)
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_14ResponseWaiter_5deliver, 0, __pyx_n_s_ResponseWaiter_deliver, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__124)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__125);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_deliver, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":775
 * 
 * 
 * class ResponseWaiter(object):             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, connection, num_responses, fail_on_error):
 */
  __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_ResponseWaiter, __pyx_t_11, __pyx_t_7, NULL, 0, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ResponseWaiter, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cassandra/connection.py":825
 * 
 * 
 * class HeartbeatFuture(object):             # <<<<<<<<<<<<<<
 *     def __init__(self, connection, owner):
 *         self._exception = None
 */
  __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_INCREF(__pyx_builtin_object);
  __Pyx_GIVEREF(__pyx_builtin_object);
  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_builtin_object);
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_11); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_11, __pyx_n_s_HeartbeatFuture, __pyx_n_s_HeartbeatFuture, (PyObject *) NULL, __pyx_n_s_cassandra_connection, (PyObject *) NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);

  /* "cassandra/connection.py":826
 * 
 * class HeartbeatFuture(object):
 *     def __init__(self, connection, owner):             # <<<<<<<<<<<<<<
 *         self._exception = None
 *         self._event = Event()
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_15HeartbeatFuture_1__init__, 0, __pyx_n_s_HeartbeatFuture___init, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__127)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_init, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":841
 *                 self._event.set()
 * 
 *     def wait(self, timeout):             # <<<<<<<<<<<<<<
 *         self._event.wait(timeout)
 *         if self._event.is_set():
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_15HeartbeatFuture_3wait, 0, __pyx_n_s_HeartbeatFuture_wait, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__129)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_wait, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":849
 *             raise OperationTimedOut()
 * 
 *     def _options_callback(self, response):             # <<<<<<<<<<<<<<
 *         if not isinstance(response, SupportedMessage):
 *             if isinstance(response, ConnectionException):
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_15HeartbeatFuture_5_options_callback, 0, __pyx_n_s_HeartbeatFuture__options_callbac, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__131)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_options_callback, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":825
 * 
 * 
 * class HeartbeatFuture(object):             # <<<<<<<<<<<<<<
 *     def __init__(self, connection, owner):
 *         self._exception = None
 */
  __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_HeartbeatFuture, __pyx_t_11, __pyx_t_7, NULL, 0, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_HeartbeatFuture, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "cassandra/connection.py":862
 * 
 * 
 * class ConnectionHeartbeat(Thread):             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, interval_sec, get_connection_holders):
 */
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_Thread); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11);
  __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_7 = __Pyx_Py3MetaclassPrepare(__pyx_t_11, __pyx_t_1, __pyx_n_s_ConnectionHeartbeat, __pyx_n_s_ConnectionHeartbeat, (PyObject *) NULL, __pyx_n_s_cassandra_connection, (PyObject *) NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);

  /* "cassandra/connection.py":864
 * class ConnectionHeartbeat(Thread):
 * 
 *     def __init__(self, interval_sec, get_connection_holders):             # <<<<<<<<<<<<<<
 *         Thread.__init__(self, name="Connection heartbeat")
 *         self._interval = interval_sec
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_19ConnectionHeartbeat_1__init__, 0, __pyx_n_s_ConnectionHeartbeat___init, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__133)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_init, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":872
 *         self.start()
 * 
 *     class ShutdownException(Exception):             # <<<<<<<<<<<<<<
 *         pass
 * 
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_builtin_Exception);
  __Pyx_GIVEREF(__pyx_builtin_Exception);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_Exception);
  __pyx_t_10 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_14 = __Pyx_Py3MetaclassPrepare(__pyx_t_10, __pyx_t_2, __pyx_n_s_ShutdownException, __pyx_n_s_ConnectionHeartbeat_ShutdownExce, (PyObject *) NULL, __pyx_n_s_cassandra_connection, (PyObject *) NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_12 = __Pyx_Py3ClassCreate(__pyx_t_10, __pyx_n_s_ShutdownException, __pyx_t_2, __pyx_t_14, NULL, 0, 1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_ShutdownException, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":875
 *         pass
 * 
 *     def run(self):             # <<<<<<<<<<<<<<
 *         self._shutdown_event.wait(self._interval)
 *         while not self._shutdown_event.is_set():
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_19ConnectionHeartbeat_3run, 0, __pyx_n_s_ConnectionHeartbeat_run, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__135)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_run, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":927
 *             self._shutdown_event.wait(max(self._interval - elapsed, 0.01))
 * 
 *     def stop(self):             # <<<<<<<<<<<<<<
 *         self._shutdown_event.set()
 *         self.join()
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_19ConnectionHeartbeat_5stop, 0, __pyx_n_s_ConnectionHeartbeat_stop, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__137)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_stop, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":931
 *         self.join()
 * 
 *     def _raise_if_stopped(self):             # <<<<<<<<<<<<<<
 *         if self._shutdown_event.is_set():
 *             raise self.ShutdownException()
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_19ConnectionHeartbeat_7_raise_if_stopped, 0, __pyx_n_s_ConnectionHeartbeat__raise_if_st, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__139)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_raise_if_stopped, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":862
 * 
 * 
 * class ConnectionHeartbeat(Thread):             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, interval_sec, get_connection_holders):
 */
  __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_11, __pyx_n_s_ConnectionHeartbeat, __pyx_t_1, __pyx_t_7, NULL, 0, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ConnectionHeartbeat, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":936
 * 
 * 
 * class Timer(object):             # <<<<<<<<<<<<<<
 * 
 *     canceled = False
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_builtin_object);
  __Pyx_GIVEREF(__pyx_builtin_object);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_builtin_object);
  __pyx_t_11 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_7 = __Pyx_Py3MetaclassPrepare(__pyx_t_11, __pyx_t_1, __pyx_n_s_Timer, __pyx_n_s_Timer, (PyObject *) NULL, __pyx_n_s_cassandra_connection, (PyObject *) NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);

  /* "cassandra/connection.py":938
 * class Timer(object):
 * 
 *     canceled = False             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, timeout, callback):
 */
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_canceled, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "cassandra/connection.py":940
 *     canceled = False
 * 
 *     def __init__(self, timeout, callback):             # <<<<<<<<<<<<<<
 *         self.end = time.time() + timeout
 *         self.callback = callback
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_5Timer_1__init__, 0, __pyx_n_s_Timer___init, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__141)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_init, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":946
 *             self.callback()
 * 
 *     def cancel(self):             # <<<<<<<<<<<<<<
 *         self.canceled = True
 * 
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_5Timer_3cancel, 0, __pyx_n_s_Timer_cancel, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__143)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_cancel, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":949
 *         self.canceled = True
 * 
 *     def finish(self, time_now):             # <<<<<<<<<<<<<<
 *         if self.canceled:
 *             return True
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_5Timer_5finish, 0, __pyx_n_s_Timer_finish, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__145)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_finish, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":936
 * 
 * 
 * class Timer(object):             # <<<<<<<<<<<<<<
 * 
 *     canceled = False
 */
  __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_11, __pyx_n_s_Timer, __pyx_t_1, __pyx_t_7, NULL, 0, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Timer, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":960
 * 
 * 
 * class TimerManager(object):             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self):
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_builtin_object);
  __Pyx_GIVEREF(__pyx_builtin_object);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_builtin_object);
  __pyx_t_11 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_7 = __Pyx_Py3MetaclassPrepare(__pyx_t_11, __pyx_t_1, __pyx_n_s_TimerManager, __pyx_n_s_TimerManager, (PyObject *) NULL, __pyx_n_s_cassandra_connection, (PyObject *) NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);

  /* "cassandra/connection.py":962
 * class TimerManager(object):
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self._queue = []
 *         self._new_timers = []
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_12TimerManager_1__init__, 0, __pyx_n_s_TimerManager___init, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__147)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_init, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":966
 *         self._new_timers = []
 * 
 *     def add_timer(self, timer):             # <<<<<<<<<<<<<<
 *         """
 *         called from client thread with a Timer object
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_12TimerManager_3add_timer, 0, __pyx_n_s_TimerManager_add_timer, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__149)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_add_timer, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":972
 *         self._new_timers.append((timer.end, timer))
 * 
 *     def service_timeouts(self):             # <<<<<<<<<<<<<<
 *         """
 *         run callbacks on all expired timers
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_12TimerManager_5service_timeouts, 0, __pyx_n_s_TimerManager_service_timeouts, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__151)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_service_timeouts, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":997
 * 
 *     @property
 *     def next_timeout(self):             # <<<<<<<<<<<<<<
 *         try:
 *             return self._queue[0][0]
 */
  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9cassandra_10connection_12TimerManager_7next_timeout, 0, __pyx_n_s_TimerManager_next_timeout, NULL, __pyx_n_s_cassandra_connection, __pyx_d, ((PyObject *)__pyx_codeobj__153)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "cassandra/connection.py":996
 *                     log.exception("Exception while servicing timeout callback: ")
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def next_timeout(self):
 *         try:
 */
  __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_property, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (PyObject_SetItem(__pyx_t_7, __pyx_n_s_next_timeout, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "cassandra/connection.py":960
 * 
 * 
 * class TimerManager(object):             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self):
 */
  __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_11, __pyx_n_s_TimerManager, __pyx_t_1, __pyx_t_7, NULL, 0, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_TimerManager, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "cassandra/connection.py":1
 * # Copyright 2013-2015 DataStax, Inc.             # <<<<<<<<<<<<<<
 * #
 * # Licensed under the Apache License, Version 2.0 (the "License");
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init cassandra.connection", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init cassandra.connection");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* --- Runtime support code --- */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON
    result = PyDict_GetItem(__pyx_d, name);
    if (likely(result)) {
        Py_INCREF(result);
    } else {
#else
    result = PyObject_GetItem(__pyx_d, name);
    if (!result) {
        PyErr_Clear();
#endif
        result = __Pyx_GetBuiltinName(name);
    }
    return result;
}

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = func->ob_type->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject* args = PyTuple_Pack(1, arg);
    return (likely(args)) ? __Pyx_PyObject_Call(func, args, NULL) : NULL;
}
#endif

static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
        Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (PyErr_ExceptionMatches(PyExc_OverflowError))
                    PyErr_Clear();
                else
                    goto bad;
            }
        }
        return ms->sq_slice(obj, cstart, cstop);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_subscript))
#endif
    {
        PyObject* result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_COMPILING_IN_CPYTHON
        result = mp->mp_subscript(obj, py_slice);
#else
        result = PyObject_GetItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
    PyObject* owned_ref = NULL;
#endif
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
        owned_ref = PyUnicode_FromObject(s2);
        if (unlikely(!owned_ref))
            return -1;
        s2 = owned_ref;
        s2_is_unicode = 1;
    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
        owned_ref = PyUnicode_FromObject(s1);
        if (unlikely(!owned_ref))
            return -1;
        s1 = owned_ref;
        s1_is_unicode = 1;
    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
        return __Pyx_PyBytes_Equals(s1, s2, equals);
    }
#endif
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length;
        int kind;
        void *data1, *data2;
        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
            return -1;
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
            goto return_ne;
        }
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, (size_t)(length * kind));
            #if PY_MAJOR_VERSION < 3
            Py_XDECREF(owned_ref);
            #endif
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_EQ);
return_ne:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_NE);
#endif
}

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
#else
    PyErr_GetExcInfo(type, value, tb);
#endif
}
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(type, value, tb);
#endif
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_COMPILING_IN_CPYTHON
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
    PyObject* fake_module;
    PyTypeObject* cached_type = NULL;
    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
    if (!fake_module) return NULL;
    Py_INCREF(fake_module);
    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
    if (cached_type) {
        if (!PyType_Check((PyObject*)cached_type)) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s is not a type object",
                type->tp_name);
            goto bad;
        }
        if (cached_type->tp_basicsize != type->tp_basicsize) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s has the wrong size, try recompiling",
                type->tp_name);
            goto bad;
        }
    } else {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        if (PyType_Ready(type) < 0) goto bad;
        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
            goto bad;
        Py_INCREF(type);
        cached_type = type;
    }
done:
    Py_DECREF(fake_module);
    return cached_type;
bad:
    Py_XDECREF(cached_type);
    cached_type = NULL;
    goto done;
}

static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
    if (unlikely(op->func_doc == NULL)) {
        if (op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
            op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
            op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
            if (unlikely(op->func_doc == NULL))
                return NULL;
        } else {
            Py_INCREF(Py_None);
            return Py_None;
        }
    }
    Py_INCREF(op->func_doc);
    return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL) {
        value = Py_None;
    }
    Py_INCREF(value);
    op->func_doc = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
{
    if (unlikely(op->func_name == NULL)) {
#if PY_MAJOR_VERSION >= 3
        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
        if (unlikely(op->func_name == NULL))
            return NULL;
    }
    Py_INCREF(op->func_name);
    return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = op->func_name;
    Py_INCREF(value);
    op->func_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
{
    Py_INCREF(op->func_qualname);
    return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = op->func_qualname;
    Py_INCREF(value);
    op->func_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
    PyObject *self;
    self = m->func_closure;
    if (self == NULL)
        self = Py_None;
    Py_INCREF(self);
    return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
{
    if (unlikely(op->func_dict == NULL)) {
        op->func_dict = PyDict_New();
        if (unlikely(op->func_dict == NULL))
            return NULL;
    }
    Py_INCREF(op->func_dict);
    return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
    if (unlikely(value == NULL)) {
        PyErr_SetString(PyExc_TypeError,
               "function's dictionary may not be deleted");
        return -1;
    }
    if (unlikely(!PyDict_Check(value))) {
        PyErr_SetString(PyExc_TypeError,
               "setting function's dictionary to a non-dict");
        return -1;
    }
    tmp = op->func_dict;
    Py_INCREF(value);
    op->func_dict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
{
    Py_INCREF(op->func_globals);
    return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
    PyObject *res = op->defaults_getter((PyObject *) op);
    if (unlikely(!res))
        return -1;
    op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
    Py_INCREF(op->defaults_tuple);
    op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
    Py_INCREF(op->defaults_kwdict);
    Py_DECREF(res);
    return 0;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyTuple_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__defaults__ must be set to a tuple object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_tuple;
    op->defaults_tuple = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
    PyObject* result = op->defaults_tuple;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_tuple;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__kwdefaults__ must be set to a dict object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_kwdict;
    op->defaults_kwdict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
    PyObject* result = op->defaults_kwdict;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_kwdict;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value || value == Py_None) {
        value = NULL;
    } else if (!PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__annotations__ must be set to a dict object");
        return -1;
    }
    Py_XINCREF(value);
    tmp = op->func_annotations;
    op->func_annotations = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
    PyObject* result = op->func_annotations;
    if (unlikely(!result)) {
        result = PyDict_New();
        if (unlikely(!result)) return NULL;
        op->func_annotations = result;
    }
    Py_INCREF(result);
    return result;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
    {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
    {0, 0, 0, 0, 0}
};
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0,  0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromString(m->func.m_ml->ml_name);
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
#if PY_VERSION_HEX < 0x030500A0
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
#else
#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
#endif
static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
                                      PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
    if (op == NULL)
        return NULL;
    op->flags = flags;
    __Pyx_CyFunction_weakreflist(op) = NULL;
    op->func.m_ml = ml;
    op->func.m_self = (PyObject *) op;
    Py_XINCREF(closure);
    op->func_closure = closure;
    Py_XINCREF(module);
    op->func.m_module = module;
    op->func_dict = NULL;
    op->func_name = NULL;
    Py_INCREF(qualname);
    op->func_qualname = qualname;
    op->func_doc = NULL;
    op->func_classobj = NULL;
    op->func_globals = globals;
    Py_INCREF(op->func_globals);
    Py_XINCREF(code);
    op->func_code = code;
    op->defaults_pyobjects = 0;
    op->defaults = NULL;
    op->defaults_tuple = NULL;
    op->defaults_kwdict = NULL;
    op->defaults_getter = NULL;
    op->func_annotations = NULL;
    PyObject_GC_Track(op);
    return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
    Py_CLEAR(m->func_closure);
    Py_CLEAR(m->func.m_module);
    Py_CLEAR(m->func_dict);
    Py_CLEAR(m->func_name);
    Py_CLEAR(m->func_qualname);
    Py_CLEAR(m->func_doc);
    Py_CLEAR(m->func_globals);
    Py_CLEAR(m->func_code);
    Py_CLEAR(m->func_classobj);
    Py_CLEAR(m->defaults_tuple);
    Py_CLEAR(m->defaults_kwdict);
    Py_CLEAR(m->func_annotations);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_XDECREF(pydefaults[i]);
        PyMem_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    if (__Pyx_CyFunction_weakreflist(m) != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
    Py_VISIT(m->func_closure);
    Py_VISIT(m->func.m_module);
    Py_VISIT(m->func_dict);
    Py_VISIT(m->func_name);
    Py_VISIT(m->func_qualname);
    Py_VISIT(m->func_doc);
    Py_VISIT(m->func_globals);
    Py_VISIT(m->func_code);
    Py_VISIT(m->func_classobj);
    Py_VISIT(m->defaults_tuple);
    Py_VISIT(m->defaults_kwdict);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_VISIT(pydefaults[i]);
    }
    return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
        Py_INCREF(func);
        return func;
    }
    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
        if (type == NULL)
            type = (PyObject *)(Py_TYPE(obj));
        return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
    return __Pyx_PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromFormat("<cyfunction %U at %p>",
                                op->func_qualname, (void *)op);
#else
    return PyString_FromFormat("<cyfunction %s at %p>",
                               PyString_AsString(op->func_qualname), (void *)op);
#endif
}
#if CYTHON_COMPILING_IN_PYPY
static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    Py_ssize_t size;
    switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) {
    case METH_VARARGS:
        if (likely(kw == NULL) || PyDict_Size(kw) == 0)
            return (*meth)(self, arg);
        break;
    case METH_VARARGS | METH_KEYWORDS:
        return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
    case METH_NOARGS:
        if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
            size = PyTuple_GET_SIZE(arg);
            if (size == 0)
                return (*meth)(self, NULL);
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    case METH_O:
        if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
            size = PyTuple_GET_SIZE(arg);
            if (size == 1)
                return (*meth)(self, PyTuple_GET_ITEM(arg, 0));
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    default:
        PyErr_SetString(PyExc_SystemError, "Bad call flags in "
                        "__Pyx_CyFunction_Call. METH_OLDARGS is no "
                        "longer supported!");
        return NULL;
    }
    PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
                 f->m_ml->ml_name);
    return NULL;
}
#else
static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
	return PyCFunction_Call(func, arg, kw);
}
#endif
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "cython_function_or_method",
    sizeof(__pyx_CyFunctionObject),
    0,
    (destructor) __Pyx_CyFunction_dealloc,
    0,
    0,
    0,
#if PY_MAJOR_VERSION < 3
    0,
#else
    0,
#endif
    (reprfunc) __Pyx_CyFunction_repr,
    0,
    0,
    0,
    0,
    __Pyx_CyFunction_Call,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
    0,
    (traverseproc) __Pyx_CyFunction_traverse,
    (inquiry) __Pyx_CyFunction_clear,
    0,
#if PY_VERSION_HEX < 0x030500A0
    offsetof(__pyx_CyFunctionObject, func_weakreflist),
#else
    offsetof(PyCFunctionObject, m_weakreflist),
#endif
    0,
    0,
    __pyx_CyFunction_methods,
    __pyx_CyFunction_members,
    __pyx_CyFunction_getsets,
    0,
    0,
    __Pyx_CyFunction_descr_get,
    0,
    offsetof(__pyx_CyFunctionObject, func_dict),
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if PY_VERSION_HEX >= 0x030400a1
    0,
#endif
};
static int __Pyx_CyFunction_init(void) {
#if !CYTHON_COMPILING_IN_PYPY
    __pyx_CyFunctionType_type.tp_call = PyCFunction_Call;
#endif
    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
    if (__pyx_CyFunctionType == NULL) {
        return -1;
    }
    return 0;
}
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults = PyMem_Malloc(size);
    if (!m->defaults)
        return PyErr_NoMemory();
    memset(m->defaults, 0, size);
    m->defaults_pyobjects = pyobjects;
    return m->defaults;
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_tuple = tuple;
    Py_INCREF(tuple);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_kwdict = dict;
    Py_INCREF(dict);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->func_annotations = dict;
    Py_INCREF(dict);
}

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_Restore(type, value, tb);
#endif
}
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(type, value, tb);
#endif
}

#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
#if PY_VERSION_HEX >= 0x03030000
    if (cause) {
#else
    if (cause && cause != Py_None) {
#endif
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (PyErr_ExceptionMatches(PyExc_OverflowError))
                        PyErr_Clear();
                    else
                        return NULL;
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}

static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
    PyObject* value;
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (unlikely(PyErr_Occurred()))
            return NULL;
        value = default_value;
    }
    Py_INCREF(value);
#else
    if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
        value = PyDict_GetItem(d, key);
        if (unlikely(!value)) {
            value = default_value;
        }
        Py_INCREF(value);
    } else {
        if (default_value == Py_None)
            default_value = NULL;
        value = PyObject_CallMethodObjArgs(
            d, __pyx_n_s_get, key, default_value, NULL);
    }
#endif
    return value;
}

static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method, *result = NULL;
    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
    if (unlikely(!method)) goto bad;
#if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyMethod_Check(method))) {
        PyObject *self = PyMethod_GET_SELF(method);
        if (likely(self)) {
            PyObject *args;
            PyObject *function = PyMethod_GET_FUNCTION(method);
            args = PyTuple_New(2);
            if (unlikely(!args)) goto bad;
            Py_INCREF(self);
            PyTuple_SET_ITEM(args, 0, self);
            Py_INCREF(arg);
            PyTuple_SET_ITEM(args, 1, arg);
            Py_INCREF(function);
            Py_DECREF(method); method = NULL;
            result = __Pyx_PyObject_Call(function, args, NULL);
            Py_DECREF(args);
            Py_DECREF(function);
            return result;
        }
    }
#endif
    result = __Pyx_PyObject_CallOneArg(method, arg);
bad:
    Py_XDECREF(method);
    return result;
}

static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
    } else {
        PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
        if (unlikely(!retval))
            return -1;
        Py_DECREF(retval);
    }
    return 0;
}

static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
    PyObject *method, *result = NULL;
    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
    if (unlikely(!method)) goto bad;
#if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyMethod_Check(method))) {
        PyObject *self = PyMethod_GET_SELF(method);
        if (likely(self)) {
            PyObject *function = PyMethod_GET_FUNCTION(method);
            result = __Pyx_PyObject_CallOneArg(function, self);
            Py_DECREF(method);
            return result;
        }
    }
#endif
    result = __Pyx_PyObject_CallNoArg(method);
    Py_DECREF(method);
bad:
    return result;
}

static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (Py_TYPE(L) == &PySet_Type) {
        return PySet_Pop(L);
    }
#endif
    return __Pyx_PyObject_CallMethod0(L, __pyx_n_s_pop);
}
static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyList_GET_SIZE(L) > (((PyListObject*)L)->allocated >> 1))) {
        Py_SIZE(L) -= 1;
        return PyList_GET_ITEM(L, PyList_GET_SIZE(L));
    }
#endif
    return __Pyx_PyObject_CallMethod0(L, __pyx_n_s_pop);
}

static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
    Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
    for (i=0; i < nbases; i++) {
        PyTypeObject *tmptype;
        PyObject *tmp = PyTuple_GET_ITEM(bases, i);
        tmptype = Py_TYPE(tmp);
#if PY_MAJOR_VERSION < 3
        if (tmptype == &PyClass_Type)
            continue;
#endif
        if (!metaclass) {
            metaclass = tmptype;
            continue;
        }
        if (PyType_IsSubtype(metaclass, tmptype))
            continue;
        if (PyType_IsSubtype(tmptype, metaclass)) {
            metaclass = tmptype;
            continue;
        }
        PyErr_SetString(PyExc_TypeError,
                        "metaclass conflict: "
                        "the metaclass of a derived class "
                        "must be a (non-strict) subclass "
                        "of the metaclasses of all its bases");
        return NULL;
    }
    if (!metaclass) {
#if PY_MAJOR_VERSION < 3
        metaclass = &PyClass_Type;
#else
        metaclass = &PyType_Type;
#endif
    }
    Py_INCREF((PyObject*) metaclass);
    return (PyObject*) metaclass;
}

static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
                                           PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
    PyObject *ns;
    if (metaclass) {
        PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
        if (prep) {
            PyObject *pargs = PyTuple_Pack(2, name, bases);
            if (unlikely(!pargs)) {
                Py_DECREF(prep);
                return NULL;
            }
            ns = PyObject_Call(prep, pargs, mkw);
            Py_DECREF(prep);
            Py_DECREF(pargs);
        } else {
            if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
                return NULL;
            PyErr_Clear();
            ns = PyDict_New();
        }
    } else {
        ns = PyDict_New();
    }
    if (unlikely(!ns))
        return NULL;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
    if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
    return ns;
bad:
    Py_DECREF(ns);
    return NULL;
}
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
                                      PyObject *dict, PyObject *mkw,
                                      int calculate_metaclass, int allow_py2_metaclass) {
    PyObject *result, *margs;
    PyObject *owned_metaclass = NULL;
    if (allow_py2_metaclass) {
        owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
        if (owned_metaclass) {
            metaclass = owned_metaclass;
        } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
            PyErr_Clear();
        } else {
            return NULL;
        }
    }
    if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
        metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
        Py_XDECREF(owned_metaclass);
        if (unlikely(!metaclass))
            return NULL;
        owned_metaclass = metaclass;
    }
    margs = PyTuple_Pack(3, name, bases, dict);
    if (unlikely(!margs)) {
        result = NULL;
    } else {
        result = PyObject_Call(metaclass, margs, mkw);
        Py_DECREF(margs);
    }
    Py_XDECREF(owned_metaclass);
    return result;
}

static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = (start + end) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        __pyx_d,      /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = py_line;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_VERSION_HEX < 0x03030000
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                #if PY_VERSION_HEX < 0x03030000
                PyObject *py_level = PyInt_FromLong(1);
                if (!py_level)
                    goto bad;
                module = PyObject_CallFunctionObjArgs(py_import,
                    name, global_dict, empty_dict, list, py_level, NULL);
                Py_DECREF(py_level);
                #else
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                #endif
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_VERSION_HEX < 0x03030000
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_VERSION_HEX < 0x03030000
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
#if CYTHON_COMPILING_IN_PYPY
    if (PyObject_TypeCheck(method, &PyWrapperDescr_Type)) {
        return PyClassMethod_New(method);
    }
#else
    static PyTypeObject *methoddescr_type = NULL;
    if (methoddescr_type == NULL) {
       PyObject *meth = PyObject_GetAttrString((PyObject*)&PyList_Type, "append");
       if (!meth) return NULL;
       methoddescr_type = Py_TYPE(meth);
       Py_DECREF(meth);
    }
    if (PyObject_TypeCheck(method, methoddescr_type)) {
        PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
        #if PY_VERSION_HEX < 0x03020000
        PyTypeObject *d_type = descr->d_type;
        #else
        PyTypeObject *d_type = descr->d_common.d_type;
        #endif
        return PyDescr_NewClassMethod(d_type, descr->d_method);
    }
#endif
    else if (PyMethod_Check(method)) {
        return PyClassMethod_New(PyMethod_GET_FUNCTION(method));
    }
    else if (PyCFunction_Check(method)) {
        return PyClassMethod_New(method);
    }
#ifdef __Pyx_CyFunction_USED
    else if (PyObject_TypeCheck(method, __pyx_CyFunctionType)) {
        return PyClassMethod_New(method);
    }
#endif
    PyErr_SetString(PyExc_TypeError,
                   "Class-level classmethod() can only be called on "
                   "a method_descriptor or instance method.");
    return NULL;
}

#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)       \
    {                                                                     \
        func_type value = func_value;                                     \
        if (sizeof(target_type) < sizeof(func_type)) {                    \
            if (unlikely(value != (func_type) (target_type) value)) {     \
                func_type zero = 0;                                       \
                if (is_unsigned && unlikely(value < zero))                \
                    goto raise_neg_overflow;                              \
                else                                                      \
                    goto raise_overflow;                                  \
            }                                                             \
        }                                                                 \
        return (target_type) value;                                       \
    }

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
 #endif
#endif

static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +(((PyLongObject*)x)->ob_digit[0]));
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong(x))
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT(long, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            switch (Py_SIZE(x)) {
                case  0: return 0;
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +(((PyLongObject*)x)->ob_digit[0]));
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
            }
 #endif
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong(x))
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT(int, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
#if PY_VERSION_HEX < 0x03030000
        char* defenc_c;
        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
        if (!defenc) return NULL;
        defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        {
            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
            char* c;
            for (c = defenc_c; c < end; c++) {
                if ((unsigned char) (*c) >= 128) {
                    PyUnicode_AsASCIIString(o);
                    return NULL;
                }
            }
        }
#endif
        *length = PyBytes_GET_SIZE(defenc);
        return defenc_c;
#else
        if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        if (PyUnicode_IS_ASCII(o)) {
            *length = PyUnicode_GET_LENGTH(o);
            return PyUnicode_AsUTF8(o);
        } else {
            PyUnicode_AsASCIIString(o);
            return NULL;
        }
#else
        return PyUnicode_AsUTF8AndSize(o, length);
#endif
#endif
    } else
#endif
#if !CYTHON_COMPILING_IN_PYPY
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_MAJOR_VERSION < 3
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%.4s__ returned non-%.4s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b)))
      return PyInt_AS_LONG(b);
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
     #if CYTHON_USE_PYLONG_INTERNALS
       switch (Py_SIZE(b)) {
       case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0];
       case  0: return 0;
       case  1: return ((PyLongObject*)b)->ob_digit[0];
       }
     #endif
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
