/* Generated by Cython 0.29.2 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "depends": [
            "C:\\Python36-x64\\lib\\site-packages\\numpy\\core\\include\\numpy\\arrayobject.h",
            "C:\\Python36-x64\\lib\\site-packages\\numpy\\core\\include\\numpy\\ufuncobject.h"
        ],
        "extra_compile_args": [
            "/Ot",
            "/IC:\\projects\\mars\\misc"
        ],
        "include_dirs": [
            "C:\\Python36-x64\\lib\\site-packages\\numpy\\core\\include"
        ],
        "name": "mars.actors.pool.gevent_pool",
        "sources": [
            "mars/actors/pool/gevent_pool.pyx"
        ]
    },
    "module_name": "mars.actors.pool.gevent_pool"
}
END: Cython Metadata */

#define PY_SSIZE_T_CLEAN
#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 < 0x03030000)
    #error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_29_2"
#define CYTHON_HEX_VERSION 0x001D02F0
#define CYTHON_FUTURE_DIVISION 0
#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
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
  #if PY_VERSION_HEX >= 0x02070000
    #define HAVE_LONG_LONG
  #endif
#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_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #if PY_VERSION_HEX < 0x03050000
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#elif defined(PYSTON_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYTYPE_LOOKUP
    #define CYTHON_USE_PYTYPE_LOOKUP 0
  #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
    #define CYTHON_USE_PYTYPE_LOOKUP 1
  #endif
  #if PY_MAJOR_VERSION < 3
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYLONG_INTERNALS
    #define CYTHON_USE_PYLONG_INTERNALS 0
  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
    #define CYTHON_USE_PYLONG_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_PYLIST_INTERNALS
    #define CYTHON_USE_PYLIST_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #if PY_VERSION_HEX < 0x030300F0
    #undef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #elif !defined(CYTHON_USE_UNICODE_WRITER)
    #define CYTHON_USE_UNICODE_WRITER 1
  #endif
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #ifndef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL 1
  #endif
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  #endif
  #ifndef CYTHON_USE_DICT_VERSIONS
    #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
  #endif
  #ifndef CYTHON_USE_EXC_INFO_STACK
    #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
  #undef SHIFT
  #undef BASE
  #undef MASK
  #ifdef SIZEOF_VOID_P
    enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  #endif
#endif
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#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
#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_MAYBE_UNUSED_VAR
#  if defined(__cplusplus)
     template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
#  else
#    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
#  endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifdef _MSC_VER
    #ifndef _MSC_STDINT_H_
        #if _MSC_VER < 1300
           typedef unsigned char     uint8_t;
           typedef unsigned int      uint32_t;
        #else
           typedef unsigned __int8   uint8_t;
           typedef unsigned __int32  uint32_t;
        #endif
    #endif
#else
   #include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
  #if defined(__cplusplus) && __cplusplus >= 201103L
    #if __has_cpp_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH [[fallthrough]]
    #elif __has_cpp_attribute(clang::fallthrough)
      #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
    #elif __has_cpp_attribute(gnu::fallthrough)
      #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
  #if defined(__clang__ ) && defined(__apple_build_version__)
    #if __apple_build_version__ < 7000000
      #undef  CYTHON_FALLTHROUGH
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
#endif

#ifndef CYTHON_INLINE
  #if defined(__clang__)
    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  #elif 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

#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
#ifndef METH_STACKLESS
  #define METH_STACKLESS 0
#endif
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
                                                          Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
  #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
    ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if CYTHON_USE_DICT_VERSIONS
#define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
    (version_var) = __PYX_GET_DICT_VERSION(dict);\
    (cache_var) = (value);
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
        static PY_UINT64_T __pyx_dict_version = 0;\
        static PyObject *__pyx_dict_cached_value = NULL;\
        if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
            (VAR) = __pyx_dict_cached_value;\
        } else {\
            (VAR) = __pyx_dict_cached_value = (LOOKUP);\
            __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
        }\
    }
#else
#define __PYX_GET_DICT_VERSION(dict)  (0)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  #define PyObject_Malloc(s)   PyMem_Malloc(s)
  #define PyObject_Free(p)     PyMem_Free(p)
  #define PyObject_Realloc(p)  PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
  #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
  #define PyMem_RawFree(p)             PyMem_Free(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
  #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
  #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
  #define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
#include "pythread.h"
#define Py_tss_NEEDS_INIT 0
typedef int Py_tss_t;
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  *key = PyThread_create_key();
  return 0; // PyThread_create_key reports success always
}
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  *key = Py_tss_NEEDS_INIT;
  return key;
}
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  PyObject_Free(key);
}
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  return *key != Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  PyThread_delete_key(*key);
  *key = Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  return PyThread_set_key_value(*key, value);
}
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  return PyThread_get_key_value(*key);
}
#endif // TSS (Thread Specific Storage) API
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n)  PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  #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
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
#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_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
  #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)
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
#else
  #define CYTHON_PEP393_ENABLED 0
  #define PyUnicode_1BYTE_KIND  1
  #define PyUnicode_2BYTE_KIND  2
  #define PyUnicode_4BYTE_KIND  4
  #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_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  #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]))
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
#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)
#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))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? 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 && !defined(PyObject_ASCII)
  #define PyObject_ASCII(o)            PyObject_Repr(o)
#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
  #define PyObject_Unicode             PyObject_Str
#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
#if CYTHON_ASSUME_SAFE_MACROS
  #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
#else
  #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
#endif
#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) : (Py_INCREF(func), func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
  #if PY_VERSION_HEX >= 0x030500B1
    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
    #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  #else
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
  #define _USE_MATH_DEFINES
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif


#define __PYX_ERR(f_index, lineno, Ln_error) \
{ \
  __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
}

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

#define __PYX_HAVE__mars__actors__pool__gevent_pool
#define __PYX_HAVE_API__mars__actors__pool__gevent_pool
/* Early includes */
#include <string.h>
#include <stdio.h>
#include "numpy/arrayobject.h"
#include "numpy/ufuncobject.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#endif

typedef struct {PyObject **p; const 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_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#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 int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
    return (size_t) i < (size_t) limit;
}
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER)
    #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const 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_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((const 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)
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);
}
#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_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
    (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_ASSUME_SAFE_MACROS
#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
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(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) + 1);
    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 CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }

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

/* Header.proto */
#if !defined(CYTHON_CCOMPLEX)
  #if defined(__cplusplus)
    #define CYTHON_CCOMPLEX 1
  #elif defined(_Complex_I)
    #define CYTHON_CCOMPLEX 1
  #else
    #define CYTHON_CCOMPLEX 0
  #endif
#endif
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #include <complex>
  #else
    #include <complex.h>
  #endif
#endif
#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
  #undef _Complex_I
  #define _Complex_I 1.0fj
#endif


static const char *__pyx_f[] = {
  "mars\\actors\\pool\\gevent_pool.pyx",
  "stringsource",
  "__init__.pxd",
  "mars\\actors\\distributor.pxd",
  "mars\\actors\\core.pxd",
  "mars\\actors\\cluster.pxd",
  "type.pxd",
};

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":776
 * # in Cython to enable them only on the right systems.
 * 
 * ctypedef npy_int8       int8_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t
 */
typedef npy_int8 __pyx_t_5numpy_int8_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":777
 * 
 * ctypedef npy_int8       int8_t
 * ctypedef npy_int16      int16_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int32      int32_t
 * ctypedef npy_int64      int64_t
 */
typedef npy_int16 __pyx_t_5numpy_int16_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":778
 * ctypedef npy_int8       int8_t
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int64      int64_t
 * #ctypedef npy_int96      int96_t
 */
typedef npy_int32 __pyx_t_5numpy_int32_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":779
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t
 * ctypedef npy_int64      int64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_int96      int96_t
 * #ctypedef npy_int128     int128_t
 */
typedef npy_int64 __pyx_t_5numpy_int64_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":783
 * #ctypedef npy_int128     int128_t
 * 
 * ctypedef npy_uint8      uint8_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t
 */
typedef npy_uint8 __pyx_t_5numpy_uint8_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":784
 * 
 * ctypedef npy_uint8      uint8_t
 * ctypedef npy_uint16     uint16_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint32     uint32_t
 * ctypedef npy_uint64     uint64_t
 */
typedef npy_uint16 __pyx_t_5numpy_uint16_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":785
 * ctypedef npy_uint8      uint8_t
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint64     uint64_t
 * #ctypedef npy_uint96     uint96_t
 */
typedef npy_uint32 __pyx_t_5numpy_uint32_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":786
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t
 * ctypedef npy_uint64     uint64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_uint96     uint96_t
 * #ctypedef npy_uint128    uint128_t
 */
typedef npy_uint64 __pyx_t_5numpy_uint64_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":790
 * #ctypedef npy_uint128    uint128_t
 * 
 * ctypedef npy_float32    float32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_float64    float64_t
 * #ctypedef npy_float80    float80_t
 */
typedef npy_float32 __pyx_t_5numpy_float32_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":791
 * 
 * ctypedef npy_float32    float32_t
 * ctypedef npy_float64    float64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_float80    float80_t
 * #ctypedef npy_float128   float128_t
 */
typedef npy_float64 __pyx_t_5numpy_float64_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":800
 * # The int types are mapped a bit surprising --
 * # numpy.int corresponds to 'l' and numpy.long to 'q'
 * ctypedef npy_long       int_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longlong   long_t
 * ctypedef npy_longlong   longlong_t
 */
typedef npy_long __pyx_t_5numpy_int_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":801
 * # numpy.int corresponds to 'l' and numpy.long to 'q'
 * ctypedef npy_long       int_t
 * ctypedef npy_longlong   long_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longlong   longlong_t
 * 
 */
typedef npy_longlong __pyx_t_5numpy_long_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":802
 * ctypedef npy_long       int_t
 * ctypedef npy_longlong   long_t
 * ctypedef npy_longlong   longlong_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_ulong      uint_t
 */
typedef npy_longlong __pyx_t_5numpy_longlong_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":804
 * ctypedef npy_longlong   longlong_t
 * 
 * ctypedef npy_ulong      uint_t             # <<<<<<<<<<<<<<
 * ctypedef npy_ulonglong  ulong_t
 * ctypedef npy_ulonglong  ulonglong_t
 */
typedef npy_ulong __pyx_t_5numpy_uint_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":805
 * 
 * ctypedef npy_ulong      uint_t
 * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 */
typedef npy_ulonglong __pyx_t_5numpy_ulong_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":806
 * ctypedef npy_ulong      uint_t
 * ctypedef npy_ulonglong  ulong_t
 * ctypedef npy_ulonglong  ulonglong_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_intp       intp_t
 */
typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":808
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uintp      uintp_t
 * 
 */
typedef npy_intp __pyx_t_5numpy_intp_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":809
 * 
 * ctypedef npy_intp       intp_t
 * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_double     float_t
 */
typedef npy_uintp __pyx_t_5numpy_uintp_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":811
 * ctypedef npy_uintp      uintp_t
 * 
 * ctypedef npy_double     float_t             # <<<<<<<<<<<<<<
 * ctypedef npy_double     double_t
 * ctypedef npy_longdouble longdouble_t
 */
typedef npy_double __pyx_t_5numpy_float_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":812
 * 
 * ctypedef npy_double     float_t
 * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longdouble longdouble_t
 * 
 */
typedef npy_double __pyx_t_5numpy_double_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":813
 * ctypedef npy_double     float_t
 * ctypedef npy_double     double_t
 * ctypedef npy_longdouble longdouble_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_cfloat      cfloat_t
 */
typedef npy_longdouble __pyx_t_5numpy_longdouble_t;

/* "messages.pxd":22
 * 
 * 
 * ctypedef np.int32_t INT32_t             # <<<<<<<<<<<<<<
 * ctypedef np.uint8_t BYTE_t
 * 
 */
typedef __pyx_t_5numpy_int32_t __pyx_t_4mars_6actors_4pool_8messages_INT32_t;

/* "messages.pxd":23
 * 
 * ctypedef np.int32_t INT32_t
 * ctypedef np.uint8_t BYTE_t             # <<<<<<<<<<<<<<
 * 
 * 
 */
typedef __pyx_t_5numpy_uint8_t __pyx_t_4mars_6actors_4pool_8messages_BYTE_t;
/* Declarations.proto */
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< float > __pyx_t_float_complex;
  #else
    typedef float _Complex __pyx_t_float_complex;
  #endif
#else
    typedef struct { float real, imag; } __pyx_t_float_complex;
#endif
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);

/* Declarations.proto */
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< double > __pyx_t_double_complex;
  #else
    typedef double _Complex __pyx_t_double_complex;
  #endif
#else
    typedef struct { double real, imag; } __pyx_t_double_complex;
#endif
static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);


/*--- Type declarations ---*/
struct __pyx_obj_4mars_6actors_11distributor_Distributor;
struct __pyx_obj_4mars_6actors_4core_ActorRef;
struct __pyx_obj_4mars_6actors_4core_Actor;
struct __pyx_obj_4mars_6actors_4core_FunctionActor;
struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run;
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr;
struct __pyx_opt_args_4mars_6actors_4core_8ActorRef_send;
struct __pyx_opt_args_4mars_6actors_4core_8ActorRef_tell;
struct __pyx_opt_args_4mars_6actors_4core_8ActorRef_destroy;
struct __pyx_opt_args_4mars_6actors_4core_create_actor_pool;
struct __pyx_opt_args_4mars_6actors_4core_new_client;

/* "core.pxd":23
 *     cdef public object _ctx
 * 
 *     cpdef object send(self, object message, bint wait=*, object callback=*)             # <<<<<<<<<<<<<<
 *     cpdef object tell(self, object message, object delay=*, bint wait=*,
 *                       object callback=*)
 */
struct __pyx_opt_args_4mars_6actors_4core_8ActorRef_send {
  int __pyx_n;
  int wait;
  PyObject *callback;
};

/* "core.pxd":24
 * 
 *     cpdef object send(self, object message, bint wait=*, object callback=*)
 *     cpdef object tell(self, object message, object delay=*, bint wait=*,             # <<<<<<<<<<<<<<
 *                       object callback=*)
 *     cpdef object destroy(self, bint wait=*, object callback=*)
 */
struct __pyx_opt_args_4mars_6actors_4core_8ActorRef_tell {
  int __pyx_n;
  PyObject *delay;
  int wait;
  PyObject *callback;
};

/* "core.pxd":26
 *     cpdef object tell(self, object message, object delay=*, bint wait=*,
 *                       object callback=*)
 *     cpdef object destroy(self, bint wait=*, object callback=*)             # <<<<<<<<<<<<<<
 * 
 * 
 */
struct __pyx_opt_args_4mars_6actors_4core_8ActorRef_destroy {
  int __pyx_n;
  int wait;
  PyObject *callback;
};

/* "core.pxd":44
 * 
 * 
 * cpdef object create_actor_pool(str address=*, int n_process=*, object distributor=*,             # <<<<<<<<<<<<<<
 *                                object parallel=*, str backend=*)
 * cpdef object new_client(object parallel=*, str backend=*)
 */
struct __pyx_opt_args_4mars_6actors_4core_create_actor_pool {
  int __pyx_n;
  PyObject *address;
  int n_process;
  PyObject *distributor;
  PyObject *parallel;
  PyObject *backend;
};

/* "core.pxd":46
 * cpdef object create_actor_pool(str address=*, int n_process=*, object distributor=*,
 *                                object parallel=*, str backend=*)
 * cpdef object new_client(object parallel=*, str backend=*)             # <<<<<<<<<<<<<<
 */
struct __pyx_opt_args_4mars_6actors_4core_new_client {
  int __pyx_n;
  PyObject *parallel;
  PyObject *backend;
};

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":815
 * ctypedef npy_longdouble longdouble_t
 * 
 * ctypedef npy_cfloat      cfloat_t             # <<<<<<<<<<<<<<
 * ctypedef npy_cdouble     cdouble_t
 * ctypedef npy_clongdouble clongdouble_t
 */
typedef npy_cfloat __pyx_t_5numpy_cfloat_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":816
 * 
 * ctypedef npy_cfloat      cfloat_t
 * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
 * ctypedef npy_clongdouble clongdouble_t
 * 
 */
typedef npy_cdouble __pyx_t_5numpy_cdouble_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":817
 * ctypedef npy_cfloat      cfloat_t
 * ctypedef npy_cdouble     cdouble_t
 * ctypedef npy_clongdouble clongdouble_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_cdouble     complex_t
 */
typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":819
 * ctypedef npy_clongdouble clongdouble_t
 * 
 * ctypedef npy_cdouble     complex_t             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew1(a):
 */
typedef npy_cdouble __pyx_t_5numpy_complex_t;
struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_send_message;
struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_tell_message;
struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_create_actor_message;
struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_destroy_actor_message;
struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_has_actor_message;
struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_result_message;
struct __pyx_opt_args_4mars_6actors_4pool_8messages_unpack_result_message;
struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_error_message;

/* "messages.pxd":26
 * 
 * 
 * cpdef enum MessageType:             # <<<<<<<<<<<<<<
 *     create_actor = 0
 *     destroy_actor = 1
 */
enum __pyx_t_4mars_6actors_4pool_8messages_MessageType {
  __pyx_e_4mars_6actors_4pool_8messages_create_actor = 0,
  __pyx_e_4mars_6actors_4pool_8messages_destroy_actor = 1,
  __pyx_e_4mars_6actors_4pool_8messages_has_actor = 2,
  __pyx_e_4mars_6actors_4pool_8messages_result = 3,
  __pyx_e_4mars_6actors_4pool_8messages_error = 4,
  __pyx_e_4mars_6actors_4pool_8messages_send_all = 5,
  __pyx_e_4mars_6actors_4pool_8messages_tell_all = 6,
  __pyx_e_4mars_6actors_4pool_8messages_send_chunk_start = 7,
  __pyx_e_4mars_6actors_4pool_8messages_send_chunk = 8,
  __pyx_e_4mars_6actors_4pool_8messages_send_chunk_end = 9,
  __pyx_e_4mars_6actors_4pool_8messages_tell_chunk_start = 10,
  __pyx_e_4mars_6actors_4pool_8messages_tell_chunk = 11,
  __pyx_e_4mars_6actors_4pool_8messages_tell_chunk_end = 12
};

/* "messages.pxd":48
 * cpdef void unpack_actor_ref(bytes binary, ActorRef actor_ref)
 * cpdef object unpack_send_message(bytes message)
 * cpdef object pack_send_message(INT32_t from_index, INT32_t to_index, ActorRef actor_ref, object message,             # <<<<<<<<<<<<<<
 *                                object write=*, int protocol=*)
 * cpdef object unpack_send_message(bytes message)
 */
struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_send_message {
  int __pyx_n;
  PyObject *write;
  int protocol;
};

/* "messages.pxd":51
 *                                object write=*, int protocol=*)
 * cpdef object unpack_send_message(bytes message)
 * cpdef object pack_tell_message(INT32_t from_index, INT32_t to_index, ActorRef actor_ref, object message,             # <<<<<<<<<<<<<<
 *                                object write=*, int protocol=*)
 * cpdef object unpack_tell_message(bytes message)
 */
struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_tell_message {
  int __pyx_n;
  PyObject *write;
  int protocol;
};

/* "messages.pxd":55
 * cpdef object unpack_tell_message(bytes message)
 * cpdef tuple get_index(bytes binary, object calc_from_uid)
 * cpdef object pack_create_actor_message(INT32_t from_index, int to_index, ActorRef actor_ref, object actor_cls,             # <<<<<<<<<<<<<<
 *                                        tuple args, dict kw, object write=*, int protocol=*)
 * cpdef object unpack_create_actor_message(bytes binary)
 */
struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_create_actor_message {
  int __pyx_n;
  PyObject *write;
  int protocol;
};

/* "messages.pxd":58
 *                                        tuple args, dict kw, object write=*, int protocol=*)
 * cpdef object unpack_create_actor_message(bytes binary)
 * cpdef object pack_destroy_actor_message(INT32_t from_index, INT32_t to_index, ActorRef actor_ref,             # <<<<<<<<<<<<<<
 *                                         object write=*, int protocol=*)
 * cpdef object unpack_destroy_actor_message(bytes binary)
 */
struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_destroy_actor_message {
  int __pyx_n;
  PyObject *write;
  int protocol;
};

/* "messages.pxd":61
 *                                         object write=*, int protocol=*)
 * cpdef object unpack_destroy_actor_message(bytes binary)
 * cpdef object pack_has_actor_message(INT32_t from_index, int to_index, ActorRef actor_ref,             # <<<<<<<<<<<<<<
 *                                     object write=*, int protocol=*)
 * cpdef object unpack_has_actor_message(bytes binary)
 */
struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_has_actor_message {
  int __pyx_n;
  PyObject *write;
  int protocol;
};

/* "messages.pxd":64
 *                                     object write=*, int protocol=*)
 * cpdef object unpack_has_actor_message(bytes binary)
 * cpdef object pack_result_message(bytes message_id, INT32_t from_index, int to_index, object result,             # <<<<<<<<<<<<<<
 *                                  object write=*, int protocol=*)
 * cpdef object unpack_result_message(bytes binary, object from_index=*, object to_index=*)
 */
struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_result_message {
  int __pyx_n;
  PyObject *write;
  int protocol;
};

/* "messages.pxd":66
 * cpdef object pack_result_message(bytes message_id, INT32_t from_index, int to_index, object result,
 *                                  object write=*, int protocol=*)
 * cpdef object unpack_result_message(bytes binary, object from_index=*, object to_index=*)             # <<<<<<<<<<<<<<
 * cpdef object pack_error_message(bytes message_id, INT32_t from_index, INT32_t to_index,
 *                                 object error_type, object error, object tb,
 */
struct __pyx_opt_args_4mars_6actors_4pool_8messages_unpack_result_message {
  int __pyx_n;
  PyObject *from_index;
  PyObject *to_index;
};

/* "messages.pxd":67
 *                                  object write=*, int protocol=*)
 * cpdef object unpack_result_message(bytes binary, object from_index=*, object to_index=*)
 * cpdef object pack_error_message(bytes message_id, INT32_t from_index, INT32_t to_index,             # <<<<<<<<<<<<<<
 *                                 object error_type, object error, object tb,
 *                                 object write=*, int protocol=*)
 */
struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_error_message {
  int __pyx_n;
  PyObject *write;
  int protocol;
};
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_destroy_actor;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_has_actor;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__send;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_send;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_tell;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__send_remote;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__send;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_send;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_tell;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__destroy_local_actor;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_destroy_actor;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__has_local_actor;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_has_actor;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_on_receive;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_10Dispatcher_send;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_10Dispatcher_tell;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_9ActorPool_destroy_actor;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_9ActorPool_has_actor;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_11ActorClient_has_actor;
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_11ActorClient_destroy_actor;

/* "mars/actors/pool/gevent_pool.pyx":280
 *         return ar.result()
 * 
 *     cpdef object future(self, bytes unique_id, object future, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef object ar
 * 
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future {
  int __pyx_n;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":529
 *         return future
 * 
 *     cpdef object destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef tuple binaries
 * 
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_destroy_actor {
  int __pyx_n;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":540
 *         return self._async_run(actor_ref.address, binaries, callback=callback)
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef tuple binaries
 * 
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_has_actor {
  int __pyx_n;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":558
 *         return ref
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         cdef object func
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__send {
  int __pyx_n;
  int wait_response;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":577
 *         return self._async_run(actor_ref.address, binaries, callback=callback)
 * 
 *     cpdef send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_send {
  int __pyx_n;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":580
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         if delay is not None:
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_tell {
  int __pyx_n;
  PyObject *delay;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":730
 *         return future
 * 
 *     cpdef object _send_remote(self, ActorRef actor_ref, object message,             # <<<<<<<<<<<<<<
 *                               bint wait_response=True, bint wait=True, object callback=None):
 *         if wait_response:
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__send_remote {
  int __pyx_n;
  int wait_response;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":737
 *             return self.remote_handler.tell(actor_ref, message, wait=wait, callback=callback)
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                 bint wait=True, object callback=None):
 *         return self._dispatch(self._send_local, self._send_process, self._send_remote, actor_ref,
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__send {
  int __pyx_n;
  int wait_response;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":743
 *                               dict(wait_response=wait_response, wait=wait, callback=callback))
 * 
 *     cpdef send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_send {
  int __pyx_n;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":746
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *                bint wait=True, object callback=None):
 *         if delay is not None:
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_tell {
  int __pyx_n;
  PyObject *delay;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":825
 *                               (actor_ref, actor_cls, args, kwargs), dict())
 * 
 *     cpdef _destroy_local_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef object future
 *         cdef object res
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__destroy_local_actor {
  int __pyx_n;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":867
 *         return future
 * 
 *     cpdef destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._dispatch(self._destroy_local_actor, self._destroy_process_actor,
 *                               self.remote_handler.destroy_actor, actor_ref,
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_destroy_actor {
  int __pyx_n;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":872
 *                               (actor_ref,), dict(wait=wait, callback=callback))
 * 
 *     cpdef _has_local_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         if wait:
 *             return self.pool.has_actor(actor_ref.uid)
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__has_local_actor {
  int __pyx_n;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":909
 *         return future
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, callback=None):             # <<<<<<<<<<<<<<
 *         return self._dispatch(self._has_local_actor, self._has_process_actor,
 *                               self.remote_handler.has_actor, actor_ref,
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_has_actor {
  int __pyx_n;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":1035
 *         self.err(message.message_id, message.error_type, message.error, message.traceback)
 * 
 *     cpdef on_receive(self, bytes binary, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef int message_type
 * 
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_on_receive {
  int __pyx_n;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":1140
 *         return future
 * 
 *     cpdef object send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_10Dispatcher_send {
  int __pyx_n;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":1143
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 *     cpdef object tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         if delay is not None:
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_10Dispatcher_tell {
  int __pyx_n;
  PyObject *delay;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":1510
 *                                              actor_cls, *args, **kwargs)
 * 
 *     cpdef object destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         self._check_started()
 * 
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_9ActorPool_destroy_actor {
  int __pyx_n;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":1515
 *         return self._dispatcher.destroy_actor(actor_ref, wait=wait, callback=callback)
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         self._check_started()
 * 
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_9ActorPool_has_actor {
  int __pyx_n;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":1625
 *         return self.remote_handler.create_actor(address, uid, actor_cls, *args, **kwargs)
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self.remote_handler.has_actor(actor_ref, wait=wait, callback=callback)
 * 
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_11ActorClient_has_actor {
  int __pyx_n;
  int wait;
  PyObject *callback;
};

/* "mars/actors/pool/gevent_pool.pyx":1628
 *         return self.remote_handler.has_actor(actor_ref, wait=wait, callback=callback)
 * 
 *     cpdef destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self.remote_handler.destroy_actor(actor_ref, wait=wait, callback=callback)
 * 
 */
struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_11ActorClient_destroy_actor {
  int __pyx_n;
  int wait;
  PyObject *callback;
};

/* "distributor.pxd":17
 * # limitations under the License.
 * 
 * cdef class Distributor(object):             # <<<<<<<<<<<<<<
 *     cdef public int n_process
 * 
 */
struct __pyx_obj_4mars_6actors_11distributor_Distributor {
  PyObject_HEAD
  struct __pyx_vtabstruct_4mars_6actors_11distributor_Distributor *__pyx_vtab;
  int n_process;
};


/* "core.pxd":18
 * 
 * 
 * cdef class ActorRef:             # <<<<<<<<<<<<<<
 *     cdef public str address
 *     cdef public object uid
 */
struct __pyx_obj_4mars_6actors_4core_ActorRef {
  PyObject_HEAD
  struct __pyx_vtabstruct_4mars_6actors_4core_ActorRef *__pyx_vtab;
  PyObject *address;
  PyObject *uid;
  PyObject *_ctx;
};


/* "core.pxd":29
 * 
 * 
 * cdef class Actor:             # <<<<<<<<<<<<<<
 *     cdef str _address
 *     cdef object _uid
 */
struct __pyx_obj_4mars_6actors_4core_Actor {
  PyObject_HEAD
  struct __pyx_vtabstruct_4mars_6actors_4core_Actor *__pyx_vtab;
  PyObject *_address;
  PyObject *_uid;
  PyObject *_ctx;
};


/* "core.pxd":40
 * 
 * 
 * cdef class FunctionActor(Actor):             # <<<<<<<<<<<<<<
 *     cpdef on_receive(self, message)
 * 
 */
struct __pyx_obj_4mars_6actors_4core_FunctionActor {
  struct __pyx_obj_4mars_6actors_4core_Actor __pyx_base;
};


/* "cluster.pxd":18
 * 
 * 
 * cdef class ClusterInfo:             # <<<<<<<<<<<<<<
 *     cdef public bint standalone
 *     cdef public int n_process
 */
struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo {
  PyObject_HEAD
  int standalone;
  int n_process;
  PyObject *address;
  PyObject *serialization;
  PyObject *location;
  int port;
};


/* "mars/actors/pool/gevent_pool.pyx":64
 * 
 * 
 * cdef class MessageContext:             # <<<<<<<<<<<<<<
 *     cdef public object message
 *     cdef public object async_result
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext {
  PyObject_HEAD
  struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_vtab;
  PyObject *message;
  PyObject *async_result;
};


/* "mars/actors/pool/gevent_pool.pyx":76
 * 
 * 
 * cdef class ActorExecutionContext:             # <<<<<<<<<<<<<<
 *     cdef public object actor
 *     cdef public object lock
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext {
  PyObject_HEAD
  struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_vtab;
  PyObject *actor;
  PyObject *lock;
  PyObject *inbox;
  PyObject *comm;
};


/* "mars/actors/pool/gevent_pool.pyx":108
 * 
 * 
 * cdef class ThreadPool:             # <<<<<<<<<<<<<<
 *     cdef object _pool
 * 
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool {
  PyObject_HEAD
  PyObject *_pool;
};


/* "mars/actors/pool/gevent_pool.pyx":118
 * 
 * 
 * cdef class ActorContext:             # <<<<<<<<<<<<<<
 *     """
 *     Hold by an actor.
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext {
  PyObject_HEAD
  PyObject *_comm;
};


/* "mars/actors/pool/gevent_pool.pyx":203
 * 
 * 
 * cdef class LocalActorPool:             # <<<<<<<<<<<<<<
 *     """
 *     manage local actors, this pool is not aware of the multi-processes or cluster
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool {
  PyObject_HEAD
  struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_vtab;
  PyObject *actors;
  PyObject *comm_proxy;
  PyObject *address;
  int index;
};


/* "mars/actors/pool/gevent_pool.pyx":263
 * 
 * 
 * cdef class AsyncHandler:             # <<<<<<<<<<<<<<
 *     cdef dict async_results
 * 
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler {
  PyObject_HEAD
  struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_vtab;
  PyObject *async_results;
};


/* "mars/actors/pool/gevent_pool.pyx":316
 * 
 * 
 * cdef class Connection:             # <<<<<<<<<<<<<<
 *     cdef public object conn
 *     cdef public object lock
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection {
  PyObject_HEAD
  struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_vtab;
  PyObject *conn;
  PyObject *lock;
};


/* "mars/actors/pool/gevent_pool.pyx":410
 * 
 * 
 * cdef class ActorRemoteHelper:             # <<<<<<<<<<<<<<
 *     """
 *     Used to handle remote operations, like deliver create_actor, destroy_actor, send etc to remote,
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper {
  PyObject_HEAD
  struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_vtab;
  PyObject *_parallel;
  PyObject *_pool;
  PyObject *_connections;
  PyObject *_lock;
};


/* "mars/actors/pool/gevent_pool.pyx":590
 * 
 * 
 * cdef class Communicator(AsyncHandler):             # <<<<<<<<<<<<<<
 *     """
 *     Communicator, decide to send message to
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler __pyx_base;
  int index;
  struct __pyx_obj_4mars_6actors_11distributor_Distributor *distributor;
  PyObject *pool;
  struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *cluster_info;
  PyObject *pipe;
  PyObject *remote_handler;
  PyObject *running;
  PyObject *_handlers;
  PyObject *__weakref__;
};


/* "mars/actors/pool/gevent_pool.pyx":1054
 * 
 * 
 * cdef class Dispatcher(AsyncHandler):             # <<<<<<<<<<<<<<
 *     """
 *     Only created when more than 1 process.
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler __pyx_base;
  struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *cluster_info;
  int index;
  PyObject *pipes;
  PyObject *pipe_checkers;
  PyObject *distributor;
  PyObject *remote_handler;
  PyObject *checker_group;
  PyObject *handlers;
};


/* "mars/actors/pool/gevent_pool.pyx":1341
 * 
 * 
 * cdef class ActorServerHandler:             # <<<<<<<<<<<<<<
 *     cdef object sender
 *     cdef bint multi_process
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler {
  PyObject_HEAD
  PyObject *sender;
  int multi_process;
  PyObject *server;
};


/* "mars/actors/pool/gevent_pool.pyx":1441
 * 
 * 
 * cdef class ActorPool:             # <<<<<<<<<<<<<<
 *     """
 *     1) If only 1 process, start local pool
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool {
  PyObject_HEAD
  struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_vtab;
  struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *cluster_info;
  PyObject *_dispatcher;
  struct __pyx_obj_4mars_6actors_11distributor_Distributor *distributor;
  int _started;
  PyObject *_stopped;
  int _multi_process;
  PyObject *_server;
  PyObject *_parallel;
  PyObject *_stop_funcs;
  PyObject *_processes;
  PyObject *_comm_pipes;
  PyObject *_pool_pipes;
};


/* "mars/actors/pool/gevent_pool.pyx":1609
 * 
 * 
 * cdef class ActorClient:             # <<<<<<<<<<<<<<
 *     cdef object remote_handler
 * 
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient {
  PyObject_HEAD
  struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_vtab;
  PyObject *remote_handler;
};


/* "mars/actors/pool/gevent_pool.pyx":143
 *         return self._comm.distributor
 * 
 *     def create_actor(self, actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef bint wait
 *         cdef object address
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor {
  PyObject_HEAD
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self;
};


/* "mars/actors/pool/gevent_pool.pyx":461
 *                 raise
 * 
 *     def create_actor(self, str address, object uid, object actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef bint wait
 *         cdef object callback
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor {
  PyObject_HEAD
  PyObject *__pyx_v_callback;
  PyObject *__pyx_v_future;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self;
};


/* "mars/actors/pool/gevent_pool.pyx":505
 *         return future
 * 
 *     def _async_run(self, str address, object binaries, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef object future
 * 
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run {
  PyObject_HEAD
  PyObject *__pyx_v_callback;
  PyObject *__pyx_v_future;
};


/* "mars/actors/pool/gevent_pool.pyx":655
 *             return remote_func(*args, **kwargs)
 * 
 *     def _send_local(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                     bint wait=True, object callback=None):
 *         cdef ActorExecutionContext actor_ctx
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local {
  PyObject_HEAD
  PyObject *__pyx_v_callback;
  PyObject *__pyx_v_future;
};


/* "mars/actors/pool/gevent_pool.pyx":702
 *         return future
 * 
 *     def _send_process(self, int to_index, ActorRef actor_ref, message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, callback=None):
 *         cdef object func
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process {
  PyObject_HEAD
  PyObject *__pyx_v_callback;
  PyObject *__pyx_v_future;
  PyObject *__pyx_v_message;
  PyObject *__pyx_v_message_id;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self;
};


/* "mars/actors/pool/gevent_pool.pyx":779
 *         return future
 * 
 *     def _create_process_actor(self, int to_index, ActorRef actor_ref, object actor_cls,             # <<<<<<<<<<<<<<
 *                               args, kwargs):
 *         cdef bint wait
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor {
  PyObject_HEAD
  PyObject *__pyx_v_callback;
  PyObject *__pyx_v_future;
  PyObject *__pyx_v_message;
  PyObject *__pyx_v_message_id;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self;
};


/* "mars/actors/pool/gevent_pool.pyx":847
 *         return future
 * 
 *     def _destroy_process_actor(self, int to_index, ActorRef actor_ref,             # <<<<<<<<<<<<<<
 *                                bint wait=True, object callback=None):
 *         cdef bytes message_id
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor {
  PyObject_HEAD
  PyObject *__pyx_v_callback;
  PyObject *__pyx_v_future;
  PyObject *__pyx_v_message;
  PyObject *__pyx_v_message_id;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self;
};


/* "mars/actors/pool/gevent_pool.pyx":888
 *         return future
 * 
 *     def _has_process_actor(self, int to_index, ActorRef actor_ref,             # <<<<<<<<<<<<<<
 *                            bint wait=True, object callback=None):
 *         cdef bytes message_id
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor {
  PyObject_HEAD
  PyObject *__pyx_v_callback;
  PyObject *__pyx_v_future;
  PyObject *__pyx_v_message;
  PyObject *__pyx_v_message_id;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self;
};


/* "mars/actors/pool/gevent_pool.pyx":1101
 *         return True
 * 
 *     def _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         cdef int to_index
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send {
  PyObject_HEAD
  PyObject *__pyx_v_callback;
  PyObject *__pyx_v_future;
  PyObject *__pyx_v_message_id;
  PyObject *__pyx_v_messages;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self;
  int __pyx_v_to_index;
};


/* "mars/actors/pool/gevent_pool.pyx":1152
 *         return self._send(actor_ref, message, wait_response=False, wait=wait, callback=callback)
 * 
 *     def create_actor(self, str address, object uid, object actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef object actor_id
 *         cdef ActorRef actor_ref
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor {
  PyObject_HEAD
  PyObject *__pyx_v_callback;
  PyObject *__pyx_v_future;
  PyObject *__pyx_v_message;
  PyObject *__pyx_v_message_id;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self;
  int __pyx_v_to_index;
};


/* "mars/actors/pool/gevent_pool.pyx":1194
 *         return future
 * 
 *     def destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef int to_index
 *         cdef bytes message_id
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor {
  PyObject_HEAD
  PyObject *__pyx_v_callback;
  PyObject *__pyx_v_future;
  PyObject *__pyx_v_message;
  PyObject *__pyx_v_message_id;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self;
  int __pyx_v_to_index;
};


/* "mars/actors/pool/gevent_pool.pyx":1222
 *         return future
 * 
 *     def has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef int to_index
 *         cdef bytes message_id
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor {
  PyObject_HEAD
  PyObject *__pyx_v_callback;
  PyObject *__pyx_v_future;
  PyObject *__pyx_v_message;
  PyObject *__pyx_v_message_id;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self;
  int __pyx_v_to_index;
};


/* "mars/actors/pool/gevent_pool.pyx":1328
 *                 return
 * 
 *     def run(self):             # <<<<<<<<<<<<<<
 *         while True:
 *             self.checker_group = gevent.pool.Group()
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run {
  PyObject_HEAD
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self;
};


/* "mars/actors/pool/gevent_pool.pyx":1337
 *             self.checker_group.join()
 *             gevent.sleep(0.05)
 *             if all(p is None for p in self.pipes):             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr {
  PyObject_HEAD
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run *__pyx_outer_scope;
  PyObject *__pyx_v_p;
};


/* "mars/actors/pool/gevent_pool.pyx":1479
 *             raise ActorPoolNotStarted('Actor pool need to run first')
 * 
 *     def create_actor(self, object actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef bint wait
 *         cdef object address
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor {
  PyObject_HEAD
  PyObject *__pyx_v_address;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self;
};


/* "mars/actors/pool/gevent_pool.pyx":1546
 *         self._dispatcher.replace_pipe(idx)
 * 
 *     def run(self):             # <<<<<<<<<<<<<<
 *         if self._started:
 *             return
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run {
  PyObject_HEAD
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self;
};


/* "mars/actors/pool/gevent_pool.pyx":1556
 *         else:
 *             self._processes, self._comm_pipes, self._pool_pipes = [list(tp) for tp in zip(
 *                 *(self._start_process(idx) for idx in range(self.cluster_info.n_process))             # <<<<<<<<<<<<<<
 *             )]
 * 
 */
struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr {
  PyObject_HEAD
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *__pyx_outer_scope;
  int __pyx_v_idx;
  int __pyx_t_0;
  int __pyx_t_1;
  int __pyx_t_2;
};



/* "distributor.pxd":17
 * # limitations under the License.
 * 
 * cdef class Distributor(object):             # <<<<<<<<<<<<<<
 *     cdef public int n_process
 * 
 */

struct __pyx_vtabstruct_4mars_6actors_11distributor_Distributor {
  int (*distribute)(struct __pyx_obj_4mars_6actors_11distributor_Distributor *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4mars_6actors_11distributor_Distributor *__pyx_vtabptr_4mars_6actors_11distributor_Distributor;


/* "core.pxd":18
 * 
 * 
 * cdef class ActorRef:             # <<<<<<<<<<<<<<
 *     cdef public str address
 *     cdef public object uid
 */

struct __pyx_vtabstruct_4mars_6actors_4core_ActorRef {
  PyObject *(*send)(struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4core_8ActorRef_send *__pyx_optional_args);
  PyObject *(*tell)(struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4core_8ActorRef_tell *__pyx_optional_args);
  PyObject *(*destroy)(struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4core_8ActorRef_destroy *__pyx_optional_args);
};
static struct __pyx_vtabstruct_4mars_6actors_4core_ActorRef *__pyx_vtabptr_4mars_6actors_4core_ActorRef;


/* "core.pxd":29
 * 
 * 
 * cdef class Actor:             # <<<<<<<<<<<<<<
 *     cdef str _address
 *     cdef object _uid
 */

struct __pyx_vtabstruct_4mars_6actors_4core_Actor {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *(*ref)(struct __pyx_obj_4mars_6actors_4core_Actor *, int __pyx_skip_dispatch);
  PyObject *(*post_create)(struct __pyx_obj_4mars_6actors_4core_Actor *, int __pyx_skip_dispatch);
  PyObject *(*on_receive)(struct __pyx_obj_4mars_6actors_4core_Actor *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*pre_destroy)(struct __pyx_obj_4mars_6actors_4core_Actor *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4mars_6actors_4core_Actor *__pyx_vtabptr_4mars_6actors_4core_Actor;


/* "core.pxd":40
 * 
 * 
 * cdef class FunctionActor(Actor):             # <<<<<<<<<<<<<<
 *     cpdef on_receive(self, message)
 * 
 */

struct __pyx_vtabstruct_4mars_6actors_4core_FunctionActor {
  struct __pyx_vtabstruct_4mars_6actors_4core_Actor __pyx_base;
};
static struct __pyx_vtabstruct_4mars_6actors_4core_FunctionActor *__pyx_vtabptr_4mars_6actors_4core_FunctionActor;


/* "mars/actors/pool/gevent_pool.pyx":64
 * 
 * 
 * cdef class MessageContext:             # <<<<<<<<<<<<<<
 *     cdef public object message
 *     cdef public object async_result
 */

struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_MessageContext {
  PyObject *(*result)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_MessageContext;


/* "mars/actors/pool/gevent_pool.pyx":76
 * 
 * 
 * cdef class ActorExecutionContext:             # <<<<<<<<<<<<<<
 *     cdef public object actor
 *     cdef public object lock
 */

struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext {
  PyObject *(*fire_run)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *, int __pyx_skip_dispatch);
  void (*receive)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *, struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext;


/* "mars/actors/pool/gevent_pool.pyx":203
 * 
 * 
 * cdef class LocalActorPool:             # <<<<<<<<<<<<<<
 *     """
 *     manage local actors, this pool is not aware of the multi-processes or cluster
 */

struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_LocalActorPool {
  PyObject *(*set_comm)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *(*get_actor_execution_ctx)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *, PyObject *, int __pyx_skip_dispatch);
  int (*has_actor)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*destroy_actor)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_LocalActorPool;


/* "mars/actors/pool/gevent_pool.pyx":263
 * 
 * 
 * cdef class AsyncHandler:             # <<<<<<<<<<<<<<
 *     cdef dict async_results
 * 
 */

struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_AsyncHandler {
  PyObject *(*submit)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*future)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future *__pyx_optional_args);
  PyObject *(*wait)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *, PyObject *, int __pyx_skip_dispatch);
  void (*got)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  void (*err)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_AsyncHandler;


/* "mars/actors/pool/gevent_pool.pyx":316
 * 
 * 
 * cdef class Connection:             # <<<<<<<<<<<<<<
 *     cdef public object conn
 *     cdef public object lock
 */

struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Connection {
  void (*release)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Connection;


/* "mars/actors/pool/gevent_pool.pyx":410
 * 
 * 
 * cdef class ActorRemoteHelper:             # <<<<<<<<<<<<<<
 *     """
 *     Used to handle remote operations, like deliver create_actor, destroy_actor, send etc to remote,
 */

struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper {
  PyObject *(*_new_connection)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *, PyObject *);
  PyObject *(*_send_remote)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*destroy_actor)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_destroy_actor *__pyx_optional_args);
  PyObject *(*has_actor)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_has_actor *__pyx_optional_args);
  PyObject *(*_send)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__send *__pyx_optional_args);
  PyObject *(*send)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_send *__pyx_optional_args);
  PyObject *(*tell)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_tell *__pyx_optional_args);
};
static struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper;


/* "mars/actors/pool/gevent_pool.pyx":590
 * 
 * 
 * cdef class Communicator(AsyncHandler):             # <<<<<<<<<<<<<<
 *     """
 *     Communicator, decide to send message to
 */

struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator {
  struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_AsyncHandler __pyx_base;
  PyObject *(*_dispatch)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, PyObject *, PyObject *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*_send_remote)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__send_remote *__pyx_optional_args);
  PyObject *(*_send)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__send *__pyx_optional_args);
  PyObject *(*send)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_send *__pyx_optional_args);
  PyObject *(*tell)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_tell *__pyx_optional_args);
  PyObject *(*_create_local_actor)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*_create_remote_actor)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*_destroy_local_actor)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__destroy_local_actor *__pyx_optional_args);
  PyObject *(*destroy_actor)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_destroy_actor *__pyx_optional_args);
  PyObject *(*_has_local_actor)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__has_local_actor *__pyx_optional_args);
  PyObject *(*has_actor)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_has_actor *__pyx_optional_args);
  PyObject *(*_on_receive_send)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*_on_receive_tell)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*_on_receive_create_actor)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*_on_receive_destroy_actor)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*_on_receive_has_actor)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*_on_receive_result)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*_on_receive_error)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*on_receive)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_on_receive *__pyx_optional_args);
};
static struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Communicator;


/* "mars/actors/pool/gevent_pool.pyx":1054
 * 
 * 
 * cdef class Dispatcher(AsyncHandler):             # <<<<<<<<<<<<<<
 *     """
 *     Only created when more than 1 process.
 */

struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Dispatcher {
  struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_AsyncHandler __pyx_base;
  int (*_is_remote)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *, struct __pyx_obj_4mars_6actors_4core_ActorRef *);
  PyObject *(*send)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_10Dispatcher_send *__pyx_optional_args);
  PyObject *(*tell)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_10Dispatcher_tell *__pyx_optional_args);
  PyObject *(*_on_receive_action)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*_on_receive_result)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*_on_receive_error)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*on_receive)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Dispatcher;
static CYTHON_INLINE int __pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__is_remote(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *, struct __pyx_obj_4mars_6actors_4core_ActorRef *);


/* "mars/actors/pool/gevent_pool.pyx":1441
 * 
 * 
 * cdef class ActorPool:             # <<<<<<<<<<<<<<
 *     """
 *     1) If only 1 process, start local pool
 */

struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorPool {
  void (*_check_started)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *);
  PyObject *(*destroy_actor)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_9ActorPool_destroy_actor *__pyx_optional_args);
  PyObject *(*has_actor)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_9ActorPool_has_actor *__pyx_optional_args);
  PyObject *(*_start_process)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*restart_process)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *, int, int __pyx_skip_dispatch);
  PyObject *(*stop)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorPool;


/* "mars/actors/pool/gevent_pool.pyx":1609
 * 
 * 
 * cdef class ActorClient:             # <<<<<<<<<<<<<<
 *     cdef object remote_handler
 * 
 */

struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorClient {
  PyObject *(*has_actor)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_11ActorClient_has_actor *__pyx_optional_args);
  PyObject *(*destroy_actor)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_11ActorClient_destroy_actor *__pyx_optional_args);
};
static struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorClient;

/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#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)

/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);

/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

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

/* RaiseArgTupleInvalid.proto */
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);

/* GetModuleGlobalName.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __Pyx_GetModuleGlobalName(var, name)  {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
        (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
        __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
#define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
    PY_UINT64_T __pyx_dict_version;\
    PyObject *__pyx_dict_cached_value;\
    (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
#else
#define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
#define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
#endif

/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
    (sizeof(char [1 - 2*!(cond)]) - 1)
#ifndef Py_MEMBER_SIZE
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
#endif
  static size_t __pyx_pyframe_localsplus_offset = 0;
  #include "frameobject.h"
  #define __Pxy_PyFrame_Initialize_Offsets()\
    ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
     (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
  #define __Pyx_PyFrame_GetLocalsplus(frame)\
    (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
#endif

/* PyObjectCall.proto */
#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

/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

/* PyObjectCallNoArg.proto */
#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

/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
#endif

/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

/* PyErrExceptionMatches.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
#endif

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred()  PyErr_Occurred()
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

/* GetAttr.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);

/* GetAttr3.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);

/* PyObjectCall2Args.proto */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);

/* PyObjectLookupSpecial.proto */
#if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
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

/* ExtTypeTest.proto */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);

/* GetTopmostException.proto */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
#endif

/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
#endif

/* GetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* RaiseTooManyValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

/* RaiseNeedMoreValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

/* IterFinish.proto */
static CYTHON_INLINE int __Pyx_IterFinish(void);

/* UnpackItemEndCheck.proto */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

/* WriteUnraisableException.proto */
static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback, int nogil);

/* ArgTypeTest.proto */
#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
    ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
        __Pyx__ArgTypeTest(obj, type, name, exact))
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);

/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);

/* PyObjectSetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
#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);
#else
#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
#endif

/* py_dict_pop.proto */
static CYTHON_INLINE PyObject *__Pyx_PyDict_Pop(PyObject *d, PyObject *key, PyObject *default_value);

/* UnpackUnboundCMethod.proto */
typedef struct {
    PyObject *type;
    PyObject **method_name;
    PyCFunction func;
    PyObject *method;
    int flag;
} __Pyx_CachedCFunction;

/* CallUnboundCMethod2.proto */
static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2);
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2);
#else
#define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2)  __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2)
#endif

/* CallUnboundCMethod1.proto */
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#else
#define __Pyx_CallUnboundCMethod1(cfunc, self, arg)  __Pyx__CallUnboundCMethod1(cfunc, self, arg)
#endif

/* FetchCommonType.proto */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

/* CythonFunction.proto */
#define __Pyx_CyFunction_USED 1
#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_Check(obj)  (__Pyx_TypeCheck(obj, __pyx_CyFunctionType))
#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);

/* KeywordStringCheck.proto */
static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);

/* DictGetItem.proto */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
#define __Pyx_PyObject_Dict_GetItem(obj, name)\
    (likely(PyDict_CheckExact(obj)) ?\
     __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
#else
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#define __Pyx_PyObject_Dict_GetItem(obj, name)  PyObject_GetItem(obj, name)
#endif

/* GetItemInt.proto */
#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 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);

/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

/* PyDictContains.proto */
static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
    int result = PyDict_Contains(dict, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace);
#else
#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

/* ListCompAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
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

/* IterNext.proto */
#define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL)
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *);

/* ObjectGetItem.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
#else
#define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
#endif

/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)

/* SliceObject.proto */
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);

/* IncludeStringH.proto */
#include <string.h>

/* BytesEquals.proto */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

/* UnicodeEquals.proto */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);

/* StrEquals.proto */
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif

/* SliceTupleAndList.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
#else
#define __Pyx_PyList_GetSlice(seq, start, stop)   PySequence_GetSlice(seq, start, stop)
#define __Pyx_PyTuple_GetSlice(seq, start, stop)  PySequence_GetSlice(seq, start, stop)
#endif

/* RaiseNoneIterError.proto */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

/* ListAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
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

/* PyObjectGetMethod.proto */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);

/* PyObjectCallMethod1.proto */
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);

/* append.proto */
static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);

/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

/* SetItemInt.proto */
#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
               __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
                                               int is_list, int wraparound, int boundscheck);

/* SwapException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* dict_getitem_default.proto */
static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value);

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* HasAttr.proto */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);

/* PyObject_GenericGetAttrNoDict.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
#endif

/* PyObject_GenericGetAttr.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
#endif

/* SetVTable.proto */
static int __Pyx_SetVtable(PyObject *dict, void *vtable);

/* SetupReduce.proto */
static int __Pyx_setup_reduce(PyObject* type_obj);

/* TypeImport.proto */
#ifndef __PYX_HAVE_RT_ImportType_proto
#define __PYX_HAVE_RT_ImportType_proto
enum __Pyx_ImportType_CheckSize {
   __Pyx_ImportType_CheckSize_Error = 0,
   __Pyx_ImportType_CheckSize_Warn = 1,
   __Pyx_ImportType_CheckSize_Ignore = 2
};
static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
#endif

/* GetVTable.proto */
static void* __Pyx_GetVtable(PyObject *dict);

/* GetNameInClass.proto */
#define __Pyx_GetNameInClass(var, nmspace, name)  (var) = __Pyx__GetNameInClass(nmspace, name)
static PyObject *__Pyx__GetNameInClass(PyObject *nmspace, PyObject *name);

/* CalculateMetaclass.proto */
static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);

/* SetNameInClass.proto */
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
#elif CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
#else
#define __Pyx_SetNameInClass(ns, name, value)  PyObject_SetItem(ns, name, value)
#endif

/* Py3ClassCreate.proto */
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);

/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif

/* CodeObjectCache.proto */
typedef struct {
    PyCodeObject* code_object;
    int code_line;
} __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);

/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(enum __pyx_t_4mars_6actors_4pool_8messages_MessageType value);

/* RealImag.proto */
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #define __Pyx_CREAL(z) ((z).real())
    #define __Pyx_CIMAG(z) ((z).imag())
  #else
    #define __Pyx_CREAL(z) (__real__(z))
    #define __Pyx_CIMAG(z) (__imag__(z))
  #endif
#else
    #define __Pyx_CREAL(z) ((z).real)
    #define __Pyx_CIMAG(z) ((z).imag)
#endif
#if defined(__cplusplus) && CYTHON_CCOMPLEX\
        && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
    #define __Pyx_SET_CREAL(z,x) ((z).real(x))
    #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
#else
    #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
    #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
#endif

/* Arithmetic.proto */
#if CYTHON_CCOMPLEX
    #define __Pyx_c_eq_float(a, b)   ((a)==(b))
    #define __Pyx_c_sum_float(a, b)  ((a)+(b))
    #define __Pyx_c_diff_float(a, b) ((a)-(b))
    #define __Pyx_c_prod_float(a, b) ((a)*(b))
    #define __Pyx_c_quot_float(a, b) ((a)/(b))
    #define __Pyx_c_neg_float(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zero_float(z) ((z)==(float)0)
    #define __Pyx_c_conj_float(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_abs_float(z)     (::std::abs(z))
        #define __Pyx_c_pow_float(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zero_float(z) ((z)==0)
    #define __Pyx_c_conj_float(z)    (conjf(z))
    #if 1
        #define __Pyx_c_abs_float(z)     (cabsf(z))
        #define __Pyx_c_pow_float(a, b)  (cpowf(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex);
    static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex);
    #if 1
        static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex);
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex);
    #endif
#endif

/* Arithmetic.proto */
#if CYTHON_CCOMPLEX
    #define __Pyx_c_eq_double(a, b)   ((a)==(b))
    #define __Pyx_c_sum_double(a, b)  ((a)+(b))
    #define __Pyx_c_diff_double(a, b) ((a)-(b))
    #define __Pyx_c_prod_double(a, b) ((a)*(b))
    #define __Pyx_c_quot_double(a, b) ((a)/(b))
    #define __Pyx_c_neg_double(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
    #define __Pyx_c_conj_double(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_abs_double(z)     (::std::abs(z))
        #define __Pyx_c_pow_double(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zero_double(z) ((z)==0)
    #define __Pyx_c_conj_double(z)    (conj(z))
    #if 1
        #define __Pyx_c_abs_double(z)     (cabs(z))
        #define __Pyx_c_pow_double(a, b)  (cpow(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
    static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
    #if 1
        static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
        static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
    #endif
#endif

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value);

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE npy_int32 __Pyx_PyInt_As_npy_int32(PyObject *);

/* CoroutineBase.proto */
typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *);
#if CYTHON_USE_EXC_INFO_STACK
#define __Pyx_ExcInfoStruct  _PyErr_StackItem
#else
typedef struct {
    PyObject *exc_type;
    PyObject *exc_value;
    PyObject *exc_traceback;
} __Pyx_ExcInfoStruct;
#endif
typedef struct {
    PyObject_HEAD
    __pyx_coroutine_body_t body;
    PyObject *closure;
    __Pyx_ExcInfoStruct gi_exc_state;
    PyObject *gi_weakreflist;
    PyObject *classobj;
    PyObject *yieldfrom;
    PyObject *gi_name;
    PyObject *gi_qualname;
    PyObject *gi_modulename;
    PyObject *gi_code;
    int resume_label;
    char is_running;
} __pyx_CoroutineObject;
static __pyx_CoroutineObject *__Pyx__Coroutine_New(
    PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
    PyObject *name, PyObject *qualname, PyObject *module_name);
static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name);
static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self);
static int __Pyx_Coroutine_clear(PyObject *self);
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
static PyObject *__Pyx_Coroutine_Close(PyObject *self);
static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
#if CYTHON_USE_EXC_INFO_STACK
#define __Pyx_Coroutine_SwapException(self)
#define __Pyx_Coroutine_ResetAndClearException(self)  __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state)
#else
#define __Pyx_Coroutine_SwapException(self) {\
    __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\
    __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\
    }
#define __Pyx_Coroutine_ResetAndClearException(self) {\
    __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\
    (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\
    }
#endif
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
#else
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
#endif
static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state);

/* PatchModuleWithCoroutine.proto */
static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);

/* PatchGeneratorABC.proto */
static int __Pyx_patch_abc(void);

/* Generator.proto */
#define __Pyx_Generator_USED
static PyTypeObject *__pyx_GeneratorType = 0;
#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
#define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\
    __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, closure, name, qualname, module_name)
static PyObject *__Pyx_Generator_Next(PyObject *self);
static int __pyx_Generator_init(void);

/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);

/* FunctionImport.proto */
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);

/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);

static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_14MessageContext_result(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_fire_run(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_receive(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_message_ctx, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_set_comm(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_comm, int __pyx_skip_dispatch); /* proto*/
static struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_f_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_get_actor_execution_ctx(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_actor_uid, int __pyx_skip_dispatch); /* proto*/
static int __pyx_f_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_actor_uid, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_actor_uid, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_submit(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id, PyObject *__pyx_v_future, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_wait(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_got(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id, PyObject *__pyx_v_result, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_err(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id, PyObject *__pyx_v_t, PyObject *__pyx_v_ex, PyObject *__pyx_v_tb, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_4mars_6actors_4pool_11gevent_pool_10Connection_release(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__new_connection(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, PyObject *__pyx_v_address); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__send_remote(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, PyObject *__pyx_v_address, PyObject *__pyx_v_binary, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_destroy_actor *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_has_actor *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__send *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_send *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_tell *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__dispatch(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_local_func, PyObject *__pyx_v_redirect_func, PyObject *__pyx_v_remote_func, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__send_remote(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__send_remote *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__send *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator_send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_send *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator_tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_tell *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__create_local_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__create_remote_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__destroy_local_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__destroy_local_actor *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator_destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_destroy_actor *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__has_local_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__has_local_actor *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator_has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_has_actor *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_result(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, CYTHON_UNUSED PyObject *__pyx_v_callback, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_error(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, CYTHON_UNUSED PyObject *__pyx_v_callback, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator_on_receive(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_on_receive *__pyx_optional_args); /* proto*/
static CYTHON_INLINE int __pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__is_remote(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher_send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_10Dispatcher_send *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher_tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_10Dispatcher_tell *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__on_receive_action(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_binary, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__on_receive_result(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_binary, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__on_receive_error(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_binary, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher_on_receive(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_binary, int __pyx_skip_dispatch); /* proto*/
static void __pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool__check_started(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool_destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_9ActorPool_destroy_actor *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool_has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_9ActorPool_has_actor *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool__start_process(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v_idx, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool_restart_process(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, int __pyx_v_idx, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool_stop(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_11ActorClient_has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_11ActorClient_has_actor *__pyx_optional_args); /* proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_11ActorClient_destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_11ActorClient_destroy_actor *__pyx_optional_args); /* proto*/

/* Module declarations from 'mars.actors.distributor' */
static PyTypeObject *__pyx_ptype_4mars_6actors_11distributor_Distributor = 0;

/* Module declarations from 'mars.actors.core' */
static PyTypeObject *__pyx_ptype_4mars_6actors_4core_ActorRef = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4core_Actor = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4core_FunctionActor = 0;

/* Module declarations from 'mars.actors.cluster' */
static PyTypeObject *__pyx_ptype_4mars_6actors_7cluster_ClusterInfo = 0;

/* Module declarations from 'cpython.buffer' */

/* Module declarations from 'libc.string' */

/* Module declarations from 'libc.stdio' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.type' */
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;

/* Module declarations from 'cpython' */

/* Module declarations from 'cpython.object' */

/* Module declarations from 'cpython.ref' */

/* Module declarations from 'cpython.mem' */

/* Module declarations from 'numpy' */

/* Module declarations from 'numpy' */
static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/

/* Module declarations from 'mars.actors.pool.messages' */
static int (*__pyx_f_4mars_6actors_4pool_8messages_unpack_message_type_value)(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_unpack_message_type)(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_unpack_message_id)(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_unpack_send_message)(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_pack_send_message)(__pyx_t_4mars_6actors_4pool_8messages_INT32_t, __pyx_t_4mars_6actors_4pool_8messages_INT32_t, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_send_message *__pyx_optional_args); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_pack_tell_message)(__pyx_t_4mars_6actors_4pool_8messages_INT32_t, __pyx_t_4mars_6actors_4pool_8messages_INT32_t, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_tell_message *__pyx_optional_args); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_unpack_tell_message)(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_get_index)(PyObject *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_pack_create_actor_message)(__pyx_t_4mars_6actors_4pool_8messages_INT32_t, int, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_create_actor_message *__pyx_optional_args); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_unpack_create_actor_message)(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_pack_destroy_actor_message)(__pyx_t_4mars_6actors_4pool_8messages_INT32_t, __pyx_t_4mars_6actors_4pool_8messages_INT32_t, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_destroy_actor_message *__pyx_optional_args); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_unpack_destroy_actor_message)(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_pack_has_actor_message)(__pyx_t_4mars_6actors_4pool_8messages_INT32_t, int, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_has_actor_message *__pyx_optional_args); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_unpack_has_actor_message)(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_pack_result_message)(PyObject *, __pyx_t_4mars_6actors_4pool_8messages_INT32_t, int, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_result_message *__pyx_optional_args); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_unpack_result_message)(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_8messages_unpack_result_message *__pyx_optional_args); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_pack_error_message)(PyObject *, __pyx_t_4mars_6actors_4pool_8messages_INT32_t, __pyx_t_4mars_6actors_4pool_8messages_INT32_t, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_error_message *__pyx_optional_args); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_unpack_error_message)(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4mars_6actors_4pool_8messages_read_remote_message)(PyObject *, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'mars.actors.pool.utils' */
static PyObject *(*__pyx_f_4mars_6actors_4pool_5utils_new_actor_id)(int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'mars.actors.pool.gevent_pool' */
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool_MessageContext = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ThreadPool = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool_LocalActorPool = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool_AsyncHandler = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool_Connection = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool_Communicator = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool_Dispatcher = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorServerHandler = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorPool = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorClient = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run = 0;
static PyTypeObject *__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr = 0;
static int __pyx_v_4mars_6actors_4pool_11gevent_pool_REMOTE_FROM_INDEX;
static int __pyx_v_4mars_6actors_4pool_11gevent_pool_UNKNOWN_TO_INDEX;
static int __pyx_v_4mars_6actors_4pool_11gevent_pool_REMOTE_DEFAULT_PARALLEL;
static int __pyx_v_4mars_6actors_4pool_11gevent_pool_REMOTE_MAX_CONNECTION;
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_start_actor_server(struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *, PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_MessageContext__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *, PyObject *); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorExecutionContext__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *, PyObject *); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ThreadPool__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *, PyObject *); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorContext__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *, PyObject *); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_LocalActorPool__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *, PyObject *); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_AsyncHandler__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *, PyObject *); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_Connection__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *, PyObject *); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorRemoteHelper__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *, PyObject *); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_Communicator__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_Dispatcher__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *, PyObject *); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorServerHandler__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *, PyObject *); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorPool__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *, PyObject *); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorClient__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *, PyObject *); /*proto*/
#define __Pyx_MODULE_NAME "mars.actors.pool.gevent_pool"
extern int __pyx_module_is_main_mars__actors__pool__gevent_pool;
int __pyx_module_is_main_mars__actors__pool__gevent_pool = 0;

/* Implementation of 'mars.actors.pool.gevent_pool' */
static PyObject *__pyx_builtin_staticmethod;
static PyObject *__pyx_builtin_object;
static PyObject *__pyx_builtin_property;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_super;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_EOFError;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_zip;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_ImportError;
static const char __pyx_k_c[] = "c";
static const char __pyx_k_g[] = "g";
static const char __pyx_k_i[] = "i";
static const char __pyx_k_l[] = "l";
static const char __pyx_k_p[] = "p";
static const char __pyx_k_t[] = "t";
static const char __pyx_k__4[] = ":";
static const char __pyx_k_ex[] = "ex";
static const char __pyx_k_fd[] = "fd";
static const char __pyx_k_fn[] = "fn";
static const char __pyx_k_lk[] = "lk";
static const char __pyx_k_np[] = "np";
static const char __pyx_k_ps[] = "ps";
static const char __pyx_k_rb[] = "rb";
static const char __pyx_k_tb[] = "tb";
static const char __pyx_k__66[] = "_";
static const char __pyx_k_ctx[] = "ctx";
static const char __pyx_k_del[] = "__del__";
static const char __pyx_k_doc[] = "__doc__";
static const char __pyx_k_err[] = "err";
static const char __pyx_k_get[] = "get";
static const char __pyx_k_got[] = "got";
static const char __pyx_k_idx[] = "idx";
static const char __pyx_k_lib[] = "lib";
static const char __pyx_k_new[] = "__new__";
static const char __pyx_k_pop[] = "pop";
static const char __pyx_k_put[] = "put";
static const char __pyx_k_ref[] = "ref";
static const char __pyx_k_ret[] = "ret";
static const char __pyx_k_run[] = "run";
static const char __pyx_k_set[] = "set";
static const char __pyx_k_six[] = "six";
static const char __pyx_k_sys[] = "sys";
static const char __pyx_k_uid[] = "uid";
static const char __pyx_k_zip[] = "zip";
static const char __pyx_k_Pool[] = "Pool";
static const char __pyx_k_args[] = "args";
static const char __pyx_k_comm[] = "comm";
static const char __pyx_k_conn[] = "conn";
static const char __pyx_k_dict[] = "__dict__";
static const char __pyx_k_exit[] = "__exit__";
static const char __pyx_k_fobj[] = "fobj";
static const char __pyx_k_gipc[] = "gipc";
static const char __pyx_k_init[] = "__init__";
static const char __pyx_k_join[] = "join";
static const char __pyx_k_lock[] = "lock";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_mode[] = "mode";
static const char __pyx_k_name[] = "__name__";
static const char __pyx_k_pipe[] = "pipe";
static const char __pyx_k_pool[] = "pool";
static const char __pyx_k_recv[] = "recv";
static const char __pyx_k_seed[] = "seed";
static const char __pyx_k_self[] = "self";
static const char __pyx_k_send[] = "send";
static const char __pyx_k_sock[] = "sock";
static const char __pyx_k_stop[] = "stop";
static const char __pyx_k_tell[] = "tell";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_wait[] = "wait";
static const char __pyx_k_EPIPE[] = "EPIPE";
static const char __pyx_k_Event[] = "Event";
static const char __pyx_k_Group[] = "Group";
static const char __pyx_k_Popen[] = "Popen";
static const char __pyx_k_Queue[] = "Queue";
static const char __pyx_k_RLock[] = "RLock";
static const char __pyx_k_actor[] = "actor";
static const char __pyx_k_addrs[] = "addrs";
static const char __pyx_k_apply[] = "apply";
static const char __pyx_k_check[] = "check";
static const char __pyx_k_clear[] = "clear";
static const char __pyx_k_close[] = "close";
static const char __pyx_k_delay[] = "delay";
static const char __pyx_k_enter[] = "__enter__";
static const char __pyx_k_errno[] = "errno";
static const char __pyx_k_error[] = "error";
static const char __pyx_k_event[] = "event";
static const char __pyx_k_index[] = "index";
static const char __pyx_k_numpy[] = "numpy";
static const char __pyx_k_pipes[] = "pipes";
static const char __pyx_k_popen[] = "popen";
static const char __pyx_k_queue[] = "queue";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_sleep[] = "sleep";
static const char __pyx_k_socks[] = "_socks";
static const char __pyx_k_spawn[] = "spawn";
static const char __pyx_k_split[] = "split";
static const char __pyx_k_start[] = "start";
static const char __pyx_k_super[] = "super";
static const char __pyx_k_throw[] = "throw";
static const char __pyx_k_utils[] = "utils";
static const char __pyx_k_value[] = "value";
static const char __pyx_k_append[] = "append";
static const char __pyx_k_binary[] = "binary";
static const char __pyx_k_compat[] = "compat";
static const char __pyx_k_daemon[] = "daemon";
static const char __pyx_k_errors[] = "errors";
static const char __pyx_k_fileno[] = "fileno";
static const char __pyx_k_format[] = "format";
static const char __pyx_k_future[] = "future";
static const char __pyx_k_gevent[] = "gevent";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_init_2[] = "_init";
static const char __pyx_k_islice[] = "islice";
static const char __pyx_k_kwargs[] = "kwargs";
static const char __pyx_k_locked[] = "locked";
static const char __pyx_k_maxlen[] = "maxlen";
static const char __pyx_k_module[] = "__module__";
static const char __pyx_k_object[] = "object";
static const char __pyx_k_pickle[] = "pickle";
static const char __pyx_k_random[] = "random";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_result[] = "result";
static const char __pyx_k_send_2[] = "_send";
static const char __pyx_k_sender[] = "sender";
static const char __pyx_k_server[] = "server";
static const char __pyx_k_socket[] = "socket";
static const char __pyx_k_struct[] = "struct";
static const char __pyx_k_submit[] = "submit";
static const char __pyx_k_update[] = "update";
static const char __pyx_k_values[] = "values";
static const char __pyx_k_acquire[] = "acquire";
static const char __pyx_k_address[] = "address";
static const char __pyx_k_bufsize[] = "bufsize";
static const char __pyx_k_connect[] = "_connect";
static const char __pyx_k_decoder[] = "decoder";
static const char __pyx_k_discard[] = "discard";
static const char __pyx_k_encoder[] = "encoder";
static const char __pyx_k_genexpr[] = "genexpr";
static const char __pyx_k_handler[] = "handler";
static const char __pyx_k_joinall[] = "joinall";
static const char __pyx_k_message[] = "message";
static const char __pyx_k_prepare[] = "__prepare__";
static const char __pyx_k_process[] = "process";
static const char __pyx_k_randint[] = "randint";
static const char __pyx_k_receive[] = "receive";
static const char __pyx_k_release[] = "release";
static const char __pyx_k_reraise[] = "reraise";
static const char __pyx_k_seconds[] = "seconds";
static const char __pyx_k_sendall[] = "sendall";
static const char __pyx_k_timeout[] = "timeout";
static const char __pyx_k_weakref[] = "weakref";
static const char __pyx_k_EOFError[] = "EOFError";
static const char __pyx_k_KeyError[] = "KeyError";
static const char __pyx_k_add_sock[] = "add_sock";
static const char __pyx_k_binaries[] = "binaries";
static const char __pyx_k_blocking[] = "blocking";
static const char __pyx_k_callback[] = "callback";
static const char __pyx_k_dispatch[] = "_dispatch";
static const char __pyx_k_exc_info[] = "exc_info";
static const char __pyx_k_fire_run[] = "fire_run";
static const char __pyx_k_getstate[] = "__getstate__";
static const char __pyx_k_is_alive[] = "is_alive";
static const char __pyx_k_iterkeys[] = "iterkeys";
static const char __pyx_k_listener[] = "listener";
static const char __pyx_k_messages[] = "messages";
static const char __pyx_k_parallel[] = "parallel";
static const char __pyx_k_property[] = "property";
static const char __pyx_k_pyx_type[] = "__pyx_type";
static const char __pyx_k_qualname[] = "__qualname__";
static const char __pyx_k_set_comm[] = "set_comm";
static const char __pyx_k_setstate[] = "__setstate__";
static const char __pyx_k_to_index[] = "to_index";
static const char __pyx_k_ActorPool[] = "ActorPool";
static const char __pyx_k_Semaphore[] = "Semaphore";
static const char __pyx_k_actor_cls[] = "actor_cls";
static const char __pyx_k_actor_ref[] = "actor_ref";
static const char __pyx_k_async_run[] = "_async_run";
static const char __pyx_k_conn_lock[] = "conn_lock";
static const char __pyx_k_connect_2[] = "connect";
static const char __pyx_k_enumerate[] = "enumerate";
static const char __pyx_k_exception[] = "exception";
static const char __pyx_k_has_actor[] = "has_actor";
static const char __pyx_k_iteritems[] = "iteritems";
static const char __pyx_k_itertools[] = "itertools";
static const char __pyx_k_metaclass[] = "__metaclass__";
static const char __pyx_k_pyx_state[] = "__pyx_state";
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
static const char __pyx_k_stop_func[] = "stop_func";
static const char __pyx_k_terminate[] = "terminate";
static const char __pyx_k_traceback[] = "traceback";
static const char __pyx_k_unique_id[] = "unique_id";
static const char __pyx_k_Connection[] = "Connection";
static const char __pyx_k_Dispatcher[] = "Dispatcher";
static const char __pyx_k_FileObject[] = "FileObject";
static const char __pyx_k_GIPCClosed[] = "GIPCClosed";
static const char __pyx_k_GIPCLocked[] = "GIPCLocked";
static const char __pyx_k_ThreadPool[] = "ThreadPool";
static const char __pyx_k_ValueError[] = "ValueError";
static const char __pyx_k_check_pipe[] = "_check_pipe";
static const char __pyx_k_close_pipe[] = "close_pipe";
static const char __pyx_k_conn_locks[] = "conn_locks";
static const char __pyx_k_distribute[] = "distribute";
static const char __pyx_k_error_type[] = "error_type";
static const char __pyx_k_fileobject[] = "fileobject";
static const char __pyx_k_from_index[] = "from_index";
static const char __pyx_k_itervalues[] = "itervalues";
static const char __pyx_k_link_value[] = "link_value";
static const char __pyx_k_local_func[] = "local_func";
static const char __pyx_k_local_pool[] = "local_pool";
static const char __pyx_k_message_id[] = "message_id";
static const char __pyx_k_on_failure[] = "on_failure";
static const char __pyx_k_on_receive[] = "on_receive";
static const char __pyx_k_on_success[] = "on_success";
static const char __pyx_k_pyx_result[] = "__pyx_result";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_send_local[] = "_send_local";
static const char __pyx_k_set_result[] = "set_result";
static const char __pyx_k_set_server[] = "set_server";
static const char __pyx_k_subprocess[] = "subprocess";
static const char __pyx_k_successful[] = "successful";
static const char __pyx_k_threadpool[] = "threadpool";
static const char __pyx_k_ActorClient[] = "ActorClient";
static const char __pyx_k_AsyncResult[] = "AsyncResult";
static const char __pyx_k_Connections[] = "Connections";
static const char __pyx_k_GThreadPool[] = "GThreadPool";
static const char __pyx_k_ImportError[] = "ImportError";
static const char __pyx_k_OrderedDict[] = "OrderedDict";
static const char __pyx_k_PickleError[] = "PickleError";
static const char __pyx_k_apply_async[] = "apply_async";
static const char __pyx_k_distributor[] = "distributor";
static const char __pyx_k_gevent_lock[] = "gevent.lock";
static const char __pyx_k_gevent_pool[] = "gevent.pool";
static const char __pyx_k_global_lock[] = "global_lock";
static const char __pyx_k_num_threads[] = "num_threads";
static const char __pyx_k_remote_func[] = "remote_func";
static const char __pyx_k_send_remote[] = "_send_remote";
static const char __pyx_k_spawn_later[] = "spawn_later";
static const char __pyx_k_ActorContext[] = "ActorContext";
static const char __pyx_k_AsyncHandler[] = "AsyncHandler";
static const char __pyx_k_Communicator[] = "Communicator";
static const char __pyx_k_RuntimeError[] = "RuntimeError";
static const char __pyx_k_StreamServer[] = "StreamServer";
static const char __pyx_k_cluster_info[] = "cluster_info";
static const char __pyx_k_create_actor[] = "create_actor";
static const char __pyx_k_gevent_event[] = "gevent.event";
static const char __pyx_k_gevent_queue[] = "gevent.queue";
static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
static const char __pyx_k_replace_pipe[] = "replace_pipe";
static const char __pyx_k_send_process[] = "_send_process";
static const char __pyx_k_staticmethod[] = "staticmethod";
static const char __pyx_k_string_types[] = "string_types";
static const char __pyx_k_stringsource[] = "stringsource";
static const char __pyx_k_ActorNotExist[] = "ActorNotExist";
static const char __pyx_k_PicklingError[] = "PicklingError";
static const char __pyx_k_destroy_actor[] = "destroy_actor";
static const char __pyx_k_gevent__tblib[] = "gevent._tblib";
static const char __pyx_k_gevent_server[] = "gevent.server";
static const char __pyx_k_gevent_socket[] = "gevent.socket";
static const char __pyx_k_multi_process[] = "multi_process";
static const char __pyx_k_redirect_func[] = "redirect_func";
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
static const char __pyx_k_set_exception[] = "set_exception";
static const char __pyx_k_start_process[] = "_start_process";
static const char __pyx_k_wait_response[] = "wait_response";
static const char __pyx_k_AttributeError[] = "AttributeError";
static const char __pyx_k_LocalActorPool[] = "LocalActorPool";
static const char __pyx_k_MessageContext[] = "MessageContext";
static const char __pyx_k_link_exception[] = "link_exception";
static const char __pyx_k_BrokenPipeError[] = "BrokenPipeError";
static const char __pyx_k_got_broken_pipe[] = "got_broken_pipe";
static const char __pyx_k_has_local_actor[] = "_has_local_actor";
static const char __pyx_k_on_receive_send[] = "_on_receive_send";
static const char __pyx_k_on_receive_tell[] = "_on_receive_tell";
static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
static const char __pyx_k_restart_process[] = "restart_process";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
static const char __pyx_k_start_process_2[] = "start_process";
static const char __pyx_k_Connections_conn[] = "Connections.conn";
static const char __pyx_k_create_actor_ref[] = "create_actor_ref";
static const char __pyx_k_inaction_decoder[] = "_inaction_decoder";
static const char __pyx_k_inaction_encoder[] = "_inaction_encoder";
static const char __pyx_k_on_receive_error[] = "_on_receive_error";
static const char __pyx_k_run_locals_close[] = "run.<locals>.close";
static const char __pyx_k_start_local_pool[] = "start_local_pool";
static const char __pyx_k_ActorAlreadyExist[] = "ActorAlreadyExist";
static const char __pyx_k_ActorRemoteHelper[] = "ActorRemoteHelper";
static const char __pyx_k_ActorStreamServer[] = "ActorStreamServer";
static const char __pyx_k_Connections___del[] = "Connections.__del__";
static const char __pyx_k_create_connection[] = "create_connection";
static const char __pyx_k_gevent_fileobject[] = "gevent.fileobject";
static const char __pyx_k_gevent_init_tblib[] = "gevent_init_tblib";
static const char __pyx_k_gevent_subprocess[] = "gevent.subprocess";
static const char __pyx_k_gevent_threadpool[] = "gevent.threadpool";
static const char __pyx_k_has_process_actor[] = "_has_process_actor";
static const char __pyx_k_on_receive_action[] = "_on_receive_action";
static const char __pyx_k_on_receive_result[] = "_on_receive_result";
static const char __pyx_k_send_locals_check[] = "_send.<locals>.check";
static const char __pyx_k_ActorServerHandler[] = "ActorServerHandler";
static const char __pyx_k_Connections___init[] = "Connections.__init__";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_create_local_actor[] = "_create_local_actor";
static const char __pyx_k_run_locals_genexpr[] = "run.<locals>.genexpr";
static const char __pyx_k_ActorPoolNotStarted[] = "ActorPoolNotStarted";
static const char __pyx_k_Connections_connect[] = "Connections.connect";
static const char __pyx_k_create_remote_actor[] = "_create_remote_actor";
static const char __pyx_k_destroy_local_actor[] = "_destroy_local_actor";
static const char __pyx_k_Connections__connect[] = "Connections._connect";
static const char __pyx_k_create_process_actor[] = "_create_process_actor";
static const char __pyx_k_on_receive_has_actor[] = "_on_receive_has_actor";
static const char __pyx_k_run_locals_stop_func[] = "run.<locals>.stop_func";
static const char __pyx_k_write_remote_message[] = "write_remote_message";
static const char __pyx_k_ActorExecutionContext[] = "ActorExecutionContext";
static const char __pyx_k_destroy_process_actor[] = "_destroy_process_actor";
static const char __pyx_k_Actor_0_does_not_exist[] = "Actor {0} does not exist";
static const char __pyx_k_Unable_to_pickle_0_1_2[] = "Unable to pickle {0}(*{1}, **{2})";
static const char __pyx_k_has_actor_locals_check[] = "has_actor.<locals>.check";
static const char __pyx_k_pyx_unpickle_ActorPool[] = "__pyx_unpickle_ActorPool";
static const char __pyx_k_ActorStreamServer_close[] = "ActorStreamServer.close";
static const char __pyx_k_get_actor_execution_ctx[] = "get_actor_execution_ctx";
static const char __pyx_k_on_receive_create_actor[] = "_on_receive_create_actor";
static const char __pyx_k_pyx_unpickle_Connection[] = "__pyx_unpickle_Connection";
static const char __pyx_k_pyx_unpickle_Dispatcher[] = "__pyx_unpickle_Dispatcher";
static const char __pyx_k_pyx_unpickle_ThreadPool[] = "__pyx_unpickle_ThreadPool";
static const char __pyx_k_ActorStreamServer___init[] = "ActorStreamServer.__init__";
static const char __pyx_k_address_must_be_provided[] = "address must be provided";
static const char __pyx_k_on_receive_destroy_actor[] = "_on_receive_destroy_actor";
static const char __pyx_k_on_receive_locals_lambda[] = "on_receive.<locals>.<lambda>";
static const char __pyx_k_pyx_unpickle_ActorClient[] = "__pyx_unpickle_ActorClient";
static const char __pyx_k_create_actor_locals_check[] = "create_actor.<locals>.check";
static const char __pyx_k_pyx_unpickle_ActorContext[] = "__pyx_unpickle_ActorContext";
static const char __pyx_k_pyx_unpickle_AsyncHandler[] = "__pyx_unpickle_AsyncHandler";
static const char __pyx_k_pyx_unpickle_Communicator[] = "__pyx_unpickle_Communicator";
static const char __pyx_k_send_process_locals_check[] = "_send_process.<locals>.check";
static const char __pyx_k_ActorStreamServer_add_sock[] = "ActorStreamServer.add_sock";
static const char __pyx_k_Unable_to_pickle_message_0[] = "Unable to pickle message {0}";
static const char __pyx_k_destroy_actor_locals_check[] = "destroy_actor.<locals>.check";
static const char __pyx_k_Connections_got_broken_pipe[] = "Connections.got_broken_pipe";
static const char __pyx_k_async_run_locals_on_failure[] = "_async_run.<locals>.on_failure";
static const char __pyx_k_async_run_locals_on_success[] = "_async_run.<locals>.on_success";
static const char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous";
static const char __pyx_k_pyx_unpickle_LocalActorPool[] = "__pyx_unpickle_LocalActorPool";
static const char __pyx_k_pyx_unpickle_MessageContext[] = "__pyx_unpickle_MessageContext";
static const char __pyx_k_Actor_pool_need_to_run_first[] = "Actor pool need to run first";
static const char __pyx_k_Unable_to_pickle_message_0_2[] = "Unable to pickle message: {0}";
static const char __pyx_k_create_actor_locals_callback[] = "create_actor.<locals>.callback";
static const char __pyx_k_mars_actors_pool_gevent_pool[] = "mars.actors.pool.gevent_pool";
static const char __pyx_k_send_local_locals_on_failure[] = "_send_local.<locals>.on_failure";
static const char __pyx_k_send_local_locals_on_success[] = "_send_local.<locals>.on_success";
static const char __pyx_k_create_actor_locals_on_failure[] = "create_actor.<locals>.on_failure";
static const char __pyx_k_create_actor_locals_on_success[] = "create_actor.<locals>.on_success";
static const char __pyx_k_has_process_actor_locals_check[] = "_has_process_actor.<locals>.check";
static const char __pyx_k_pyx_unpickle_ActorExecutionCon[] = "__pyx_unpickle_ActorExecutionContext";
static const char __pyx_k_pyx_unpickle_ActorRemoteHelper[] = "__pyx_unpickle_ActorRemoteHelper";
static const char __pyx_k_pyx_unpickle_ActorServerHandle[] = "__pyx_unpickle_ActorServerHandler";
static const char __pyx_k_Both_address_and_port_should_be[] = "Both address and port should be provided";
static const char __pyx_k_create_process_actor_locals_che[] = "_create_process_actor.<locals>.check";
static const char __pyx_k_destroy_process_actor_locals_ch[] = "_destroy_process_actor.<locals>.check";
static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import";
static const char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)";
static const char __pyx_k_Actor_0_already_exist_cannot_cre[] = "Actor {0} already exist, cannot create";
static const char __pyx_k_Connections_connect_locals_close[] = "Connections.connect.<locals>.close";
static const char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd";
static const char __pyx_k_Incompatible_checksums_s_vs_0x06[] = "Incompatible checksums (%s vs 0x061f3cd = (multi_process, sender, server))";
static const char __pyx_k_Incompatible_checksums_s_vs_0x16[] = "Incompatible checksums (%s vs 0x162dc4f = (_connections, _lock, _parallel, _pool))";
static const char __pyx_k_Incompatible_checksums_s_vs_0x2b[] = "Incompatible checksums (%s vs 0x2b57a74 = (remote_handler))";
static const char __pyx_k_Incompatible_checksums_s_vs_0x2e[] = "Incompatible checksums (%s vs 0x2e761fc = (async_results))";
static const char __pyx_k_Incompatible_checksums_s_vs_0x37[] = "Incompatible checksums (%s vs 0x3781f9c = (async_results, checker_group, cluster_info, distributor, handlers, index, pipe_checkers, pipes, remote_handler))";
static const char __pyx_k_Incompatible_checksums_s_vs_0x40[] = "Incompatible checksums (%s vs 0x406a582 = (actors, address, comm_proxy, index))";
static const char __pyx_k_Incompatible_checksums_s_vs_0x92[] = "Incompatible checksums (%s vs 0x9212058 = (async_result, message))";
static const char __pyx_k_Incompatible_checksums_s_vs_0xa6[] = "Incompatible checksums (%s vs 0xa6da11f = (actor, comm, inbox, lock))";
static const char __pyx_k_Incompatible_checksums_s_vs_0xb0[] = "Incompatible checksums (%s vs 0xb0b0700 = (_comm))";
static const char __pyx_k_Incompatible_checksums_s_vs_0xcb[] = "Incompatible checksums (%s vs 0xcbda5ce = (_comm_pipes, _dispatcher, _multi_process, _parallel, _pool_pipes, _processes, _server, _started, _stop_funcs, _stopped, cluster_info, distributor))";
static const char __pyx_k_Incompatible_checksums_s_vs_0xd3[] = "Incompatible checksums (%s vs 0xd3b2268 = (_handlers, async_results, cluster_info, distributor, index, pipe, pool, remote_handler, running))";
static const char __pyx_k_Incompatible_checksums_s_vs_0xe9[] = "Incompatible checksums (%s vs 0xe946d0d = (conn, lock))";
static const char __pyx_k_Incompatible_checksums_s_vs_0xf7[] = "Incompatible checksums (%s vs 0xf753458 = (_pool))";
static const char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported";
static const char __pyx_k_Not_allow_to_send_message_to_rem[] = "Not allow to send message to remote in standalone mode";
static const char __pyx_k_mars_actors_pool_gevent_pool_pyx[] = "mars\\actors\\pool\\gevent_pool.pyx";
static const char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous";
static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import";
static const char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short.";
static PyObject *__pyx_n_s_ActorAlreadyExist;
static PyObject *__pyx_n_s_ActorClient;
static PyObject *__pyx_n_s_ActorContext;
static PyObject *__pyx_n_s_ActorExecutionContext;
static PyObject *__pyx_n_s_ActorNotExist;
static PyObject *__pyx_n_s_ActorPool;
static PyObject *__pyx_n_s_ActorPoolNotStarted;
static PyObject *__pyx_n_s_ActorRemoteHelper;
static PyObject *__pyx_n_s_ActorServerHandler;
static PyObject *__pyx_n_s_ActorStreamServer;
static PyObject *__pyx_n_s_ActorStreamServer___init;
static PyObject *__pyx_n_s_ActorStreamServer_add_sock;
static PyObject *__pyx_n_s_ActorStreamServer_close;
static PyObject *__pyx_kp_s_Actor_0_already_exist_cannot_cre;
static PyObject *__pyx_kp_s_Actor_0_does_not_exist;
static PyObject *__pyx_kp_s_Actor_pool_need_to_run_first;
static PyObject *__pyx_n_s_AsyncHandler;
static PyObject *__pyx_n_s_AsyncResult;
static PyObject *__pyx_n_s_AttributeError;
static PyObject *__pyx_kp_s_Both_address_and_port_should_be;
static PyObject *__pyx_n_s_BrokenPipeError;
static PyObject *__pyx_n_s_Communicator;
static PyObject *__pyx_n_s_Connection;
static PyObject *__pyx_n_s_Connections;
static PyObject *__pyx_n_s_Connections___del;
static PyObject *__pyx_n_s_Connections___init;
static PyObject *__pyx_n_s_Connections__connect;
static PyObject *__pyx_n_s_Connections_conn;
static PyObject *__pyx_n_s_Connections_connect;
static PyObject *__pyx_n_s_Connections_connect_locals_close;
static PyObject *__pyx_n_s_Connections_got_broken_pipe;
static PyObject *__pyx_n_s_Dispatcher;
static PyObject *__pyx_n_s_EOFError;
static PyObject *__pyx_n_s_EPIPE;
static PyObject *__pyx_n_s_Event;
static PyObject *__pyx_n_s_FileObject;
static PyObject *__pyx_kp_u_Format_string_allocated_too_shor;
static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2;
static PyObject *__pyx_n_s_GIPCClosed;
static PyObject *__pyx_n_s_GIPCLocked;
static PyObject *__pyx_n_s_GThreadPool;
static PyObject *__pyx_n_s_Group;
static PyObject *__pyx_n_s_ImportError;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x06;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x16;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x2b;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x2e;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x37;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x40;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x92;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xa6;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xb0;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xcb;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xd3;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xe9;
static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xf7;
static PyObject *__pyx_n_s_KeyError;
static PyObject *__pyx_n_s_LocalActorPool;
static PyObject *__pyx_n_s_MessageContext;
static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor;
static PyObject *__pyx_kp_s_Not_allow_to_send_message_to_rem;
static PyObject *__pyx_n_s_OrderedDict;
static PyObject *__pyx_n_s_PickleError;
static PyObject *__pyx_n_s_PicklingError;
static PyObject *__pyx_n_s_Pool;
static PyObject *__pyx_n_s_Popen;
static PyObject *__pyx_n_s_Queue;
static PyObject *__pyx_n_s_RLock;
static PyObject *__pyx_n_s_RuntimeError;
static PyObject *__pyx_n_s_Semaphore;
static PyObject *__pyx_n_s_StreamServer;
static PyObject *__pyx_n_s_ThreadPool;
static PyObject *__pyx_kp_s_Unable_to_pickle_0_1_2;
static PyObject *__pyx_kp_s_Unable_to_pickle_message_0;
static PyObject *__pyx_kp_s_Unable_to_pickle_message_0_2;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_kp_s__4;
static PyObject *__pyx_n_s__66;
static PyObject *__pyx_n_s_acquire;
static PyObject *__pyx_n_s_actor;
static PyObject *__pyx_n_s_actor_cls;
static PyObject *__pyx_n_s_actor_ref;
static PyObject *__pyx_n_s_add_sock;
static PyObject *__pyx_n_s_address;
static PyObject *__pyx_kp_s_address_must_be_provided;
static PyObject *__pyx_n_s_addrs;
static PyObject *__pyx_n_s_append;
static PyObject *__pyx_n_s_apply;
static PyObject *__pyx_n_s_apply_async;
static PyObject *__pyx_n_s_args;
static PyObject *__pyx_n_s_async_run;
static PyObject *__pyx_n_s_async_run_locals_on_failure;
static PyObject *__pyx_n_s_async_run_locals_on_success;
static PyObject *__pyx_n_s_binaries;
static PyObject *__pyx_n_s_binary;
static PyObject *__pyx_n_s_blocking;
static PyObject *__pyx_n_s_bufsize;
static PyObject *__pyx_n_s_c;
static PyObject *__pyx_n_s_callback;
static PyObject *__pyx_n_s_check;
static PyObject *__pyx_n_s_check_pipe;
static PyObject *__pyx_n_s_clear;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_close;
static PyObject *__pyx_n_s_close_pipe;
static PyObject *__pyx_n_s_cluster_info;
static PyObject *__pyx_n_s_comm;
static PyObject *__pyx_n_s_compat;
static PyObject *__pyx_n_s_conn;
static PyObject *__pyx_n_s_conn_lock;
static PyObject *__pyx_n_s_conn_locks;
static PyObject *__pyx_n_s_connect;
static PyObject *__pyx_n_s_connect_2;
static PyObject *__pyx_n_s_create_actor;
static PyObject *__pyx_n_s_create_actor_locals_callback;
static PyObject *__pyx_n_s_create_actor_locals_check;
static PyObject *__pyx_n_s_create_actor_locals_on_failure;
static PyObject *__pyx_n_s_create_actor_locals_on_success;
static PyObject *__pyx_n_s_create_actor_ref;
static PyObject *__pyx_n_s_create_connection;
static PyObject *__pyx_n_s_create_local_actor;
static PyObject *__pyx_n_s_create_process_actor;
static PyObject *__pyx_n_s_create_process_actor_locals_che;
static PyObject *__pyx_n_s_create_remote_actor;
static PyObject *__pyx_n_s_ctx;
static PyObject *__pyx_n_s_daemon;
static PyObject *__pyx_n_s_decoder;
static PyObject *__pyx_n_s_del;
static PyObject *__pyx_n_s_delay;
static PyObject *__pyx_n_s_destroy_actor;
static PyObject *__pyx_n_s_destroy_actor_locals_check;
static PyObject *__pyx_n_s_destroy_local_actor;
static PyObject *__pyx_n_s_destroy_process_actor;
static PyObject *__pyx_n_s_destroy_process_actor_locals_ch;
static PyObject *__pyx_n_s_dict;
static PyObject *__pyx_n_s_discard;
static PyObject *__pyx_n_s_dispatch;
static PyObject *__pyx_n_s_distribute;
static PyObject *__pyx_n_s_distributor;
static PyObject *__pyx_n_s_doc;
static PyObject *__pyx_n_s_encoder;
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_type;
static PyObject *__pyx_n_s_errors;
static PyObject *__pyx_n_s_event;
static PyObject *__pyx_n_s_ex;
static PyObject *__pyx_n_s_exc_info;
static PyObject *__pyx_n_s_exception;
static PyObject *__pyx_n_s_exit;
static PyObject *__pyx_n_s_fd;
static PyObject *__pyx_n_s_fileno;
static PyObject *__pyx_n_s_fileobject;
static PyObject *__pyx_n_s_fire_run;
static PyObject *__pyx_n_s_fn;
static PyObject *__pyx_n_s_fobj;
static PyObject *__pyx_n_s_format;
static PyObject *__pyx_n_s_from_index;
static PyObject *__pyx_n_s_future;
static PyObject *__pyx_n_s_g;
static PyObject *__pyx_n_s_genexpr;
static PyObject *__pyx_n_s_get;
static PyObject *__pyx_n_s_get_actor_execution_ctx;
static PyObject *__pyx_n_s_getstate;
static PyObject *__pyx_n_s_gevent;
static PyObject *__pyx_n_s_gevent__tblib;
static PyObject *__pyx_n_s_gevent_event;
static PyObject *__pyx_n_s_gevent_fileobject;
static PyObject *__pyx_n_s_gevent_init_tblib;
static PyObject *__pyx_n_s_gevent_lock;
static PyObject *__pyx_n_s_gevent_pool;
static PyObject *__pyx_n_s_gevent_queue;
static PyObject *__pyx_n_s_gevent_server;
static PyObject *__pyx_n_s_gevent_socket;
static PyObject *__pyx_n_s_gevent_subprocess;
static PyObject *__pyx_n_s_gevent_threadpool;
static PyObject *__pyx_n_s_gipc;
static PyObject *__pyx_n_s_global_lock;
static PyObject *__pyx_n_s_got;
static PyObject *__pyx_n_s_got_broken_pipe;
static PyObject *__pyx_n_s_handler;
static PyObject *__pyx_n_s_has_actor;
static PyObject *__pyx_n_s_has_actor_locals_check;
static PyObject *__pyx_n_s_has_local_actor;
static PyObject *__pyx_n_s_has_process_actor;
static PyObject *__pyx_n_s_has_process_actor_locals_check;
static PyObject *__pyx_n_s_i;
static PyObject *__pyx_n_s_idx;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_inaction_decoder;
static PyObject *__pyx_n_s_inaction_encoder;
static PyObject *__pyx_n_s_index;
static PyObject *__pyx_n_s_init;
static PyObject *__pyx_n_s_init_2;
static PyObject *__pyx_n_s_is_alive;
static PyObject *__pyx_n_s_islice;
static PyObject *__pyx_n_s_iteritems;
static PyObject *__pyx_n_s_iterkeys;
static PyObject *__pyx_n_s_itertools;
static PyObject *__pyx_n_s_itervalues;
static PyObject *__pyx_n_s_join;
static PyObject *__pyx_n_s_joinall;
static PyObject *__pyx_n_s_kwargs;
static PyObject *__pyx_n_s_l;
static PyObject *__pyx_n_s_lib;
static PyObject *__pyx_n_s_link_exception;
static PyObject *__pyx_n_s_link_value;
static PyObject *__pyx_n_s_listener;
static PyObject *__pyx_n_s_lk;
static PyObject *__pyx_n_s_local_func;
static PyObject *__pyx_n_s_local_pool;
static PyObject *__pyx_n_s_lock;
static PyObject *__pyx_n_s_locked;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_mars_actors_pool_gevent_pool;
static PyObject *__pyx_kp_s_mars_actors_pool_gevent_pool_pyx;
static PyObject *__pyx_n_s_maxlen;
static PyObject *__pyx_n_s_message;
static PyObject *__pyx_n_s_message_id;
static PyObject *__pyx_n_s_messages;
static PyObject *__pyx_n_s_metaclass;
static PyObject *__pyx_n_s_mode;
static PyObject *__pyx_n_s_module;
static PyObject *__pyx_n_s_multi_process;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous;
static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou;
static PyObject *__pyx_n_s_new;
static PyObject *__pyx_n_s_np;
static PyObject *__pyx_n_s_num_threads;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_kp_s_numpy_core_multiarray_failed_to;
static PyObject *__pyx_kp_s_numpy_core_umath_failed_to_impor;
static PyObject *__pyx_n_s_object;
static PyObject *__pyx_n_s_on_failure;
static PyObject *__pyx_n_s_on_receive;
static PyObject *__pyx_n_s_on_receive_action;
static PyObject *__pyx_n_s_on_receive_create_actor;
static PyObject *__pyx_n_s_on_receive_destroy_actor;
static PyObject *__pyx_n_s_on_receive_error;
static PyObject *__pyx_n_s_on_receive_has_actor;
static PyObject *__pyx_n_s_on_receive_locals_lambda;
static PyObject *__pyx_n_s_on_receive_result;
static PyObject *__pyx_n_s_on_receive_send;
static PyObject *__pyx_n_s_on_receive_tell;
static PyObject *__pyx_n_s_on_success;
static PyObject *__pyx_n_s_p;
static PyObject *__pyx_n_s_parallel;
static PyObject *__pyx_n_s_pickle;
static PyObject *__pyx_n_s_pipe;
static PyObject *__pyx_n_s_pipes;
static PyObject *__pyx_n_s_pool;
static PyObject *__pyx_n_s_pop;
static PyObject *__pyx_n_s_popen;
static PyObject *__pyx_n_s_prepare;
static PyObject *__pyx_n_s_process;
static PyObject *__pyx_n_s_property;
static PyObject *__pyx_n_s_ps;
static PyObject *__pyx_n_s_put;
static PyObject *__pyx_n_s_pyx_PickleError;
static PyObject *__pyx_n_s_pyx_checksum;
static PyObject *__pyx_n_s_pyx_result;
static PyObject *__pyx_n_s_pyx_state;
static PyObject *__pyx_n_s_pyx_type;
static PyObject *__pyx_n_s_pyx_unpickle_ActorClient;
static PyObject *__pyx_n_s_pyx_unpickle_ActorContext;
static PyObject *__pyx_n_s_pyx_unpickle_ActorExecutionCon;
static PyObject *__pyx_n_s_pyx_unpickle_ActorPool;
static PyObject *__pyx_n_s_pyx_unpickle_ActorRemoteHelper;
static PyObject *__pyx_n_s_pyx_unpickle_ActorServerHandle;
static PyObject *__pyx_n_s_pyx_unpickle_AsyncHandler;
static PyObject *__pyx_n_s_pyx_unpickle_Communicator;
static PyObject *__pyx_n_s_pyx_unpickle_Connection;
static PyObject *__pyx_n_s_pyx_unpickle_Dispatcher;
static PyObject *__pyx_n_s_pyx_unpickle_LocalActorPool;
static PyObject *__pyx_n_s_pyx_unpickle_MessageContext;
static PyObject *__pyx_n_s_pyx_unpickle_ThreadPool;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_qualname;
static PyObject *__pyx_n_s_queue;
static PyObject *__pyx_n_s_randint;
static PyObject *__pyx_n_s_random;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_rb;
static PyObject *__pyx_n_s_receive;
static PyObject *__pyx_n_s_recv;
static PyObject *__pyx_n_s_redirect_func;
static PyObject *__pyx_n_s_reduce;
static PyObject *__pyx_n_s_reduce_cython;
static PyObject *__pyx_n_s_reduce_ex;
static PyObject *__pyx_n_s_ref;
static PyObject *__pyx_n_s_release;
static PyObject *__pyx_n_s_remote_func;
static PyObject *__pyx_n_s_replace_pipe;
static PyObject *__pyx_n_s_reraise;
static PyObject *__pyx_n_s_restart_process;
static PyObject *__pyx_n_s_result;
static PyObject *__pyx_n_s_ret;
static PyObject *__pyx_n_s_run;
static PyObject *__pyx_n_s_run_locals_close;
static PyObject *__pyx_n_s_run_locals_genexpr;
static PyObject *__pyx_n_s_run_locals_stop_func;
static PyObject *__pyx_n_s_seconds;
static PyObject *__pyx_n_s_seed;
static PyObject *__pyx_n_s_self;
static PyObject *__pyx_n_s_send;
static PyObject *__pyx_n_s_send_2;
static PyObject *__pyx_n_s_send_local;
static PyObject *__pyx_n_s_send_local_locals_on_failure;
static PyObject *__pyx_n_s_send_local_locals_on_success;
static PyObject *__pyx_n_s_send_locals_check;
static PyObject *__pyx_n_s_send_process;
static PyObject *__pyx_n_s_send_process_locals_check;
static PyObject *__pyx_n_s_send_remote;
static PyObject *__pyx_n_s_sendall;
static PyObject *__pyx_n_s_sender;
static PyObject *__pyx_n_s_server;
static PyObject *__pyx_n_s_set;
static PyObject *__pyx_n_s_set_comm;
static PyObject *__pyx_n_s_set_exception;
static PyObject *__pyx_n_s_set_result;
static PyObject *__pyx_n_s_set_server;
static PyObject *__pyx_n_s_setstate;
static PyObject *__pyx_n_s_setstate_cython;
static PyObject *__pyx_n_s_six;
static PyObject *__pyx_n_s_sleep;
static PyObject *__pyx_n_s_sock;
static PyObject *__pyx_n_s_socket;
static PyObject *__pyx_n_s_socks;
static PyObject *__pyx_n_s_spawn;
static PyObject *__pyx_n_s_spawn_later;
static PyObject *__pyx_n_s_split;
static PyObject *__pyx_n_s_start;
static PyObject *__pyx_n_s_start_local_pool;
static PyObject *__pyx_n_s_start_process;
static PyObject *__pyx_n_s_start_process_2;
static PyObject *__pyx_n_s_staticmethod;
static PyObject *__pyx_n_s_stop;
static PyObject *__pyx_n_s_stop_func;
static PyObject *__pyx_n_s_string_types;
static PyObject *__pyx_kp_s_stringsource;
static PyObject *__pyx_n_s_struct;
static PyObject *__pyx_n_s_submit;
static PyObject *__pyx_n_s_subprocess;
static PyObject *__pyx_n_s_successful;
static PyObject *__pyx_n_s_super;
static PyObject *__pyx_n_s_sys;
static PyObject *__pyx_n_s_t;
static PyObject *__pyx_n_s_tb;
static PyObject *__pyx_n_s_tell;
static PyObject *__pyx_n_s_terminate;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_threadpool;
static PyObject *__pyx_n_s_throw;
static PyObject *__pyx_n_s_timeout;
static PyObject *__pyx_n_s_to_index;
static PyObject *__pyx_n_s_traceback;
static PyObject *__pyx_n_s_uid;
static PyObject *__pyx_n_s_unique_id;
static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd;
static PyObject *__pyx_n_s_update;
static PyObject *__pyx_n_s_utils;
static PyObject *__pyx_n_s_value;
static PyObject *__pyx_n_s_values;
static PyObject *__pyx_n_s_wait;
static PyObject *__pyx_n_s_wait_response;
static PyObject *__pyx_n_s_weakref;
static PyObject *__pyx_n_s_write_remote_message;
static PyObject *__pyx_n_s_zip;
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self, PyObject *__pyx_v_message); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_2result(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_4__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_6__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, PyObject *__pyx_v_actor, PyObject *__pyx_v_comm); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_2fire_run(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4receive(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_message_ctx); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_6__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_8__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_10ThreadPool___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *__pyx_v_self, PyObject *__pyx_v_num_threads); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10ThreadPool_2submit(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *__pyx_v_self, PyObject *__pyx_v_fn, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10ThreadPool_4__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10ThreadPool_6__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self, PyObject *__pyx_v_comm); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_5index___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_11distributor___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_12create_actor_callback(PyObject *__pyx_self, PyObject *__pyx_v_ret); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_2create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_4destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_6has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_8actor_ref(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_10send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_12tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, PyObject *__pyx_v_delay, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_14sleep(PyObject *__pyx_v_seconds); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_16fileobject(PyObject *__pyx_v_fobj, PyObject *__pyx_v_mode, PyObject *__pyx_v_bufsize, PyObject *__pyx_v_close); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_18popen(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_20threadpool(PyObject *__pyx_v_num_threads); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_22__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_24__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_address, PyObject *__pyx_v_index); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_4comm___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_2set_comm(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_comm); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_4get_actor_execution_ctx(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_actor_uid); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_uid, PyObject *__pyx_v_args, PyObject *__pyx_v_kw); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_8has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_actor_uid); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_actor_uid); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_5index___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_5index_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_12__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_14__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_2submit(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_4future(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id, PyObject *__pyx_v_future, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_6wait(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_8got(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id, PyObject *__pyx_v_result); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_10err(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id, PyObject *__pyx_v_t, PyObject *__pyx_v_ex, PyObject *__pyx_v_tb); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_12__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_14__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self, PyObject *__pyx_v_conn, PyObject *__pyx_v_lock); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_2__enter__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4__exit__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v__); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_6release(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4conn___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4conn_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4conn_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4lock___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4lock_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4lock_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_8__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_10__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_address); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_2conn(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_4_connect(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_conn, PyObject *__pyx_v_lock); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_6got_broken_pipe(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fd); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_7connect_close(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_c, PyObject *__pyx_v_lk); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_8connect(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_10__del__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, PyObject *__pyx_v_parallel); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_2_send_remote(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, PyObject *__pyx_v_address, PyObject *__pyx_v_binary); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12create_actor_on_success(PyObject *__pyx_self, PyObject *__pyx_v_g); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12create_actor_2on_failure(PyObject *__pyx_self, PyObject *__pyx_v_g); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_4create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, PyObject *__pyx_v_address, PyObject *__pyx_v_uid, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10_async_run_on_success(PyObject *__pyx_self, PyObject *__pyx_v_g); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10_async_run_2on_failure(PyObject *__pyx_self, PyObject *__pyx_v_g); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_6_async_run(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, PyObject *__pyx_v_address, PyObject *__pyx_v_binaries, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_8destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12actor_ref(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_14_send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait_response, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_16send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_18tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, PyObject *__pyx_v_delay, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_20__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_22__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_pool, struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *__pyx_v_cluster_info, PyObject *__pyx_v_pipe, struct __pyx_obj_4mars_6actors_11distributor_Distributor *__pyx_v_distributor, PyObject *__pyx_v_parallel); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_2_dispatch(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_local_func, PyObject *__pyx_v_redirect_func, PyObject *__pyx_v_remote_func, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send_local_on_success(PyObject *__pyx_self, PyObject *__pyx_v_g); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send_local_2on_failure(PyObject *__pyx_self, PyObject *__pyx_v_g); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_4_send_local(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait_response, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_13_send_process_check(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_6_send_process(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, int __pyx_v_to_index, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait_response, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_8_send_remote(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait_response, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_10_send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait_response, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_12send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_14tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, PyObject *__pyx_v_delay, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_16_create_local_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_21_create_process_actor_check(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_18_create_process_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, int __pyx_v_to_index, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_20_create_remote_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_22create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_address, PyObject *__pyx_v_uid, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_24_destroy_local_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_22_destroy_process_actor_check(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_26_destroy_process_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, int __pyx_v_to_index, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_28destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_30_has_local_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_18_has_process_actor_check(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_32_has_process_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, int __pyx_v_to_index, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_34has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_36_on_receive_send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_38_on_receive_tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_40_on_receive_create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_42_on_receive_destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_44_on_receive_has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_46_on_receive_result(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_48_on_receive_error(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_50on_receive(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_52run(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_5index___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_5index_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_54__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_56__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *__pyx_v_cluster_info, PyObject *__pyx_v_pipes, struct __pyx_obj_4mars_6actors_11distributor_Distributor *__pyx_v_distributor, PyObject *__pyx_v_parallel); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_5_send_check(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_2_send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait_response, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_4send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_6tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, PyObject *__pyx_v_delay, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_12create_actor_check(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_8create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_address, PyObject *__pyx_v_uid, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_13destroy_actor_check(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_10destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_9has_actor_check(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_12has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_14_on_receive_action(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_binary); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_16_on_receive_result(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_binary); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_18_on_receive_error(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_binary); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_20on_receive(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_binary); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_22replace_pipe(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_idx); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_24_check_pipe(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_pipe); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_3run_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_26run(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_28__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_30__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *__pyx_v_self, PyObject *__pyx_v_sender, PyObject *__pyx_v_multi_process); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_2set_server(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *__pyx_v_self, PyObject *__pyx_v_server); /* proto */
static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_4on_receive(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *__pyx_v_self, PyObject *__pyx_v_binary); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_6__call__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *__pyx_v_self, PyObject *__pyx_v_sock, CYTHON_UNUSED PyObject *__pyx_v_address); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_8__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_10__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_listener, PyObject *__pyx_v_handler); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer_2add_sock(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_sock); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer_4close(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_start_actor_server(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *__pyx_v_cluster_info, PyObject *__pyx_v_sender); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_2start_local_pool(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_index, struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *__pyx_v_cluster_info, PyObject *__pyx_v_pipe, struct __pyx_obj_4mars_6actors_11distributor_Distributor *__pyx_v_distributor, PyObject *__pyx_v_parallel, int __pyx_v_join); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_4close_pipe(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_p); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *__pyx_v_cluster_info, struct __pyx_obj_4mars_6actors_11distributor_Distributor *__pyx_v_distributor, PyObject *__pyx_v_parallel); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_12create_actor_callback(PyObject *__pyx_self, PyObject *__pyx_v_ref); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_2create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_4destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_6has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_8actor_ref(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_9processes___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_10_start_process(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v_idx); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_12restart_process(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, int __pyx_v_idx); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_stop_func(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_2close(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_4genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_14run(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_16sleep(PyObject *__pyx_v_seconds); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_18join(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v_timeout); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_20stop(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_22__enter__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_24__exit__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v__); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_26__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_28__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self, PyObject *__pyx_v_parallel); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_2create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_4has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_6destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_8actor_ref(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_10sleep(PyObject *__pyx_v_seconds); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_12threadpool(PyObject *__pyx_v_num_threads); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_14__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_16__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_6__pyx_unpickle_MessageContext(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_8__pyx_unpickle_ActorExecutionContext(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10__pyx_unpickle_ThreadPool(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12__pyx_unpickle_ActorContext(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14__pyx_unpickle_LocalActorPool(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_16__pyx_unpickle_AsyncHandler(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_18__pyx_unpickle_Connection(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_20__pyx_unpickle_ActorRemoteHelper(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_22__pyx_unpickle_Communicator(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_24__pyx_unpickle_Dispatcher(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_26__pyx_unpickle_ActorServerHandler(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_28__pyx_unpickle_ActorPool(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_30__pyx_unpickle_ActorClient(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_MessageContext(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ThreadPool(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorContext(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_LocalActorPool(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_AsyncHandler(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_Connection(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_Communicator(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_Dispatcher(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorServerHandler(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorPool(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorClient(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_get = {0, &__pyx_n_s_get, 0, 0, 0};
static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop = {0, &__pyx_n_s_pop, 0, 0, 0};
static PyObject *__pyx_float_0_05;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_6419405;
static PyObject *__pyx_int_23256143;
static PyObject *__pyx_int_45447796;
static PyObject *__pyx_int_48718332;
static PyObject *__pyx_int_58204060;
static PyObject *__pyx_int_67544450;
static PyObject *__pyx_int_153165912;
static PyObject *__pyx_int_174956831;
static PyObject *__pyx_int_185272064;
static PyObject *__pyx_int_213755342;
static PyObject *__pyx_int_221979240;
static PyObject *__pyx_int_244608269;
static PyObject *__pyx_int_259339352;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_slice__8;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_tuple__11;
static PyObject *__pyx_tuple__13;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__32;
static PyObject *__pyx_tuple__33;
static PyObject *__pyx_tuple__35;
static PyObject *__pyx_tuple__36;
static PyObject *__pyx_tuple__39;
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__45;
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__56;
static PyObject *__pyx_tuple__58;
static PyObject *__pyx_tuple__60;
static PyObject *__pyx_tuple__62;
static PyObject *__pyx_tuple__64;
static PyObject *__pyx_tuple__67;
static PyObject *__pyx_tuple__69;
static PyObject *__pyx_tuple__71;
static PyObject *__pyx_tuple__73;
static PyObject *__pyx_tuple__75;
static PyObject *__pyx_tuple__77;
static PyObject *__pyx_tuple__79;
static PyObject *__pyx_tuple__81;
static PyObject *__pyx_tuple__83;
static PyObject *__pyx_tuple__85;
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__3;
static PyObject *__pyx_codeobj__7;
static PyObject *__pyx_tuple__101;
static PyObject *__pyx_tuple__103;
static PyObject *__pyx_tuple__105;
static PyObject *__pyx_tuple__107;
static PyObject *__pyx_tuple__109;
static PyObject *__pyx_codeobj__10;
static PyObject *__pyx_codeobj__12;
static PyObject *__pyx_codeobj__14;
static PyObject *__pyx_codeobj__16;
static PyObject *__pyx_codeobj__19;
static PyObject *__pyx_codeobj__21;
static PyObject *__pyx_codeobj__22;
static PyObject *__pyx_codeobj__25;
static PyObject *__pyx_codeobj__26;
static PyObject *__pyx_codeobj__27;
static PyObject *__pyx_codeobj__28;
static PyObject *__pyx_codeobj__29;
static PyObject *__pyx_codeobj__30;
static PyObject *__pyx_codeobj__31;
static PyObject *__pyx_codeobj__34;
static PyObject *__pyx_codeobj__37;
static PyObject *__pyx_codeobj__38;
static PyObject *__pyx_codeobj__48;
static PyObject *__pyx_codeobj__50;
static PyObject *__pyx_codeobj__52;
static PyObject *__pyx_codeobj__54;
static PyObject *__pyx_codeobj__57;
static PyObject *__pyx_codeobj__59;
static PyObject *__pyx_codeobj__61;
static PyObject *__pyx_codeobj__63;
static PyObject *__pyx_codeobj__65;
static PyObject *__pyx_codeobj__68;
static PyObject *__pyx_codeobj__70;
static PyObject *__pyx_codeobj__72;
static PyObject *__pyx_codeobj__74;
static PyObject *__pyx_codeobj__76;
static PyObject *__pyx_codeobj__78;
static PyObject *__pyx_codeobj__80;
static PyObject *__pyx_codeobj__82;
static PyObject *__pyx_codeobj__84;
static PyObject *__pyx_codeobj__86;
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__104;
static PyObject *__pyx_codeobj__106;
static PyObject *__pyx_codeobj__108;
static PyObject *__pyx_codeobj__110;
/* Late includes */

/* "mars/actors/pool/gevent_pool.pyx":68
 *     cdef public object async_result
 * 
 *     def __init__(self, message):             # <<<<<<<<<<<<<<
 *         self.message = message
 *         self.async_result = gevent.event.AsyncResult()
 */

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_message = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_message,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) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 68, __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_message = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 68, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.MessageContext.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext___init__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)__pyx_v_self), __pyx_v_message);

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self, PyObject *__pyx_v_message) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":69
 * 
 *     def __init__(self, message):
 *         self.message = message             # <<<<<<<<<<<<<<
 *         self.async_result = gevent.event.AsyncResult()
 * 
 */
  __Pyx_INCREF(__pyx_v_message);
  __Pyx_GIVEREF(__pyx_v_message);
  __Pyx_GOTREF(__pyx_v_self->message);
  __Pyx_DECREF(__pyx_v_self->message);
  __pyx_v_self->message = __pyx_v_message;

  /* "mars/actors/pool/gevent_pool.pyx":70
 *     def __init__(self, message):
 *         self.message = message
 *         self.async_result = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 * 
 *     cpdef result(self):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_event); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 70, __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_AsyncResult); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->async_result);
  __Pyx_DECREF(__pyx_v_self->async_result);
  __pyx_v_self->async_result = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":68
 *     cdef public object async_result
 * 
 *     def __init__(self, message):             # <<<<<<<<<<<<<<
 *         self.message = message
 *         self.async_result = gevent.event.AsyncResult()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.MessageContext.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":72
 *         self.async_result = gevent.event.AsyncResult()
 * 
 *     cpdef result(self):             # <<<<<<<<<<<<<<
 *         return self.async_result.result()
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_3result(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_14MessageContext_result(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self, int __pyx_skip_dispatch) {
  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;
  __Pyx_RefNannySetupContext("result", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_3result)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":73
 * 
 *     cpdef result(self):
 *         return self.async_result.result()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->async_result, __pyx_n_s_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":72
 *         self.async_result = gevent.event.AsyncResult()
 * 
 *     cpdef result(self):             # <<<<<<<<<<<<<<
 *         return self.async_result.result()
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.MessageContext.result", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_3result(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_3result(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("result (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_2result(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_2result(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("result", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_14MessageContext_result(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.MessageContext.result", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":65
 * 
 * cdef class MessageContext:
 *     cdef public object message             # <<<<<<<<<<<<<<
 *     cdef public object async_result
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->message);
  __pyx_r = __pyx_v_self->message;
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->message);
  __Pyx_DECREF(__pyx_v_self->message);
  __pyx_v_self->message = __pyx_v_value;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message_4__del__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)__pyx_v_self));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->message);
  __Pyx_DECREF(__pyx_v_self->message);
  __pyx_v_self->message = Py_None;

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

/* "mars/actors/pool/gevent_pool.pyx":66
 * cdef class MessageContext:
 *     cdef public object message
 *     cdef public object async_result             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, message):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->async_result);
  __pyx_r = __pyx_v_self->async_result;
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->async_result);
  __Pyx_DECREF(__pyx_v_self->async_result);
  __pyx_v_self->async_result = __pyx_v_value;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result_4__del__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)__pyx_v_self));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->async_result);
  __Pyx_DECREF(__pyx_v_self->async_result);
  __pyx_v_self->async_result = Py_None;

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

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_4__reduce_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_4__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.async_result, self.message)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->async_result);
  __Pyx_GIVEREF(__pyx_v_self->async_result);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->async_result);
  __Pyx_INCREF(__pyx_v_self->message);
  __Pyx_GIVEREF(__pyx_v_self->message);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->message);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.async_result, self.message)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self.async_result, self.message)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.async_result is not None or self.message is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.async_result, self.message)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.async_result is not None or self.message is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_MessageContext, (type(self), 0x9212058, None), state
 */
  /*else*/ {
    __pyx_t_2 = (__pyx_v_self->async_result != Py_None);
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->message != Py_None);
    __pyx_t_2 = (__pyx_t_5 != 0);
    __pyx_t_3 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.async_result is not None or self.message is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_MessageContext, (type(self), 0x9212058, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self.async_result is not None or self.message is not None
 *     if use_setstate:
 *         return __pyx_unpickle_MessageContext, (type(self), 0x9212058, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_MessageContext, (type(self), 0x9212058, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_MessageContext); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_153165912);
    __Pyx_GIVEREF(__pyx_int_153165912);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_153165912);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.async_result is not None or self.message is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_MessageContext, (type(self), 0x9212058, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_MessageContext, (type(self), 0x9212058, None), state
 *     else:
 *         return __pyx_unpickle_MessageContext, (type(self), 0x9212058, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_MessageContext__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_MessageContext); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_153165912);
    __Pyx_GIVEREF(__pyx_int_153165912);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_153165912);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.MessageContext.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_MessageContext, (type(self), 0x9212058, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_MessageContext__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_6__setstate_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14MessageContext_6__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_MessageContext, (type(self), 0x9212058, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_MessageContext__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_MessageContext__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_MessageContext, (type(self), 0x9212058, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_MessageContext__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.MessageContext.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":82
 *     cdef public object comm
 * 
 *     def __init__(self, actor, comm):             # <<<<<<<<<<<<<<
 *         self.actor = weakref.ref(actor)
 *         self.lock = gevent.lock.RLock()
 */

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_actor = 0;
  PyObject *__pyx_v_comm = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor,&__pyx_n_s_comm,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_comm)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 82, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 82, __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_actor = values[0];
    __pyx_v_comm = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 82, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorExecutionContext.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext___init__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_self), __pyx_v_actor, __pyx_v_comm);

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, PyObject *__pyx_v_actor, PyObject *__pyx_v_comm) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":83
 * 
 *     def __init__(self, actor, comm):
 *         self.actor = weakref.ref(actor)             # <<<<<<<<<<<<<<
 *         self.lock = gevent.lock.RLock()
 *         self.inbox = gevent.queue.Queue()
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_weakref); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ref); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_actor) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_actor);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->actor);
  __Pyx_DECREF(__pyx_v_self->actor);
  __pyx_v_self->actor = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":84
 *     def __init__(self, actor, comm):
 *         self.actor = weakref.ref(actor)
 *         self.lock = gevent.lock.RLock()             # <<<<<<<<<<<<<<
 *         self.inbox = gevent.queue.Queue()
 *         self.comm = comm
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_gevent); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_lock); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __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_RLock); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->lock);
  __Pyx_DECREF(__pyx_v_self->lock);
  __pyx_v_self->lock = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":85
 *         self.actor = weakref.ref(actor)
 *         self.lock = gevent.lock.RLock()
 *         self.inbox = gevent.queue.Queue()             # <<<<<<<<<<<<<<
 *         self.comm = comm
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_gevent); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_queue); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __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_Queue); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->inbox);
  __Pyx_DECREF(__pyx_v_self->inbox);
  __pyx_v_self->inbox = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":86
 *         self.lock = gevent.lock.RLock()
 *         self.inbox = gevent.queue.Queue()
 *         self.comm = comm             # <<<<<<<<<<<<<<
 * 
 *     cpdef object fire_run(self):
 */
  __Pyx_INCREF(__pyx_v_comm);
  __Pyx_GIVEREF(__pyx_v_comm);
  __Pyx_GOTREF(__pyx_v_self->comm);
  __Pyx_DECREF(__pyx_v_self->comm);
  __pyx_v_self->comm = __pyx_v_comm;

  /* "mars/actors/pool/gevent_pool.pyx":82
 *     cdef public object comm
 * 
 *     def __init__(self, actor, comm):             # <<<<<<<<<<<<<<
 *         self.actor = weakref.ref(actor)
 *         self.lock = gevent.lock.RLock()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorExecutionContext.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":88
 *         self.comm = comm
 * 
 *     cpdef object fire_run(self):             # <<<<<<<<<<<<<<
 *         cdef MessageContext message_ctx
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_3fire_run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_fire_run(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, int __pyx_skip_dispatch) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_message_ctx = 0;
  PyObject *__pyx_v_actor = NULL;
  PyObject *__pyx_v_res = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_ex = NULL;
  PyObject *__pyx_v_tb = 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;
  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;
  PyObject *__pyx_t_15 = NULL;
  PyObject *(*__pyx_t_16)(PyObject *);
  int __pyx_t_17;
  int __pyx_t_18;
  __Pyx_RefNannySetupContext("fire_run", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_fire_run); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_3fire_run)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":91
 *         cdef MessageContext message_ctx
 * 
 *         with self.lock:             # <<<<<<<<<<<<<<
 *             message_ctx = self.inbox.get()
 *             actor = self.actor()
 */
  /*with:*/ {
    __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_v_self->lock, __pyx_n_s_exit); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 91, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_v_self->lock, __pyx_n_s_enter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L3_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L3_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    /*try:*/ {
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __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:*/ {

          /* "mars/actors/pool/gevent_pool.pyx":92
 * 
 *         with self.lock:
 *             message_ctx = self.inbox.get()             # <<<<<<<<<<<<<<
 *             actor = self.actor()
 * 
 */
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->inbox, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = NULL;
          if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4mars_6actors_4pool_11gevent_pool_MessageContext))))) __PYX_ERR(0, 92, __pyx_L7_error)
          __pyx_v_message_ctx = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)__pyx_t_1);
          __pyx_t_1 = 0;

          /* "mars/actors/pool/gevent_pool.pyx":93
 *         with self.lock:
 *             message_ctx = self.inbox.get()
 *             actor = self.actor()             # <<<<<<<<<<<<<<
 * 
 *             try:
 */
          __Pyx_INCREF(__pyx_v_self->actor);
          __pyx_t_2 = __pyx_v_self->actor; __pyx_t_3 = NULL;
          if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_v_actor = __pyx_t_1;
          __pyx_t_1 = 0;

          /* "mars/actors/pool/gevent_pool.pyx":95
 *             actor = self.actor()
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 res = actor.on_receive(message_ctx.message)
 *                 message_ctx.async_result.set_result(res)
 */
          {
            __Pyx_PyThreadState_declare
            __Pyx_PyThreadState_assign
            __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:*/ {

              /* "mars/actors/pool/gevent_pool.pyx":96
 * 
 *             try:
 *                 res = actor.on_receive(message_ctx.message)             # <<<<<<<<<<<<<<
 *                 message_ctx.async_result.set_result(res)
 *                 return res
 */
              __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_actor, __pyx_n_s_on_receive); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_3 = NULL;
              if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_message_ctx->message) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_message_ctx->message);
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __pyx_v_res = __pyx_t_1;
              __pyx_t_1 = 0;

              /* "mars/actors/pool/gevent_pool.pyx":97
 *             try:
 *                 res = actor.on_receive(message_ctx.message)
 *                 message_ctx.async_result.set_result(res)             # <<<<<<<<<<<<<<
 *                 return res
 *             except:
 */
              __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_message_ctx->async_result, __pyx_n_s_set_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_3 = NULL;
              if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_res) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_res);
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

              /* "mars/actors/pool/gevent_pool.pyx":98
 *                 res = actor.on_receive(message_ctx.message)
 *                 message_ctx.async_result.set_result(res)
 *                 return res             # <<<<<<<<<<<<<<
 *             except:
 *                 t, ex, tb = sys.exc_info()
 */
              __Pyx_XDECREF(__pyx_r);
              __Pyx_INCREF(__pyx_v_res);
              __pyx_r = __pyx_v_res;
              goto __pyx_L17_try_return;

              /* "mars/actors/pool/gevent_pool.pyx":95
 *             actor = self.actor()
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 res = actor.on_receive(message_ctx.message)
 *                 message_ctx.async_result.set_result(res)
 */
            }
            __pyx_L13_error:;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

            /* "mars/actors/pool/gevent_pool.pyx":99
 *                 message_ctx.async_result.set_result(res)
 *                 return res
 *             except:             # <<<<<<<<<<<<<<
 *                 t, ex, tb = sys.exc_info()
 *                 message_ctx.async_result.set_exception(ex, exc_info=(t, ex, tb))
 */
            /*except:*/ {
              __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorExecutionContext.fire_run", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 99, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_GOTREF(__pyx_t_3);

              /* "mars/actors/pool/gevent_pool.pyx":100
 *                 return res
 *             except:
 *                 t, ex, tb = sys.exc_info()             # <<<<<<<<<<<<<<
 *                 message_ctx.async_result.set_exception(ex, exc_info=(t, ex, tb))
 *                 raise
 */
              __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_sys); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 100, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_12);
              __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 100, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              __pyx_t_12 = NULL;
              if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
                __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
                if (likely(__pyx_t_12)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
                  __Pyx_INCREF(__pyx_t_12);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_13, function);
                }
              }
              __pyx_t_4 = (__pyx_t_12) ? __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_12) : __Pyx_PyObject_CallNoArg(__pyx_t_13);
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 100, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
                PyObject* sequence = __pyx_t_4;
                Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
                if (unlikely(size != 3)) {
                  if (size > 3) __Pyx_RaiseTooManyValuesError(3);
                  else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
                  __PYX_ERR(0, 100, __pyx_L15_except_error)
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                if (likely(PyTuple_CheckExact(sequence))) {
                  __pyx_t_13 = PyTuple_GET_ITEM(sequence, 0); 
                  __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); 
                  __pyx_t_14 = PyTuple_GET_ITEM(sequence, 2); 
                } else {
                  __pyx_t_13 = PyList_GET_ITEM(sequence, 0); 
                  __pyx_t_12 = PyList_GET_ITEM(sequence, 1); 
                  __pyx_t_14 = PyList_GET_ITEM(sequence, 2); 
                }
                __Pyx_INCREF(__pyx_t_13);
                __Pyx_INCREF(__pyx_t_12);
                __Pyx_INCREF(__pyx_t_14);
                #else
                __pyx_t_13 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 100, __pyx_L15_except_error)
                __Pyx_GOTREF(__pyx_t_13);
                __pyx_t_12 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 100, __pyx_L15_except_error)
                __Pyx_GOTREF(__pyx_t_12);
                __pyx_t_14 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 100, __pyx_L15_except_error)
                __Pyx_GOTREF(__pyx_t_14);
                #endif
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              } else {
                Py_ssize_t index = -1;
                __pyx_t_15 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 100, __pyx_L15_except_error)
                __Pyx_GOTREF(__pyx_t_15);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __pyx_t_16 = Py_TYPE(__pyx_t_15)->tp_iternext;
                index = 0; __pyx_t_13 = __pyx_t_16(__pyx_t_15); if (unlikely(!__pyx_t_13)) goto __pyx_L21_unpacking_failed;
                __Pyx_GOTREF(__pyx_t_13);
                index = 1; __pyx_t_12 = __pyx_t_16(__pyx_t_15); if (unlikely(!__pyx_t_12)) goto __pyx_L21_unpacking_failed;
                __Pyx_GOTREF(__pyx_t_12);
                index = 2; __pyx_t_14 = __pyx_t_16(__pyx_t_15); if (unlikely(!__pyx_t_14)) goto __pyx_L21_unpacking_failed;
                __Pyx_GOTREF(__pyx_t_14);
                if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_15), 3) < 0) __PYX_ERR(0, 100, __pyx_L15_except_error)
                __pyx_t_16 = NULL;
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                goto __pyx_L22_unpacking_done;
                __pyx_L21_unpacking_failed:;
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                __pyx_t_16 = NULL;
                if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
                __PYX_ERR(0, 100, __pyx_L15_except_error)
                __pyx_L22_unpacking_done:;
              }
              __pyx_v_t = __pyx_t_13;
              __pyx_t_13 = 0;
              __pyx_v_ex = __pyx_t_12;
              __pyx_t_12 = 0;
              __pyx_v_tb = __pyx_t_14;
              __pyx_t_14 = 0;

              /* "mars/actors/pool/gevent_pool.pyx":101
 *             except:
 *                 t, ex, tb = sys.exc_info()
 *                 message_ctx.async_result.set_exception(ex, exc_info=(t, ex, tb))             # <<<<<<<<<<<<<<
 *                 raise
 * 
 */
              __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_message_ctx->async_result, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 101, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 101, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_14);
              __Pyx_INCREF(__pyx_v_ex);
              __Pyx_GIVEREF(__pyx_v_ex);
              PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_v_ex);
              __pyx_t_12 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 101, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_12);
              __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 101, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_13);
              __Pyx_INCREF(__pyx_v_t);
              __Pyx_GIVEREF(__pyx_v_t);
              PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_t);
              __Pyx_INCREF(__pyx_v_ex);
              __Pyx_GIVEREF(__pyx_v_ex);
              PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_ex);
              __Pyx_INCREF(__pyx_v_tb);
              __Pyx_GIVEREF(__pyx_v_tb);
              PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_v_tb);
              if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_exc_info, __pyx_t_13) < 0) __PYX_ERR(0, 101, __pyx_L15_except_error)
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_14, __pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 101, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

              /* "mars/actors/pool/gevent_pool.pyx":102
 *                 t, ex, tb = sys.exc_info()
 *                 message_ctx.async_result.set_exception(ex, exc_info=(t, ex, tb))
 *                 raise             # <<<<<<<<<<<<<<
 * 
 *     cpdef void receive(self, MessageContext message_ctx):
 */
              __Pyx_GIVEREF(__pyx_t_1);
              __Pyx_GIVEREF(__pyx_t_2);
              __Pyx_XGIVEREF(__pyx_t_3);
              __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_2, __pyx_t_3);
              __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; 
              __PYX_ERR(0, 102, __pyx_L15_except_error)
            }
            __pyx_L15_except_error:;

            /* "mars/actors/pool/gevent_pool.pyx":95
 *             actor = self.actor()
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 res = actor.on_receive(message_ctx.message)
 *                 message_ctx.async_result.set_result(res)
 */
            __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_L7_error;
            __pyx_L17_try_return:;
            __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_L11_try_return;
          }

          /* "mars/actors/pool/gevent_pool.pyx":91
 *         cdef MessageContext message_ctx
 * 
 *         with self.lock:             # <<<<<<<<<<<<<<
 *             message_ctx = self.inbox.get()
 *             actor = self.actor()
 */
        }
        __pyx_L7_error:;
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        /*except:*/ {
          __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorExecutionContext.fire_run", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1) < 0) __PYX_ERR(0, 91, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_13 = PyTuple_Pack(3, __pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 91, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_13, NULL);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 91, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (__pyx_t_17 < 0) __PYX_ERR(0, 91, __pyx_L9_except_error)
          __pyx_t_18 = ((!(__pyx_t_17 != 0)) != 0);
          if (__pyx_t_18) {
            __Pyx_GIVEREF(__pyx_t_3);
            __Pyx_GIVEREF(__pyx_t_2);
            __Pyx_XGIVEREF(__pyx_t_1);
            __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_2, __pyx_t_1);
            __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_1 = 0; 
            __PYX_ERR(0, 91, __pyx_L9_except_error)
          }
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__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_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);
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_5) {
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple_, NULL);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 91, __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_5) {
          __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple_, NULL);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 91, __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_L26;
    __pyx_L3_error:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L1_error;
    __pyx_L26:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":88
 *         self.comm = comm
 * 
 *     cpdef object fire_run(self):             # <<<<<<<<<<<<<<
 *         cdef MessageContext message_ctx
 * 
 */

  /* 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_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorExecutionContext.fire_run", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_message_ctx);
  __Pyx_XDECREF(__pyx_v_actor);
  __Pyx_XDECREF(__pyx_v_res);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_ex);
  __Pyx_XDECREF(__pyx_v_tb);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_3fire_run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_3fire_run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fire_run (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_2fire_run(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_2fire_run(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("fire_run", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_fire_run(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorExecutionContext.fire_run", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":104
 *                 raise
 * 
 *     cpdef void receive(self, MessageContext message_ctx):             # <<<<<<<<<<<<<<
 *         self.inbox.put(message_ctx)
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5receive(PyObject *__pyx_v_self, PyObject *__pyx_v_message_ctx); /*proto*/
static void __pyx_f_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_receive(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_message_ctx, int __pyx_skip_dispatch) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("receive", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_receive); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5receive)) {
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, ((PyObject *)__pyx_v_message_ctx)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_message_ctx));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":105
 * 
 *     cpdef void receive(self, MessageContext message_ctx):
 *         self.inbox.put(message_ctx)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->inbox, __pyx_n_s_put); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_v_message_ctx)) : __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_message_ctx));
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __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;

  /* "mars/actors/pool/gevent_pool.pyx":104
 *                 raise
 * 
 *     cpdef void receive(self, MessageContext message_ctx):             # <<<<<<<<<<<<<<
 *         self.inbox.put(message_ctx)
 * 
 */

  /* function exit code */
  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_WriteUnraisable("mars.actors.pool.gevent_pool.ActorExecutionContext.receive", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5receive(PyObject *__pyx_v_self, PyObject *__pyx_v_message_ctx); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5receive(PyObject *__pyx_v_self, PyObject *__pyx_v_message_ctx) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("receive (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_message_ctx), __pyx_ptype_4mars_6actors_4pool_11gevent_pool_MessageContext, 1, "message_ctx", 0))) __PYX_ERR(0, 104, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4receive(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_self), ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)__pyx_v_message_ctx));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4receive(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_message_ctx) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("receive", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_void_to_None(__pyx_f_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_receive(__pyx_v_self, __pyx_v_message_ctx, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorExecutionContext.receive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":77
 * 
 * cdef class ActorExecutionContext:
 *     cdef public object actor             # <<<<<<<<<<<<<<
 *     cdef public object lock
 *     cdef public object inbox
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->actor);
  __pyx_r = __pyx_v_self->actor;
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->actor);
  __Pyx_DECREF(__pyx_v_self->actor);
  __pyx_v_self->actor = __pyx_v_value;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor_4__del__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_self));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->actor);
  __Pyx_DECREF(__pyx_v_self->actor);
  __pyx_v_self->actor = Py_None;

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

/* "mars/actors/pool/gevent_pool.pyx":78
 * cdef class ActorExecutionContext:
 *     cdef public object actor
 *     cdef public object lock             # <<<<<<<<<<<<<<
 *     cdef public object inbox
 *     cdef public object comm
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->lock);
  __pyx_r = __pyx_v_self->lock;
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->lock);
  __Pyx_DECREF(__pyx_v_self->lock);
  __pyx_v_self->lock = __pyx_v_value;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock_4__del__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_self));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->lock);
  __Pyx_DECREF(__pyx_v_self->lock);
  __pyx_v_self->lock = Py_None;

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

/* "mars/actors/pool/gevent_pool.pyx":79
 *     cdef public object actor
 *     cdef public object lock
 *     cdef public object inbox             # <<<<<<<<<<<<<<
 *     cdef public object comm
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->inbox);
  __pyx_r = __pyx_v_self->inbox;
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->inbox);
  __Pyx_DECREF(__pyx_v_self->inbox);
  __pyx_v_self->inbox = __pyx_v_value;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox_4__del__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_self));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->inbox);
  __Pyx_DECREF(__pyx_v_self->inbox);
  __pyx_v_self->inbox = Py_None;

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

/* "mars/actors/pool/gevent_pool.pyx":80
 *     cdef public object lock
 *     cdef public object inbox
 *     cdef public object comm             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, actor, comm):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->comm);
  __pyx_r = __pyx_v_self->comm;
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->comm);
  __Pyx_DECREF(__pyx_v_self->comm);
  __pyx_v_self->comm = __pyx_v_value;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm_4__del__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_self));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->comm);
  __Pyx_DECREF(__pyx_v_self->comm);
  __pyx_v_self->comm = Py_None;

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

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_6__reduce_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_6__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.actor, self.comm, self.inbox, self.lock)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->actor);
  __Pyx_GIVEREF(__pyx_v_self->actor);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->actor);
  __Pyx_INCREF(__pyx_v_self->comm);
  __Pyx_GIVEREF(__pyx_v_self->comm);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->comm);
  __Pyx_INCREF(__pyx_v_self->inbox);
  __Pyx_GIVEREF(__pyx_v_self->inbox);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_self->inbox);
  __Pyx_INCREF(__pyx_v_self->lock);
  __Pyx_GIVEREF(__pyx_v_self->lock);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_self->lock);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.actor, self.comm, self.inbox, self.lock)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self.actor, self.comm, self.inbox, self.lock)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.actor is not None or self.comm is not None or self.inbox is not None or self.lock is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.actor, self.comm, self.inbox, self.lock)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.actor is not None or self.comm is not None or self.inbox is not None or self.lock is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_ActorExecutionContext, (type(self), 0xa6da11f, None), state
 */
  /*else*/ {
    __pyx_t_2 = (__pyx_v_self->actor != Py_None);
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->comm != Py_None);
    __pyx_t_2 = (__pyx_t_5 != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (__pyx_v_self->inbox != Py_None);
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->lock != Py_None);
    __pyx_t_2 = (__pyx_t_5 != 0);
    __pyx_t_3 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.actor is not None or self.comm is not None or self.inbox is not None or self.lock is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ActorExecutionContext, (type(self), 0xa6da11f, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self.actor is not None or self.comm is not None or self.inbox is not None or self.lock is not None
 *     if use_setstate:
 *         return __pyx_unpickle_ActorExecutionContext, (type(self), 0xa6da11f, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_ActorExecutionContext, (type(self), 0xa6da11f, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_ActorExecutionCon); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_174956831);
    __Pyx_GIVEREF(__pyx_int_174956831);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_174956831);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.actor is not None or self.comm is not None or self.inbox is not None or self.lock is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ActorExecutionContext, (type(self), 0xa6da11f, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_ActorExecutionContext, (type(self), 0xa6da11f, None), state
 *     else:
 *         return __pyx_unpickle_ActorExecutionContext, (type(self), 0xa6da11f, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ActorExecutionContext__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_ActorExecutionCon); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_174956831);
    __Pyx_GIVEREF(__pyx_int_174956831);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_174956831);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorExecutionContext.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ActorExecutionContext, (type(self), 0xa6da11f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ActorExecutionContext__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_8__setstate_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_8__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_ActorExecutionContext, (type(self), 0xa6da11f, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ActorExecutionContext__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorExecutionContext__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ActorExecutionContext, (type(self), 0xa6da11f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ActorExecutionContext__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorExecutionContext.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":111
 *     cdef object _pool
 * 
 *     def __init__(self, num_threads):             # <<<<<<<<<<<<<<
 *         self._pool = GThreadPool(num_threads)
 * 
 */

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_10ThreadPool_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_10ThreadPool_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_num_threads = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_num_threads,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) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_num_threads)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 111, __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_num_threads = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 111, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ThreadPool.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10ThreadPool___init__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *)__pyx_v_self), __pyx_v_num_threads);

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_10ThreadPool___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *__pyx_v_self, PyObject *__pyx_v_num_threads) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":112
 * 
 *     def __init__(self, num_threads):
 *         self._pool = GThreadPool(num_threads)             # <<<<<<<<<<<<<<
 * 
 *     def submit(self, fn, *args, **kwargs):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_GThreadPool); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_num_threads) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_num_threads);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_pool);
  __Pyx_DECREF(__pyx_v_self->_pool);
  __pyx_v_self->_pool = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":111
 *     cdef object _pool
 * 
 *     def __init__(self, num_threads):             # <<<<<<<<<<<<<<
 *         self._pool = GThreadPool(num_threads)
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ThreadPool.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":114
 *         self._pool = GThreadPool(num_threads)
 * 
 *     def submit(self, fn, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         return self._pool.spawn(fn, *args, **kwargs)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10ThreadPool_3submit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10ThreadPool_3submit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_fn = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("submit (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_fn,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);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fn)) != 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, "submit") < 0)) __PYX_ERR(0, 114, __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_fn = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("submit", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 114, __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("mars.actors.pool.gevent_pool.ThreadPool.submit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10ThreadPool_2submit(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *)__pyx_v_self), __pyx_v_fn, __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_4mars_6actors_4pool_11gevent_pool_10ThreadPool_2submit(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *__pyx_v_self, PyObject *__pyx_v_fn, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("submit", 0);

  /* "mars/actors/pool/gevent_pool.pyx":115
 * 
 *     def submit(self, fn, *args, **kwargs):
 *         return self._pool.spawn(fn, *args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_pool, __pyx_n_s_spawn); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_fn);
  __Pyx_GIVEREF(__pyx_v_fn);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_fn);
  __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_v_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":114
 *         self._pool = GThreadPool(num_threads)
 * 
 *     def submit(self, fn, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         return self._pool.spawn(fn, *args, **kwargs)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ThreadPool.submit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10ThreadPool_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10ThreadPool_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10ThreadPool_4__reduce_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10ThreadPool_4__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  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;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self._pool,)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->_pool);
  __Pyx_GIVEREF(__pyx_v_self->_pool);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->_pool);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self._pool,)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self._pool,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self._pool is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self._pool,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self._pool is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_ThreadPool, (type(self), 0xf753458, None), state
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_self->_pool != Py_None);
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._pool is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ThreadPool, (type(self), 0xf753458, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self._pool is not None
 *     if use_setstate:
 *         return __pyx_unpickle_ThreadPool, (type(self), 0xf753458, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_ThreadPool, (type(self), 0xf753458, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_ThreadPool); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_259339352);
    __Pyx_GIVEREF(__pyx_int_259339352);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_259339352);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __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_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._pool is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ThreadPool, (type(self), 0xf753458, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_ThreadPool, (type(self), 0xf753458, None), state
 *     else:
 *         return __pyx_unpickle_ThreadPool, (type(self), 0xf753458, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ThreadPool__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_ThreadPool); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_259339352);
    __Pyx_GIVEREF(__pyx_int_259339352);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_259339352);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ThreadPool.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ThreadPool, (type(self), 0xf753458, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ThreadPool__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10ThreadPool_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10ThreadPool_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10ThreadPool_6__setstate_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10ThreadPool_6__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_ThreadPool, (type(self), 0xf753458, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ThreadPool__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ThreadPool__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ThreadPool, (type(self), 0xf753458, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ThreadPool__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ThreadPool.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":132
 *     cdef object _comm
 * 
 *     def __init__(self, comm):             # <<<<<<<<<<<<<<
 *         self._comm = comm
 * 
 */

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_comm = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_comm,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) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_comm)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 132, __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_comm = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 132, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorContext.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext___init__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *)__pyx_v_self), __pyx_v_comm);

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self, PyObject *__pyx_v_comm) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":133
 * 
 *     def __init__(self, comm):
 *         self._comm = comm             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_INCREF(__pyx_v_comm);
  __Pyx_GIVEREF(__pyx_v_comm);
  __Pyx_GOTREF(__pyx_v_self->_comm);
  __Pyx_DECREF(__pyx_v_self->_comm);
  __pyx_v_self->_comm = __pyx_v_comm;

  /* "mars/actors/pool/gevent_pool.pyx":132
 *     cdef object _comm
 * 
 *     def __init__(self, comm):             # <<<<<<<<<<<<<<
 *         self._comm = comm
 * 
 */

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

/* "mars/actors/pool/gevent_pool.pyx":136
 * 
 *     @property
 *     def index(self):             # <<<<<<<<<<<<<<
 *         return self._comm.index
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_5index_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_5index_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_5index___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_5index___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":137
 *     @property
 *     def index(self):
 *         return self._comm.index             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_comm, __pyx_n_s_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":136
 * 
 *     @property
 *     def index(self):             # <<<<<<<<<<<<<<
 *         return self._comm.index
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorContext.index.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":140
 * 
 *     @property
 *     def distributor(self):             # <<<<<<<<<<<<<<
 *         return self._comm.distributor
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_11distributor_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_11distributor_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_11distributor___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_11distributor___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":141
 *     @property
 *     def distributor(self):
 *         return self._comm.distributor             # <<<<<<<<<<<<<<
 * 
 *     def create_actor(self, actor_cls, *args, **kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_comm, __pyx_n_s_distributor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":140
 * 
 *     @property
 *     def distributor(self):             # <<<<<<<<<<<<<<
 *         return self._comm.distributor
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorContext.distributor.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":143
 *         return self._comm.distributor
 * 
 *     def create_actor(self, actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef bint wait
 *         cdef object address
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_3create_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_3create_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_actor_cls = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_actor (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_actor_cls,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);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_cls)) != 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, "create_actor") < 0)) __PYX_ERR(0, 143, __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_actor_cls = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_actor", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 143, __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("mars.actors.pool.gevent_pool.ActorContext.create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_2create_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *)__pyx_v_self), __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs);

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

/* "mars/actors/pool/gevent_pool.pyx":158
 *             return ref
 * 
 *         def callback(ret):             # <<<<<<<<<<<<<<
 *             ret.ctx = self
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_12create_actor_1callback(PyObject *__pyx_self, PyObject *__pyx_v_ret); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_12ActorContext_12create_actor_1callback = {"callback", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_12create_actor_1callback, METH_O, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_12create_actor_1callback(PyObject *__pyx_self, PyObject *__pyx_v_ret) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("callback (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_12create_actor_callback(__pyx_self, ((PyObject *)__pyx_v_ret));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_12create_actor_callback(PyObject *__pyx_self, PyObject *__pyx_v_ret) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor *__pyx_outer_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("callback", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":159
 * 
 *         def callback(ret):
 *             ret.ctx = self             # <<<<<<<<<<<<<<
 * 
 *         kwargs['wait'] = False
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 159, __pyx_L1_error) }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_ret, __pyx_n_s_ctx, ((PyObject *)__pyx_cur_scope->__pyx_v_self)) < 0) __PYX_ERR(0, 159, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":158
 *             return ref
 * 
 *         def callback(ret):             # <<<<<<<<<<<<<<
 *             ret.ctx = self
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorContext.create_actor.callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":143
 *         return self._comm.distributor
 * 
 *     def create_actor(self, actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef bint wait
 *         cdef object address
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_2create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor *__pyx_cur_scope;
  int __pyx_v_wait;
  PyObject *__pyx_v_address = 0;
  PyObject *__pyx_v_uid = 0;
  PyObject *__pyx_v_ref = 0;
  PyObject *__pyx_v_callback = 0;
  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;
  __Pyx_RefNannySetupContext("create_actor", 0);
  __pyx_cur_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor *)__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor(__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 143, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);

  /* "mars/actors/pool/gevent_pool.pyx":149
 *         cdef object ref
 * 
 *         wait = kwargs.pop('wait', True)             # <<<<<<<<<<<<<<
 *         address = kwargs.pop('address', None)
 *         uid = kwargs.pop('uid', None)
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_wait, Py_True); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 149, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_wait = __pyx_t_2;

  /* "mars/actors/pool/gevent_pool.pyx":150
 * 
 *         wait = kwargs.pop('wait', True)
 *         address = kwargs.pop('address', None)             # <<<<<<<<<<<<<<
 *         uid = kwargs.pop('uid', None)
 * 
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_address, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_address = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":151
 *         wait = kwargs.pop('wait', True)
 *         address = kwargs.pop('address', None)
 *         uid = kwargs.pop('uid', None)             # <<<<<<<<<<<<<<
 * 
 *         if wait:
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_uid, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_uid = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":153
 *         uid = kwargs.pop('uid', None)
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             ref = self._comm.create_actor(address, uid, actor_cls, *args, **kwargs)
 *             ref.ctx = self
 */
  __pyx_t_2 = (__pyx_v_wait != 0);
  if (__pyx_t_2) {

    /* "mars/actors/pool/gevent_pool.pyx":154
 * 
 *         if wait:
 *             ref = self._comm.create_actor(address, uid, actor_cls, *args, **kwargs)             # <<<<<<<<<<<<<<
 *             ref.ctx = self
 *             return ref
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->_comm, __pyx_n_s_create_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_address);
    __Pyx_GIVEREF(__pyx_v_address);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_address);
    __Pyx_INCREF(__pyx_v_uid);
    __Pyx_GIVEREF(__pyx_v_uid);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_uid);
    __Pyx_INCREF(__pyx_v_actor_cls);
    __Pyx_GIVEREF(__pyx_v_actor_cls);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_actor_cls);
    __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_v_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_v_kwargs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_ref = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":155
 *         if wait:
 *             ref = self._comm.create_actor(address, uid, actor_cls, *args, **kwargs)
 *             ref.ctx = self             # <<<<<<<<<<<<<<
 *             return ref
 * 
 */
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_ref, __pyx_n_s_ctx, ((PyObject *)__pyx_cur_scope->__pyx_v_self)) < 0) __PYX_ERR(0, 155, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":156
 *             ref = self._comm.create_actor(address, uid, actor_cls, *args, **kwargs)
 *             ref.ctx = self
 *             return ref             # <<<<<<<<<<<<<<
 * 
 *         def callback(ret):
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_ref);
    __pyx_r = __pyx_v_ref;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":153
 *         uid = kwargs.pop('uid', None)
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             ref = self._comm.create_actor(address, uid, actor_cls, *args, **kwargs)
 *             ref.ctx = self
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":158
 *             return ref
 * 
 *         def callback(ret):             # <<<<<<<<<<<<<<
 *             ret.ctx = self
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_12ActorContext_12create_actor_1callback, 0, __pyx_n_s_create_actor_locals_callback, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__3)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_callback = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":161
 *             ret.ctx = self
 * 
 *         kwargs['wait'] = False             # <<<<<<<<<<<<<<
 *         kwargs['callback'] = callback
 *         return self._comm.create_actor(address, uid, actor_cls, *args, **kwargs)
 */
  if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_n_s_wait, Py_False) < 0)) __PYX_ERR(0, 161, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":162
 * 
 *         kwargs['wait'] = False
 *         kwargs['callback'] = callback             # <<<<<<<<<<<<<<
 *         return self._comm.create_actor(address, uid, actor_cls, *args, **kwargs)
 * 
 */
  if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_n_s_callback, __pyx_v_callback) < 0)) __PYX_ERR(0, 162, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":163
 *         kwargs['wait'] = False
 *         kwargs['callback'] = callback
 *         return self._comm.create_actor(address, uid, actor_cls, *args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     def destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->_comm, __pyx_n_s_create_actor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_address);
  __Pyx_GIVEREF(__pyx_v_address);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_address);
  __Pyx_INCREF(__pyx_v_uid);
  __Pyx_GIVEREF(__pyx_v_uid);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_uid);
  __Pyx_INCREF(__pyx_v_actor_cls);
  __Pyx_GIVEREF(__pyx_v_actor_cls);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_actor_cls);
  __pyx_t_1 = PyNumber_Add(__pyx_t_4, __pyx_v_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, __pyx_v_kwargs); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":143
 *         return self._comm.distributor
 * 
 *     def create_actor(self, actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef bint wait
 *         cdef object address
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorContext.create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_address);
  __Pyx_XDECREF(__pyx_v_uid);
  __Pyx_XDECREF(__pyx_v_ref);
  __Pyx_XDECREF(__pyx_v_callback);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":165
 *         return self._comm.create_actor(address, uid, actor_cls, *args, **kwargs)
 * 
 *     def destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._comm.destroy_actor(actor_ref, wait=wait, callback=callback)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_5destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_5destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("destroy_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "destroy_actor") < 0)) __PYX_ERR(0, 165, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    if (values[1]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("destroy_actor", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 165, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorContext.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 165, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_4destroy_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_4destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, 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;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("destroy_actor", 0);

  /* "mars/actors/pool/gevent_pool.pyx":166
 * 
 *     def destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 *         return self._comm.destroy_actor(actor_ref, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *     def has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_comm, __pyx_n_s_destroy_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_actor_ref));
  __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_wait, __pyx_t_4) < 0) __PYX_ERR(0, 166, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 166, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __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_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":165
 *         return self._comm.create_actor(address, uid, actor_cls, *args, **kwargs)
 * 
 *     def destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._comm.destroy_actor(actor_ref, wait=wait, callback=callback)
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.ActorContext.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":168
 *         return self._comm.destroy_actor(actor_ref, wait=wait, callback=callback)
 * 
 *     def has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._comm.has_actor(actor_ref, wait=wait, callback=callback)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_7has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_7has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("has_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "has_actor") < 0)) __PYX_ERR(0, 168, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    if (values[1]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 168, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("has_actor", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 168, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorContext.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 168, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_6has_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_6has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, 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;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("has_actor", 0);

  /* "mars/actors/pool/gevent_pool.pyx":169
 * 
 *     def has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 *         return self._comm.has_actor(actor_ref, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *     def actor_ref(self, *args, **kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_comm, __pyx_n_s_has_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_actor_ref));
  __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_wait, __pyx_t_4) < 0) __PYX_ERR(0, 169, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 169, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 169, __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_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":168
 *         return self._comm.destroy_actor(actor_ref, wait=wait, callback=callback)
 * 
 *     def has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._comm.has_actor(actor_ref, wait=wait, callback=callback)
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.ActorContext.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":171
 *         return self._comm.has_actor(actor_ref, wait=wait, callback=callback)
 * 
 *     def actor_ref(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef ActorRef ref
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_9actor_ref(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_9actor_ref(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("actor_ref (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "actor_ref", 1))) return NULL;
  if (unlikely(__pyx_kwds)) {
    __pyx_v_kwargs = PyDict_Copy(__pyx_kwds); if (unlikely(!__pyx_v_kwargs)) return NULL;
    __Pyx_GOTREF(__pyx_v_kwargs);
  } else {
    __pyx_v_kwargs = NULL;
  }
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_8actor_ref(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *)__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_4mars_6actors_4pool_11gevent_pool_12ActorContext_8actor_ref(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_ref = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("actor_ref", 0);

  /* "mars/actors/pool/gevent_pool.pyx":174
 *         cdef ActorRef ref
 * 
 *         ref = create_actor_ref(*args, **kwargs)             # <<<<<<<<<<<<<<
 *         ref.ctx = self
 *         return ref
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_actor_ref); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 174, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4mars_6actors_4core_ActorRef))))) __PYX_ERR(0, 174, __pyx_L1_error)
  __pyx_v_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":175
 * 
 *         ref = create_actor_ref(*args, **kwargs)
 *         ref.ctx = self             # <<<<<<<<<<<<<<
 *         return ref
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_ref), __pyx_n_s_ctx, ((PyObject *)__pyx_v_self)) < 0) __PYX_ERR(0, 175, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":176
 *         ref = create_actor_ref(*args, **kwargs)
 *         ref.ctx = self
 *         return ref             # <<<<<<<<<<<<<<
 * 
 *     def send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_ref));
  __pyx_r = ((PyObject *)__pyx_v_ref);
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":171
 *         return self._comm.has_actor(actor_ref, wait=wait, callback=callback)
 * 
 *     def actor_ref(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef ActorRef ref
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorContext.actor_ref", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ref);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":178
 *         return ref
 * 
 *     def send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._comm.send(actor_ref, message, wait=wait, callback=callback)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_11send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_11send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_message = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("send (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_message,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[4] = {0,0,0,0};
    values[3] = ((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);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("send", 0, 2, 4, 1); __PYX_ERR(0, 178, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "send") < 0)) __PYX_ERR(0, 178, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    __pyx_v_message = values[1];
    if (values[2]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 178, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("send", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 178, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorContext.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 178, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_10send(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_message, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_10send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait, 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;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("send", 0);

  /* "mars/actors/pool/gevent_pool.pyx":179
 * 
 *     def send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):
 *         return self._comm.send(actor_ref, message, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *     def tell(self, ActorRef actor_ref, object message, object delay=None,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_comm, __pyx_n_s_send); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_actor_ref));
  __Pyx_INCREF(__pyx_v_message);
  __Pyx_GIVEREF(__pyx_v_message);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_message);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_wait, __pyx_t_4) < 0) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 179, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __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_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":178
 *         return ref
 * 
 *     def send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._comm.send(actor_ref, message, wait=wait, callback=callback)
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.ActorContext.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":181
 *         return self._comm.send(actor_ref, message, wait=wait, callback=callback)
 * 
 *     def tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *              bint wait=True, object callback=None):
 *         return self._comm.tell(actor_ref, message, delay=delay,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_13tell(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_13tell(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_message = 0;
  PyObject *__pyx_v_delay = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tell (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_message,&__pyx_n_s_delay,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[2] = ((PyObject *)Py_None);

    /* "mars/actors/pool/gevent_pool.pyx":182
 * 
 *     def tell(self, ActorRef actor_ref, object message, object delay=None,
 *              bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._comm.tell(actor_ref, message, delay=delay,
 *                                wait=wait, callback=callback)
 */
    values[4] = ((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  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tell", 0, 2, 5, 1); __PYX_ERR(0, 181, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_delay);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tell") < 0)) __PYX_ERR(0, 181, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    __pyx_v_message = values[1];
    __pyx_v_delay = values[2];
    if (values[3]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 182, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("tell", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 181, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorContext.tell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 181, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_12tell(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_message, __pyx_v_delay, __pyx_v_wait, __pyx_v_callback);

  /* "mars/actors/pool/gevent_pool.pyx":181
 *         return self._comm.send(actor_ref, message, wait=wait, callback=callback)
 * 
 *     def tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *              bint wait=True, object callback=None):
 *         return self._comm.tell(actor_ref, message, delay=delay,
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_12tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, PyObject *__pyx_v_delay, int __pyx_v_wait, 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;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("tell", 0);

  /* "mars/actors/pool/gevent_pool.pyx":183
 *     def tell(self, ActorRef actor_ref, object message, object delay=None,
 *              bint wait=True, object callback=None):
 *         return self._comm.tell(actor_ref, message, delay=delay,             # <<<<<<<<<<<<<<
 *                                wait=wait, callback=callback)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_comm, __pyx_n_s_tell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 183, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_actor_ref));
  __Pyx_INCREF(__pyx_v_message);
  __Pyx_GIVEREF(__pyx_v_message);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_message);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 183, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_delay, __pyx_v_delay) < 0) __PYX_ERR(0, 183, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":184
 *              bint wait=True, object callback=None):
 *         return self._comm.tell(actor_ref, message, delay=delay,
 *                                wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_wait, __pyx_t_4) < 0) __PYX_ERR(0, 183, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 183, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":183
 *     def tell(self, ActorRef actor_ref, object message, object delay=None,
 *              bint wait=True, object callback=None):
 *         return self._comm.tell(actor_ref, message, delay=delay,             # <<<<<<<<<<<<<<
 *                                wait=wait, callback=callback)
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 183, __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_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":181
 *         return self._comm.send(actor_ref, message, wait=wait, callback=callback)
 * 
 *     def tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *              bint wait=True, object callback=None):
 *         return self._comm.tell(actor_ref, message, delay=delay,
 */

  /* 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("mars.actors.pool.gevent_pool.ActorContext.tell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":187
 * 
 *     @staticmethod
 *     def sleep(seconds):             # <<<<<<<<<<<<<<
 *         gevent.sleep(seconds)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_15sleep(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_12ActorContext_15sleep = {"sleep", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_15sleep, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_15sleep(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_seconds = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sleep (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_seconds,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) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_seconds)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sleep") < 0)) __PYX_ERR(0, 187, __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_seconds = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sleep", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 187, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorContext.sleep", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_14sleep(__pyx_v_seconds);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_14sleep(PyObject *__pyx_v_seconds) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("sleep", 0);

  /* "mars/actors/pool/gevent_pool.pyx":188
 *     @staticmethod
 *     def sleep(seconds):
 *         gevent.sleep(seconds)             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_sleep); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_seconds) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_seconds);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 188, __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;

  /* "mars/actors/pool/gevent_pool.pyx":187
 * 
 *     @staticmethod
 *     def sleep(seconds):             # <<<<<<<<<<<<<<
 *         gevent.sleep(seconds)
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.ActorContext.sleep", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":191
 * 
 *     @staticmethod
 *     def fileobject(fobj, mode='rb', bufsize=-1, close=True):             # <<<<<<<<<<<<<<
 *         return gevent.fileobject.FileObject(fobj, mode=mode, bufsize=bufsize, close=close)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_17fileobject(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_12ActorContext_17fileobject = {"fileobject", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_17fileobject, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_17fileobject(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_fobj = 0;
  PyObject *__pyx_v_mode = 0;
  PyObject *__pyx_v_bufsize = 0;
  PyObject *__pyx_v_close = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("fileobject (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_fobj,&__pyx_n_s_mode,&__pyx_n_s_bufsize,&__pyx_n_s_close,0};
    PyObject* values[4] = {0,0,0,0};
    values[1] = ((PyObject *)__pyx_n_s_rb);
    values[2] = ((PyObject *)__pyx_int_neg_1);
    values[3] = ((PyObject *)Py_True);
    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);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fobj)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bufsize);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_close);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fileobject") < 0)) __PYX_ERR(0, 191, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_fobj = values[0];
    __pyx_v_mode = values[1];
    __pyx_v_bufsize = values[2];
    __pyx_v_close = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("fileobject", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 191, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorContext.fileobject", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_16fileobject(__pyx_v_fobj, __pyx_v_mode, __pyx_v_bufsize, __pyx_v_close);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_16fileobject(PyObject *__pyx_v_fobj, PyObject *__pyx_v_mode, PyObject *__pyx_v_bufsize, PyObject *__pyx_v_close) {
  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;
  __Pyx_RefNannySetupContext("fileobject", 0);

  /* "mars/actors/pool/gevent_pool.pyx":192
 *     @staticmethod
 *     def fileobject(fobj, mode='rb', bufsize=-1, close=True):
 *         return gevent.fileobject.FileObject(fobj, mode=mode, bufsize=bufsize, close=close)             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_fileobject); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_FileObject); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_fobj);
  __Pyx_GIVEREF(__pyx_v_fobj);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_fobj);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 192, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mode, __pyx_v_mode) < 0) __PYX_ERR(0, 192, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_bufsize, __pyx_v_bufsize) < 0) __PYX_ERR(0, 192, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_close, __pyx_v_close) < 0) __PYX_ERR(0, 192, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 192, __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_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":191
 * 
 *     @staticmethod
 *     def fileobject(fobj, mode='rb', bufsize=-1, close=True):             # <<<<<<<<<<<<<<
 *         return gevent.fileobject.FileObject(fobj, mode=mode, bufsize=bufsize, close=close)
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.ActorContext.fileobject", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":195
 * 
 *     @staticmethod
 *     def popen(*args, **kwargs):             # <<<<<<<<<<<<<<
 *         return gevent.subprocess.Popen(*args, **kwargs)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_19popen(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_12ActorContext_19popen = {"popen", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_19popen, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_19popen(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("popen (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "popen", 1))) return NULL;
  if (unlikely(__pyx_kwds)) {
    __pyx_v_kwargs = PyDict_Copy(__pyx_kwds); if (unlikely(!__pyx_v_kwargs)) return NULL;
    __Pyx_GOTREF(__pyx_v_kwargs);
  } else {
    __pyx_v_kwargs = NULL;
  }
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_18popen(__pyx_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_4mars_6actors_4pool_11gevent_pool_12ActorContext_18popen(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("popen", 0);

  /* "mars/actors/pool/gevent_pool.pyx":196
 *     @staticmethod
 *     def popen(*args, **kwargs):
 *         return gevent.subprocess.Popen(*args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_subprocess); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 196, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Popen); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 196, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":195
 * 
 *     @staticmethod
 *     def popen(*args, **kwargs):             # <<<<<<<<<<<<<<
 *         return gevent.subprocess.Popen(*args, **kwargs)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorContext.popen", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":199
 * 
 *     @staticmethod
 *     def threadpool(num_threads):             # <<<<<<<<<<<<<<
 *         return ThreadPool(num_threads)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_21threadpool(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_12ActorContext_21threadpool = {"threadpool", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_21threadpool, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_21threadpool(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_num_threads = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("threadpool (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_num_threads,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) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_num_threads)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "threadpool") < 0)) __PYX_ERR(0, 199, __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_num_threads = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("threadpool", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 199, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorContext.threadpool", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_20threadpool(__pyx_v_num_threads);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_20threadpool(PyObject *__pyx_v_num_threads) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("threadpool", 0);

  /* "mars/actors/pool/gevent_pool.pyx":200
 *     @staticmethod
 *     def threadpool(num_threads):
 *         return ThreadPool(num_threads)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ThreadPool), __pyx_v_num_threads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":199
 * 
 *     @staticmethod
 *     def threadpool(num_threads):             # <<<<<<<<<<<<<<
 *         return ThreadPool(num_threads)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorContext.threadpool", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_23__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_23__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_22__reduce_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_22__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  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;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self._comm,)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->_comm);
  __Pyx_GIVEREF(__pyx_v_self->_comm);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->_comm);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self._comm,)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self._comm,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self._comm is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self._comm,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self._comm is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_ActorContext, (type(self), 0xb0b0700, None), state
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_self->_comm != Py_None);
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._comm is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ActorContext, (type(self), 0xb0b0700, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self._comm is not None
 *     if use_setstate:
 *         return __pyx_unpickle_ActorContext, (type(self), 0xb0b0700, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_ActorContext, (type(self), 0xb0b0700, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_ActorContext); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_185272064);
    __Pyx_GIVEREF(__pyx_int_185272064);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_185272064);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __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_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._comm is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ActorContext, (type(self), 0xb0b0700, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_ActorContext, (type(self), 0xb0b0700, None), state
 *     else:
 *         return __pyx_unpickle_ActorContext, (type(self), 0xb0b0700, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ActorContext__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_ActorContext); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_185272064);
    __Pyx_GIVEREF(__pyx_int_185272064);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_185272064);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorContext.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ActorContext, (type(self), 0xb0b0700, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ActorContext__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_25__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_25__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_24__setstate_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12ActorContext_24__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_ActorContext, (type(self), 0xb0b0700, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ActorContext__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorContext__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ActorContext, (type(self), 0xb0b0700, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ActorContext__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorContext.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":213
 *     cdef public int index
 * 
 *     def __init__(self, str address=None, index=0):             # <<<<<<<<<<<<<<
 *         self.actors = dict()
 *         self.comm_proxy = None
 */

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_address = 0;
  PyObject *__pyx_v_index = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_address,&__pyx_n_s_index,0};
    PyObject* values[2] = {0,0};
    values[0] = ((PyObject*)Py_None);
    values[1] = ((PyObject *)__pyx_int_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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_address);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_index);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 213, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_address = ((PyObject*)values[0]);
    __pyx_v_index = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 213, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_address), (&PyString_Type), 1, "address", 1))) __PYX_ERR(0, 213, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool___init__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self), __pyx_v_address, __pyx_v_index);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_address, PyObject *__pyx_v_index) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":214
 * 
 *     def __init__(self, str address=None, index=0):
 *         self.actors = dict()             # <<<<<<<<<<<<<<
 *         self.comm_proxy = None
 *         self.address = address
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 214, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->actors);
  __Pyx_DECREF(__pyx_v_self->actors);
  __pyx_v_self->actors = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":215
 *     def __init__(self, str address=None, index=0):
 *         self.actors = dict()
 *         self.comm_proxy = None             # <<<<<<<<<<<<<<
 *         self.address = address
 *         self.index = index
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->comm_proxy);
  __Pyx_DECREF(__pyx_v_self->comm_proxy);
  __pyx_v_self->comm_proxy = Py_None;

  /* "mars/actors/pool/gevent_pool.pyx":216
 *         self.actors = dict()
 *         self.comm_proxy = None
 *         self.address = address             # <<<<<<<<<<<<<<
 *         self.index = index
 * 
 */
  __Pyx_INCREF(__pyx_v_address);
  __Pyx_GIVEREF(__pyx_v_address);
  __Pyx_GOTREF(__pyx_v_self->address);
  __Pyx_DECREF(__pyx_v_self->address);
  __pyx_v_self->address = __pyx_v_address;

  /* "mars/actors/pool/gevent_pool.pyx":217
 *         self.comm_proxy = None
 *         self.address = address
 *         self.index = index             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_v_index); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 217, __pyx_L1_error)
  __pyx_v_self->index = __pyx_t_2;

  /* "mars/actors/pool/gevent_pool.pyx":213
 *     cdef public int index
 * 
 *     def __init__(self, str address=None, index=0):             # <<<<<<<<<<<<<<
 *         self.actors = dict()
 *         self.comm_proxy = None
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":220
 * 
 *     @property
 *     def comm(self):             # <<<<<<<<<<<<<<
 *         return self.comm_proxy()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_4comm_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_4comm_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_4comm___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_4comm___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":221
 *     @property
 *     def comm(self):
 *         return self.comm_proxy()             # <<<<<<<<<<<<<<
 * 
 *     cpdef set_comm(self, object comm):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->comm_proxy);
  __pyx_t_2 = __pyx_v_self->comm_proxy; __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":220
 * 
 *     @property
 *     def comm(self):             # <<<<<<<<<<<<<<
 *         return self.comm_proxy()
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.comm.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":223
 *         return self.comm_proxy()
 * 
 *     cpdef set_comm(self, object comm):             # <<<<<<<<<<<<<<
 *         self.comm_proxy = weakref.ref(comm)
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_3set_comm(PyObject *__pyx_v_self, PyObject *__pyx_v_comm); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_set_comm(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_comm, int __pyx_skip_dispatch) {
  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;
  __Pyx_RefNannySetupContext("set_comm", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_comm); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 223, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_3set_comm)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_comm) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_comm);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 223, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":224
 * 
 *     cpdef set_comm(self, object comm):
 *         self.comm_proxy = weakref.ref(comm)             # <<<<<<<<<<<<<<
 * 
 *     cpdef ActorExecutionContext get_actor_execution_ctx(self, object actor_uid):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_weakref); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 224, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ref); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 224, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_comm) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_comm);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->comm_proxy);
  __Pyx_DECREF(__pyx_v_self->comm_proxy);
  __pyx_v_self->comm_proxy = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":223
 *         return self.comm_proxy()
 * 
 *     cpdef set_comm(self, object comm):             # <<<<<<<<<<<<<<
 *         self.comm_proxy = weakref.ref(comm)
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.LocalActorPool.set_comm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_3set_comm(PyObject *__pyx_v_self, PyObject *__pyx_v_comm); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_3set_comm(PyObject *__pyx_v_self, PyObject *__pyx_v_comm) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_comm (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_2set_comm(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self), ((PyObject *)__pyx_v_comm));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_2set_comm(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_comm) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("set_comm", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_set_comm(__pyx_v_self, __pyx_v_comm, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.set_comm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":226
 *         self.comm_proxy = weakref.ref(comm)
 * 
 *     cpdef ActorExecutionContext get_actor_execution_ctx(self, object actor_uid):             # <<<<<<<<<<<<<<
 *         try:
 *             return self.actors[actor_uid][1]
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_5get_actor_execution_ctx(PyObject *__pyx_v_self, PyObject *__pyx_v_actor_uid); /*proto*/
static struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_f_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_get_actor_execution_ctx(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_actor_uid, int __pyx_skip_dispatch) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__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;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  __Pyx_RefNannySetupContext("get_actor_execution_ctx", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_actor_execution_ctx); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_5get_actor_execution_ctx)) {
        __Pyx_XDECREF(((PyObject *)__pyx_r));
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_actor_uid) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_actor_uid);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 226, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext))))) __PYX_ERR(0, 226, __pyx_L1_error)
        __pyx_r = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":227
 * 
 *     cpdef ActorExecutionContext get_actor_execution_ctx(self, object actor_uid):
 *         try:             # <<<<<<<<<<<<<<
 *             return self.actors[actor_uid][1]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_7);
    /*try:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":228
 *     cpdef ActorExecutionContext get_actor_execution_ctx(self, object actor_uid):
 *         try:
 *             return self.actors[actor_uid][1]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             raise ActorNotExist('Actor {0} does not exist'.format(actor_uid))
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      if (unlikely(__pyx_v_self->actors == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 228, __pyx_L3_error)
      }
      __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_self->actors, __pyx_v_actor_uid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 228, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 228, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext))))) __PYX_ERR(0, 228, __pyx_L3_error)
      __pyx_r = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_t_2);
      __pyx_t_2 = 0;
      goto __pyx_L7_try_return;

      /* "mars/actors/pool/gevent_pool.pyx":227
 * 
 *     cpdef ActorExecutionContext get_actor_execution_ctx(self, object actor_uid):
 *         try:             # <<<<<<<<<<<<<<
 *             return self.actors[actor_uid][1]
 *         except KeyError:
 */
    }
    __pyx_L3_error:;
    __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_2); __pyx_t_2 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":229
 *         try:
 *             return self.actors[actor_uid][1]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             raise ActorNotExist('Actor {0} does not exist'.format(actor_uid))
 * 
 */
    __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_8) {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.get_actor_execution_ctx", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(0, 229, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_3);

      /* "mars/actors/pool/gevent_pool.pyx":230
 *             return self.actors[actor_uid][1]
 *         except KeyError:
 *             raise ActorNotExist('Actor {0} does not exist'.format(actor_uid))             # <<<<<<<<<<<<<<
 * 
 *     def create_actor(self, object actor_cls, object uid, *args, **kw):
 */
      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_ActorNotExist); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 230, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Actor_0_does_not_exist, __pyx_n_s_format); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 230, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      __pyx_t_10 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_12, __pyx_v_actor_uid) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_actor_uid);
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 230, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      __pyx_t_4 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_11, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_10);
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 230, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 230, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":227
 * 
 *     cpdef ActorExecutionContext get_actor_execution_ctx(self, object actor_uid):
 *         try:             # <<<<<<<<<<<<<<
 *             return self.actors[actor_uid][1]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
    goto __pyx_L0;
  }

  /* "mars/actors/pool/gevent_pool.pyx":226
 *         self.comm_proxy = weakref.ref(comm)
 * 
 *     cpdef ActorExecutionContext get_actor_execution_ctx(self, object actor_uid):             # <<<<<<<<<<<<<<
 *         try:
 *             return self.actors[actor_uid][1]
 */

  /* 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_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.get_actor_execution_ctx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_5get_actor_execution_ctx(PyObject *__pyx_v_self, PyObject *__pyx_v_actor_uid); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_5get_actor_execution_ctx(PyObject *__pyx_v_self, PyObject *__pyx_v_actor_uid) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_actor_execution_ctx (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_4get_actor_execution_ctx(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self), ((PyObject *)__pyx_v_actor_uid));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_4get_actor_execution_ctx(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_actor_uid) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("get_actor_execution_ctx", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((PyObject *)__pyx_f_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_get_actor_execution_ctx(__pyx_v_self, __pyx_v_actor_uid, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.get_actor_execution_ctx", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":232
 *             raise ActorNotExist('Actor {0} does not exist'.format(actor_uid))
 * 
 *     def create_actor(self, object actor_cls, object uid, *args, **kw):             # <<<<<<<<<<<<<<
 *         cdef Actor actor
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7create_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7create_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_actor_cls = 0;
  PyObject *__pyx_v_uid = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kw = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_actor (wrapper)", 0);
  __pyx_v_kw = PyDict_New(); if (unlikely(!__pyx_v_kw)) return NULL;
  __Pyx_GOTREF(__pyx_v_kw);
  if (PyTuple_GET_SIZE(__pyx_args) > 2) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_args)) {
      __Pyx_DECREF(__pyx_v_kw); __pyx_v_kw = 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_actor_cls,&__pyx_n_s_uid,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) {
        default:
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_cls)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_uid)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_actor", 0, 2, 2, 1); __PYX_ERR(0, 232, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (pos_args < 2) ? pos_args : 2;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kw, values, used_pos_args, "create_actor") < 0)) __PYX_ERR(0, 232, __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_actor_cls = values[0];
    __pyx_v_uid = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_actor", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 232, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_DECREF(__pyx_v_kw); __pyx_v_kw = 0;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6create_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self), __pyx_v_actor_cls, __pyx_v_uid, __pyx_v_args, __pyx_v_kw);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_uid, PyObject *__pyx_v_args, PyObject *__pyx_v_kw) {
  struct __pyx_obj_4mars_6actors_4core_Actor *__pyx_v_actor = 0;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_actor_execution_ctx = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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;
  __Pyx_RefNannySetupContext("create_actor", 0);

  /* "mars/actors/pool/gevent_pool.pyx":235
 *         cdef Actor actor
 * 
 *         actor = actor_cls(*args, **kw)             # <<<<<<<<<<<<<<
 *         actor.address = self.address
 *         actor.uid = uid
 */
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_actor_cls, __pyx_v_args, __pyx_v_kw); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 235, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4mars_6actors_4core_Actor))))) __PYX_ERR(0, 235, __pyx_L1_error)
  __pyx_v_actor = ((struct __pyx_obj_4mars_6actors_4core_Actor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":236
 * 
 *         actor = actor_cls(*args, **kw)
 *         actor.address = self.address             # <<<<<<<<<<<<<<
 *         actor.uid = uid
 *         actor_execution_ctx = ActorExecutionContext(actor, self.comm)
 */
  __pyx_t_1 = __pyx_v_self->address;
  __Pyx_INCREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_actor), __pyx_n_s_address, __pyx_t_1) < 0) __PYX_ERR(0, 236, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":237
 *         actor = actor_cls(*args, **kw)
 *         actor.address = self.address
 *         actor.uid = uid             # <<<<<<<<<<<<<<
 *         actor_execution_ctx = ActorExecutionContext(actor, self.comm)
 *         actor.ctx = ActorContext(actor_execution_ctx.comm)
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_actor), __pyx_n_s_uid, __pyx_v_uid) < 0) __PYX_ERR(0, 237, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":238
 *         actor.address = self.address
 *         actor.uid = uid
 *         actor_execution_ctx = ActorExecutionContext(actor, self.comm)             # <<<<<<<<<<<<<<
 *         actor.ctx = ActorContext(actor_execution_ctx.comm)
 *         if uid in self.actors:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_comm); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_actor));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_actor));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_actor));
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_actor_execution_ctx = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":239
 *         actor.uid = uid
 *         actor_execution_ctx = ActorExecutionContext(actor, self.comm)
 *         actor.ctx = ActorContext(actor_execution_ctx.comm)             # <<<<<<<<<<<<<<
 *         if uid in self.actors:
 *             raise ActorAlreadyExist('Actor {0} already exist, cannot create'.format(actor.uid))
 */
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext), __pyx_v_actor_execution_ctx->comm); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_actor), __pyx_n_s_ctx, __pyx_t_1) < 0) __PYX_ERR(0, 239, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":240
 *         actor_execution_ctx = ActorExecutionContext(actor, self.comm)
 *         actor.ctx = ActorContext(actor_execution_ctx.comm)
 *         if uid in self.actors:             # <<<<<<<<<<<<<<
 *             raise ActorAlreadyExist('Actor {0} already exist, cannot create'.format(actor.uid))
 *         self.actors[uid] = (actor, actor_execution_ctx)
 */
  if (unlikely(__pyx_v_self->actors == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 240, __pyx_L1_error)
  }
  __pyx_t_3 = (__Pyx_PyDict_ContainsTF(__pyx_v_uid, __pyx_v_self->actors, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 240, __pyx_L1_error)
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (unlikely(__pyx_t_4)) {

    /* "mars/actors/pool/gevent_pool.pyx":241
 *         actor.ctx = ActorContext(actor_execution_ctx.comm)
 *         if uid in self.actors:
 *             raise ActorAlreadyExist('Actor {0} already exist, cannot create'.format(actor.uid))             # <<<<<<<<<<<<<<
 *         self.actors[uid] = (actor, actor_execution_ctx)
 *         actor.post_create()
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ActorAlreadyExist); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 241, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Actor_0_already_exist_cannot_cre, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 241, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_actor), __pyx_n_s_uid); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 241, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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_5 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_8, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 241, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 241, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __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_ERR(0, 241, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":240
 *         actor_execution_ctx = ActorExecutionContext(actor, self.comm)
 *         actor.ctx = ActorContext(actor_execution_ctx.comm)
 *         if uid in self.actors:             # <<<<<<<<<<<<<<
 *             raise ActorAlreadyExist('Actor {0} already exist, cannot create'.format(actor.uid))
 *         self.actors[uid] = (actor, actor_execution_ctx)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":242
 *         if uid in self.actors:
 *             raise ActorAlreadyExist('Actor {0} already exist, cannot create'.format(actor.uid))
 *         self.actors[uid] = (actor, actor_execution_ctx)             # <<<<<<<<<<<<<<
 *         actor.post_create()
 *         return ActorRef(self.address, uid)
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_actor));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_actor));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_actor));
  __Pyx_INCREF(((PyObject *)__pyx_v_actor_execution_ctx));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_execution_ctx));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_actor_execution_ctx));
  if (unlikely(__pyx_v_self->actors == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 242, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_self->actors, __pyx_v_uid, __pyx_t_1) < 0)) __PYX_ERR(0, 242, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":243
 *             raise ActorAlreadyExist('Actor {0} already exist, cannot create'.format(actor.uid))
 *         self.actors[uid] = (actor, actor_execution_ctx)
 *         actor.post_create()             # <<<<<<<<<<<<<<
 *         return ActorRef(self.address, uid)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4mars_6actors_4core_Actor *)__pyx_v_actor->__pyx_vtab)->post_create(__pyx_v_actor, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":244
 *         self.actors[uid] = (actor, actor_execution_ctx)
 *         actor.post_create()
 *         return ActorRef(self.address, uid)             # <<<<<<<<<<<<<<
 * 
 *     cpdef bint has_actor(self, object actor_uid):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->address);
  __Pyx_GIVEREF(__pyx_v_self->address);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->address);
  __Pyx_INCREF(__pyx_v_uid);
  __Pyx_GIVEREF(__pyx_v_uid);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_uid);
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4mars_6actors_4core_ActorRef), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":232
 *             raise ActorNotExist('Actor {0} does not exist'.format(actor_uid))
 * 
 *     def create_actor(self, object actor_cls, object uid, *args, **kw):             # <<<<<<<<<<<<<<
 *         cdef Actor actor
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __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_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_actor);
  __Pyx_XDECREF((PyObject *)__pyx_v_actor_execution_ctx);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":246
 *         return ActorRef(self.address, uid)
 * 
 *     cpdef bint has_actor(self, object actor_uid):             # <<<<<<<<<<<<<<
 *         if actor_uid not in self.actors:
 *             return False
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_9has_actor(PyObject *__pyx_v_self, PyObject *__pyx_v_actor_uid); /*proto*/
static int __pyx_f_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_actor_uid, int __pyx_skip_dispatch) {
  int __pyx_r;
  __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;
  __Pyx_RefNannySetupContext("has_actor", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_has_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_9has_actor)) {
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_actor_uid) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_actor_uid);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 246, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 246, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_r = __pyx_t_5;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":247
 * 
 *     cpdef bint has_actor(self, object actor_uid):
 *         if actor_uid not in self.actors:             # <<<<<<<<<<<<<<
 *             return False
 *         return True
 */
  if (unlikely(__pyx_v_self->actors == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 247, __pyx_L1_error)
  }
  __pyx_t_5 = (__Pyx_PyDict_ContainsTF(__pyx_v_actor_uid, __pyx_v_self->actors, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 247, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (__pyx_t_6) {

    /* "mars/actors/pool/gevent_pool.pyx":248
 *     cpdef bint has_actor(self, object actor_uid):
 *         if actor_uid not in self.actors:
 *             return False             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":247
 * 
 *     cpdef bint has_actor(self, object actor_uid):
 *         if actor_uid not in self.actors:             # <<<<<<<<<<<<<<
 *             return False
 *         return True
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":249
 *         if actor_uid not in self.actors:
 *             return False
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cpdef destroy_actor(self, object actor_uid):
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":246
 *         return ActorRef(self.address, uid)
 * 
 *     cpdef bint has_actor(self, object actor_uid):             # <<<<<<<<<<<<<<
 *         if actor_uid not in self.actors:
 *             return False
 */

  /* 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_WriteUnraisable("mars.actors.pool.gevent_pool.LocalActorPool.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_9has_actor(PyObject *__pyx_v_self, PyObject *__pyx_v_actor_uid); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_9has_actor(PyObject *__pyx_v_self, PyObject *__pyx_v_actor_uid) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("has_actor (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_8has_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self), ((PyObject *)__pyx_v_actor_uid));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_8has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_actor_uid) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("has_actor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_has_actor(__pyx_v_self, __pyx_v_actor_uid, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":251
 *         return True
 * 
 *     cpdef destroy_actor(self, object actor_uid):             # <<<<<<<<<<<<<<
 *         cdef Actor actor
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_11destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_v_actor_uid); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_actor_uid, int __pyx_skip_dispatch) {
  struct __pyx_obj_4mars_6actors_4core_Actor *__pyx_v_actor = 0;
  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)(PyObject *);
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  __Pyx_RefNannySetupContext("destroy_actor", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_destroy_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_11destroy_actor)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_actor_uid) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_actor_uid);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 251, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":254
 *         cdef Actor actor
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             actor, _ = self.actors[actor_uid]
 *         except KeyError:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_7);
    /*try:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":255
 * 
 *         try:
 *             actor, _ = self.actors[actor_uid]             # <<<<<<<<<<<<<<
 *         except KeyError:
 *             raise ActorNotExist('Actor {0} does not exist'.format(actor_uid))
 */
      if (unlikely(__pyx_v_self->actors == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 255, __pyx_L3_error)
      }
      __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_self->actors, __pyx_v_actor_uid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 255, __pyx_L3_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        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_ERR(0, 255, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 255, __pyx_L3_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_ERR(0, 255, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_8 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_8(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_3 = __pyx_t_8(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_4), 2) < 0) __PYX_ERR(0, 255, __pyx_L3_error)
        __pyx_t_8 = NULL;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L10_unpacking_done;
        __pyx_L9_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_8 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 255, __pyx_L3_error)
        __pyx_L10_unpacking_done:;
      }
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4mars_6actors_4core_Actor))))) __PYX_ERR(0, 255, __pyx_L3_error)
      __pyx_v_actor = ((struct __pyx_obj_4mars_6actors_4core_Actor *)__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_v__ = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":254
 *         cdef Actor actor
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             actor, _ = self.actors[actor_uid]
 *         except KeyError:
 */
    }
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 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;

    /* "mars/actors/pool/gevent_pool.pyx":256
 *         try:
 *             actor, _ = self.actors[actor_uid]
 *         except KeyError:             # <<<<<<<<<<<<<<
 *             raise ActorNotExist('Actor {0} does not exist'.format(actor_uid))
 *         actor.pre_destroy()
 */
    __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_9) {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 256, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_2);

      /* "mars/actors/pool/gevent_pool.pyx":257
 *             actor, _ = self.actors[actor_uid]
 *         except KeyError:
 *             raise ActorNotExist('Actor {0} does not exist'.format(actor_uid))             # <<<<<<<<<<<<<<
 *         actor.pre_destroy()
 *         del self.actors[actor_uid]
 */
      __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_ActorNotExist); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 257, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Actor_0_does_not_exist, __pyx_n_s_format); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 257, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = NULL;
      if (CYTHON_UNPACK_METHODS && 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);
        }
      }
      __pyx_t_11 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_13, __pyx_v_actor_uid) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_actor_uid);
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 257, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = NULL;
      if (CYTHON_UNPACK_METHODS && 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);
        }
      }
      __pyx_t_4 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_12, __pyx_t_11) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_11);
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 257, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 257, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":254
 *         cdef Actor actor
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             actor, _ = self.actors[actor_uid]
 *         except KeyError:
 */
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
    goto __pyx_L1_error;
    __pyx_L8_try_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":258
 *         except KeyError:
 *             raise ActorNotExist('Actor {0} does not exist'.format(actor_uid))
 *         actor.pre_destroy()             # <<<<<<<<<<<<<<
 *         del self.actors[actor_uid]
 *         return actor_uid
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_4mars_6actors_4core_Actor *)__pyx_v_actor->__pyx_vtab)->pre_destroy(__pyx_v_actor, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":259
 *             raise ActorNotExist('Actor {0} does not exist'.format(actor_uid))
 *         actor.pre_destroy()
 *         del self.actors[actor_uid]             # <<<<<<<<<<<<<<
 *         return actor_uid
 * 
 */
  if (unlikely(__pyx_v_self->actors == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 259, __pyx_L1_error)
  }
  if (unlikely(PyDict_DelItem(__pyx_v_self->actors, __pyx_v_actor_uid) < 0)) __PYX_ERR(0, 259, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":260
 *         actor.pre_destroy()
 *         del self.actors[actor_uid]
 *         return actor_uid             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_actor_uid);
  __pyx_r = __pyx_v_actor_uid;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":251
 *         return True
 * 
 *     cpdef destroy_actor(self, object actor_uid):             # <<<<<<<<<<<<<<
 *         cdef Actor actor
 * 
 */

  /* 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_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_actor);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_11destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_v_actor_uid); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_11destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_v_actor_uid) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("destroy_actor (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10destroy_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self), ((PyObject *)__pyx_v_actor_uid));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_actor_uid) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("destroy_actor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_destroy_actor(__pyx_v_self, __pyx_v_actor_uid, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":208
 *     """
 * 
 *     cdef public dict actors             # <<<<<<<<<<<<<<
 *     cdef public object comm_proxy
 *     cdef public str address
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->actors);
  __pyx_r = __pyx_v_self->actors;
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyDict_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 208, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->actors);
  __Pyx_DECREF(__pyx_v_self->actors);
  __pyx_v_self->actors = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.actors.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors_4__del__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->actors);
  __Pyx_DECREF(__pyx_v_self->actors);
  __pyx_v_self->actors = ((PyObject*)Py_None);

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

/* "mars/actors/pool/gevent_pool.pyx":209
 * 
 *     cdef public dict actors
 *     cdef public object comm_proxy             # <<<<<<<<<<<<<<
 *     cdef public str address
 *     cdef public int index
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->comm_proxy);
  __pyx_r = __pyx_v_self->comm_proxy;
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->comm_proxy);
  __Pyx_DECREF(__pyx_v_self->comm_proxy);
  __pyx_v_self->comm_proxy = __pyx_v_value;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy_4__del__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->comm_proxy);
  __Pyx_DECREF(__pyx_v_self->comm_proxy);
  __pyx_v_self->comm_proxy = Py_None;

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

/* "mars/actors/pool/gevent_pool.pyx":210
 *     cdef public dict actors
 *     cdef public object comm_proxy
 *     cdef public str address             # <<<<<<<<<<<<<<
 *     cdef public int index
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->address);
  __pyx_r = __pyx_v_self->address;
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(PyString_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 210, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->address);
  __Pyx_DECREF(__pyx_v_self->address);
  __pyx_v_self->address = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.address.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address_4__del__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->address);
  __Pyx_DECREF(__pyx_v_self->address);
  __pyx_v_self->address = ((PyObject*)Py_None);

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

/* "mars/actors/pool/gevent_pool.pyx":211
 *     cdef public object comm_proxy
 *     cdef public str address
 *     cdef public int index             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, str address=None, index=0):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_5index_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_5index_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_5index___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_5index___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.index.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_5index_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_5index_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_5index_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_5index_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 211, __pyx_L1_error)
  __pyx_v_self->index = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.index.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_12__reduce_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_12__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.actors, self.address, self.comm_proxy, self.index)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->index); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->actors);
  __Pyx_GIVEREF(__pyx_v_self->actors);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->actors);
  __Pyx_INCREF(__pyx_v_self->address);
  __Pyx_GIVEREF(__pyx_v_self->address);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->address);
  __Pyx_INCREF(__pyx_v_self->comm_proxy);
  __Pyx_GIVEREF(__pyx_v_self->comm_proxy);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_self->comm_proxy);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.actors, self.address, self.comm_proxy, self.index)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_2 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v__dict = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "(tree fragment)":7
 *     state = (self.actors, self.address, self.comm_proxy, self.index)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_3 = (__pyx_v__dict != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__dict);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.actors is not None or self.address is not None or self.comm_proxy is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.actors, self.address, self.comm_proxy, self.index)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.actors is not None or self.address is not None or self.comm_proxy is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_LocalActorPool, (type(self), 0x406a582, None), state
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_self->actors != ((PyObject*)Py_None));
    __pyx_t_5 = (__pyx_t_3 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->address != ((PyObject*)Py_None));
    __pyx_t_3 = (__pyx_t_5 != 0);
    if (!__pyx_t_3) {
    } else {
      __pyx_t_4 = __pyx_t_3;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_3 = (__pyx_v_self->comm_proxy != Py_None);
    __pyx_t_5 = (__pyx_t_3 != 0);
    __pyx_t_4 = __pyx_t_5;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_4;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.actors is not None or self.address is not None or self.comm_proxy is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_LocalActorPool, (type(self), 0x406a582, None), state
 *     else:
 */
  __pyx_t_4 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":13
 *         use_setstate = self.actors is not None or self.address is not None or self.comm_proxy is not None
 *     if use_setstate:
 *         return __pyx_unpickle_LocalActorPool, (type(self), 0x406a582, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_LocalActorPool, (type(self), 0x406a582, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle_LocalActorPool); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_67544450);
    __Pyx_GIVEREF(__pyx_int_67544450);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_67544450);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.actors is not None or self.address is not None or self.comm_proxy is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_LocalActorPool, (type(self), 0x406a582, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_LocalActorPool, (type(self), 0x406a582, None), state
 *     else:
 *         return __pyx_unpickle_LocalActorPool, (type(self), 0x406a582, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_LocalActorPool__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_LocalActorPool); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_67544450);
    __Pyx_GIVEREF(__pyx_int_67544450);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_67544450);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_6 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_LocalActorPool, (type(self), 0x406a582, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_LocalActorPool__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_14__setstate_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_14__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_LocalActorPool, (type(self), 0x406a582, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_LocalActorPool__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_LocalActorPool__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_LocalActorPool, (type(self), 0x406a582, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_LocalActorPool__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.LocalActorPool.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":266
 *     cdef dict async_results
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.async_results = dict()
 * 
 */

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler___init__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_v_self));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":267
 * 
 *     def __init__(self):
 *         self.async_results = dict()             # <<<<<<<<<<<<<<
 * 
 *     cpdef object submit(self, bytes unique_id):
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->async_results);
  __Pyx_DECREF(__pyx_v_self->async_results);
  __pyx_v_self->async_results = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":266
 *     cdef dict async_results
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         self.async_results = dict()
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.AsyncHandler.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":269
 *         self.async_results = dict()
 * 
 *     cpdef object submit(self, bytes unique_id):             # <<<<<<<<<<<<<<
 *         cdef object ar
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_3submit(PyObject *__pyx_v_self, PyObject *__pyx_v_unique_id); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_submit(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_ar = 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;
  __Pyx_RefNannySetupContext("submit", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_submit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_3submit)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_unique_id) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_unique_id);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":272
 *         cdef object ar
 * 
 *         ar = self.async_results[unique_id] = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 * 
 *         # wait for result
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_event); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 272, __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_AsyncResult); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_ar = __pyx_t_1;
  if (unlikely(__pyx_v_self->async_results == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 272, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_self->async_results, __pyx_v_unique_id, __pyx_t_1) < 0)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":275
 * 
 *         # wait for result
 *         ar.wait()             # <<<<<<<<<<<<<<
 *         del self.async_results[unique_id]
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ar, __pyx_n_s_wait); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __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;

  /* "mars/actors/pool/gevent_pool.pyx":276
 *         # wait for result
 *         ar.wait()
 *         del self.async_results[unique_id]             # <<<<<<<<<<<<<<
 * 
 *         return ar.result()
 */
  if (unlikely(__pyx_v_self->async_results == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 276, __pyx_L1_error)
  }
  if (unlikely(PyDict_DelItem(__pyx_v_self->async_results, __pyx_v_unique_id) < 0)) __PYX_ERR(0, 276, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":278
 *         del self.async_results[unique_id]
 * 
 *         return ar.result()             # <<<<<<<<<<<<<<
 * 
 *     cpdef object future(self, bytes unique_id, object future, object callback=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ar, __pyx_n_s_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":269
 *         self.async_results = dict()
 * 
 *     cpdef object submit(self, bytes unique_id):             # <<<<<<<<<<<<<<
 *         cdef object ar
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.AsyncHandler.submit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ar);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_3submit(PyObject *__pyx_v_self, PyObject *__pyx_v_unique_id); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_3submit(PyObject *__pyx_v_self, PyObject *__pyx_v_unique_id) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("submit (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_unique_id), (&PyBytes_Type), 1, "unique_id", 1))) __PYX_ERR(0, 269, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_2submit(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_v_self), ((PyObject*)__pyx_v_unique_id));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_2submit(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("submit", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_submit(__pyx_v_self, __pyx_v_unique_id, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.AsyncHandler.submit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":280
 *         return ar.result()
 * 
 *     cpdef object future(self, bytes unique_id, object future, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef object ar
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_5future(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id, PyObject *__pyx_v_future, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future *__pyx_optional_args) {
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  PyObject *__pyx_v_ar = 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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("future", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_callback = __pyx_optional_args->callback;
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_future); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_5future)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && 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);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_unique_id, __pyx_v_future, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 280, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_unique_id, __pyx_v_future, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 280, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 280, __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_unique_id);
          __Pyx_GIVEREF(__pyx_v_unique_id);
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_unique_id);
          __Pyx_INCREF(__pyx_v_future);
          __Pyx_GIVEREF(__pyx_v_future);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_future);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_callback);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 280, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":283
 *         cdef object ar
 * 
 *         ar = self.async_results[unique_id] = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 * 
 *         # wait for result
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_event); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __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_AsyncResult); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_ar = __pyx_t_1;
  if (unlikely(__pyx_v_self->async_results == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 283, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_self->async_results, __pyx_v_unique_id, __pyx_t_1) < 0)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":286
 * 
 *         # wait for result
 *         ar.wait()             # <<<<<<<<<<<<<<
 *         del self.async_results[unique_id]
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ar, __pyx_n_s_wait); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __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;

  /* "mars/actors/pool/gevent_pool.pyx":287
 *         # wait for result
 *         ar.wait()
 *         del self.async_results[unique_id]             # <<<<<<<<<<<<<<
 * 
 *         if callback and ar.successful():
 */
  if (unlikely(__pyx_v_self->async_results == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 287, __pyx_L1_error)
  }
  if (unlikely(PyDict_DelItem(__pyx_v_self->async_results, __pyx_v_unique_id) < 0)) __PYX_ERR(0, 287, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":289
 *         del self.async_results[unique_id]
 * 
 *         if callback and ar.successful():             # <<<<<<<<<<<<<<
 *             callback(ar.result())
 * 
 */
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 289, __pyx_L1_error)
  if (__pyx_t_8) {
  } else {
    __pyx_t_7 = __pyx_t_8;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ar, __pyx_n_s_successful); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 289, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 289, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 289, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = __pyx_t_8;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_7) {

    /* "mars/actors/pool/gevent_pool.pyx":290
 * 
 *         if callback and ar.successful():
 *             callback(ar.result())             # <<<<<<<<<<<<<<
 * 
 *         future(ar)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_ar, __pyx_n_s_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_INCREF(__pyx_v_callback);
    __pyx_t_3 = __pyx_v_callback; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_6, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 290, __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;

    /* "mars/actors/pool/gevent_pool.pyx":289
 *         del self.async_results[unique_id]
 * 
 *         if callback and ar.successful():             # <<<<<<<<<<<<<<
 *             callback(ar.result())
 * 
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":292
 *             callback(ar.result())
 * 
 *         future(ar)             # <<<<<<<<<<<<<<
 * 
 *     cpdef object wait(self, bytes unique_id):
 */
  __Pyx_INCREF(__pyx_v_future);
  __pyx_t_3 = __pyx_v_future; __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_ar) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_ar);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 292, __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;

  /* "mars/actors/pool/gevent_pool.pyx":280
 *         return ar.result()
 * 
 *     cpdef object future(self, bytes unique_id, object future, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef object ar
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.AsyncHandler.future", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ar);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_5future(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_5future(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_unique_id = 0;
  PyObject *__pyx_v_future = 0;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("future (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_unique_id,&__pyx_n_s_future,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_unique_id)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_future)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("future", 0, 2, 3, 1); __PYX_ERR(0, 280, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "future") < 0)) __PYX_ERR(0, 280, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_unique_id = ((PyObject*)values[0]);
    __pyx_v_future = values[1];
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("future", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 280, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.AsyncHandler.future", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_unique_id), (&PyBytes_Type), 1, "unique_id", 1))) __PYX_ERR(0, 280, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_4future(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_v_self), __pyx_v_unique_id, __pyx_v_future, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_4future(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id, PyObject *__pyx_v_future, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future __pyx_t_2;
  __Pyx_RefNannySetupContext("future", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_AsyncHandler->future(__pyx_v_self, __pyx_v_unique_id, __pyx_v_future, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.AsyncHandler.future", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":294
 *         future(ar)
 * 
 *     cpdef object wait(self, bytes unique_id):             # <<<<<<<<<<<<<<
 *         cdef object ar
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_7wait(PyObject *__pyx_v_self, PyObject *__pyx_v_unique_id); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_wait(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_ar = 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;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("wait", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_wait); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_7wait)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_unique_id) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_unique_id);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 294, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":297
 *         cdef object ar
 * 
 *         ar = self.async_results[unique_id] = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 * 
 *         # wait for result
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_event); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 297, __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_AsyncResult); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 297, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_ar = __pyx_t_1;
  if (unlikely(__pyx_v_self->async_results == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 297, __pyx_L1_error)
  }
  if (unlikely(PyDict_SetItem(__pyx_v_self->async_results, __pyx_v_unique_id, __pyx_t_1) < 0)) __PYX_ERR(0, 297, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":300
 * 
 *         # wait for result
 *         ar.wait()             # <<<<<<<<<<<<<<
 *         del self.async_results[unique_id]
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ar, __pyx_n_s_wait); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __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;

  /* "mars/actors/pool/gevent_pool.pyx":301
 *         # wait for result
 *         ar.wait()
 *         del self.async_results[unique_id]             # <<<<<<<<<<<<<<
 * 
 *         if ar.successful():
 */
  if (unlikely(__pyx_v_self->async_results == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 301, __pyx_L1_error)
  }
  if (unlikely(PyDict_DelItem(__pyx_v_self->async_results, __pyx_v_unique_id) < 0)) __PYX_ERR(0, 301, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":303
 *         del self.async_results[unique_id]
 * 
 *         if ar.successful():             # <<<<<<<<<<<<<<
 *             return ar.result()
 *         else:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ar, __pyx_n_s_successful); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 303, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "mars/actors/pool/gevent_pool.pyx":304
 * 
 *         if ar.successful():
 *             return ar.result()             # <<<<<<<<<<<<<<
 *         else:
 *             return ar.exception()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ar, __pyx_n_s_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 304, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":303
 *         del self.async_results[unique_id]
 * 
 *         if ar.successful():             # <<<<<<<<<<<<<<
 *             return ar.result()
 *         else:
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":306
 *             return ar.result()
 *         else:
 *             return ar.exception()             # <<<<<<<<<<<<<<
 * 
 *     cpdef void got(self, bytes unique_id, object result):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ar, __pyx_n_s_exception); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 306, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "mars/actors/pool/gevent_pool.pyx":294
 *         future(ar)
 * 
 *     cpdef object wait(self, bytes unique_id):             # <<<<<<<<<<<<<<
 *         cdef object ar
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.AsyncHandler.wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ar);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_7wait(PyObject *__pyx_v_self, PyObject *__pyx_v_unique_id); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_7wait(PyObject *__pyx_v_self, PyObject *__pyx_v_unique_id) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("wait (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_unique_id), (&PyBytes_Type), 1, "unique_id", 1))) __PYX_ERR(0, 294, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_6wait(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_v_self), ((PyObject*)__pyx_v_unique_id));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_6wait(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("wait", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_wait(__pyx_v_self, __pyx_v_unique_id, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.AsyncHandler.wait", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":308
 *             return ar.exception()
 * 
 *     cpdef void got(self, bytes unique_id, object result):             # <<<<<<<<<<<<<<
 *         # receive event handling
 *         self.async_results[unique_id].set_result(result)
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_9got(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static void __pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_got(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id, PyObject *__pyx_v_result, int __pyx_skip_dispatch) {
  __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;
  __Pyx_RefNannySetupContext("got", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_got); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_9got)) {
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && 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);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_unique_id, __pyx_v_result};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 308, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_unique_id, __pyx_v_result};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 308, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 308, __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_unique_id);
          __Pyx_GIVEREF(__pyx_v_unique_id);
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_unique_id);
          __Pyx_INCREF(__pyx_v_result);
          __Pyx_GIVEREF(__pyx_v_result);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_result);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 308, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":310
 *     cpdef void got(self, bytes unique_id, object result):
 *         # receive event handling
 *         self.async_results[unique_id].set_result(result)             # <<<<<<<<<<<<<<
 * 
 *     cpdef void err(self, bytes unique_id, object t, object ex, object tb):
 */
  if (unlikely(__pyx_v_self->async_results == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 310, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->async_results, __pyx_v_unique_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_set_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_result) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_result);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __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;

  /* "mars/actors/pool/gevent_pool.pyx":308
 *             return ar.exception()
 * 
 *     cpdef void got(self, bytes unique_id, object result):             # <<<<<<<<<<<<<<
 *         # receive event handling
 *         self.async_results[unique_id].set_result(result)
 */

  /* function exit code */
  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_WriteUnraisable("mars.actors.pool.gevent_pool.AsyncHandler.got", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_9got(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_9got(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_unique_id = 0;
  PyObject *__pyx_v_result = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("got (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_unique_id,&__pyx_n_s_result,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_unique_id)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_result)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("got", 1, 2, 2, 1); __PYX_ERR(0, 308, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "got") < 0)) __PYX_ERR(0, 308, __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_unique_id = ((PyObject*)values[0]);
    __pyx_v_result = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("got", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 308, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.AsyncHandler.got", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_unique_id), (&PyBytes_Type), 1, "unique_id", 1))) __PYX_ERR(0, 308, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_8got(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_v_self), __pyx_v_unique_id, __pyx_v_result);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_8got(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id, PyObject *__pyx_v_result) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("got", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_void_to_None(__pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_got(__pyx_v_self, __pyx_v_unique_id, __pyx_v_result, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.AsyncHandler.got", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":312
 *         self.async_results[unique_id].set_result(result)
 * 
 *     cpdef void err(self, bytes unique_id, object t, object ex, object tb):             # <<<<<<<<<<<<<<
 *         self.async_results[unique_id].set_exception(ex, exc_info=(t, ex, tb))
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_11err(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static void __pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_err(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id, PyObject *__pyx_v_t, PyObject *__pyx_v_ex, PyObject *__pyx_v_tb, int __pyx_skip_dispatch) {
  __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;
  __Pyx_RefNannySetupContext("err", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_err); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 312, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_11err)) {
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && 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);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_unique_id, __pyx_v_t, __pyx_v_ex, __pyx_v_tb};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 312, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_unique_id, __pyx_v_t, __pyx_v_ex, __pyx_v_tb};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 312, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 312, __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_unique_id);
          __Pyx_GIVEREF(__pyx_v_unique_id);
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_unique_id);
          __Pyx_INCREF(__pyx_v_t);
          __Pyx_GIVEREF(__pyx_v_t);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_t);
          __Pyx_INCREF(__pyx_v_ex);
          __Pyx_GIVEREF(__pyx_v_ex);
          PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_ex);
          __Pyx_INCREF(__pyx_v_tb);
          __Pyx_GIVEREF(__pyx_v_tb);
          PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_tb);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 312, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":313
 * 
 *     cpdef void err(self, bytes unique_id, object t, object ex, object tb):
 *         self.async_results[unique_id].set_exception(ex, exc_info=(t, ex, tb))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (unlikely(__pyx_v_self->async_results == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 313, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_self->async_results, __pyx_v_unique_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 313, __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_ERR(0, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_ex);
  __Pyx_GIVEREF(__pyx_v_ex);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_ex);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(__pyx_v_t);
  __Pyx_GIVEREF(__pyx_v_t);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_t);
  __Pyx_INCREF(__pyx_v_ex);
  __Pyx_GIVEREF(__pyx_v_ex);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_ex);
  __Pyx_INCREF(__pyx_v_tb);
  __Pyx_GIVEREF(__pyx_v_tb);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_tb);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_exc_info, __pyx_t_6) < 0) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 313, __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_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":312
 *         self.async_results[unique_id].set_result(result)
 * 
 *     cpdef void err(self, bytes unique_id, object t, object ex, object tb):             # <<<<<<<<<<<<<<
 *         self.async_results[unique_id].set_exception(ex, exc_info=(t, ex, tb))
 * 
 */

  /* function exit code */
  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_WriteUnraisable("mars.actors.pool.gevent_pool.AsyncHandler.err", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_11err(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_11err(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_unique_id = 0;
  PyObject *__pyx_v_t = 0;
  PyObject *__pyx_v_ex = 0;
  PyObject *__pyx_v_tb = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("err (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_unique_id,&__pyx_n_s_t,&__pyx_n_s_ex,&__pyx_n_s_tb,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);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_unique_id)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_t)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("err", 1, 4, 4, 1); __PYX_ERR(0, 312, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ex)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("err", 1, 4, 4, 2); __PYX_ERR(0, 312, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tb)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("err", 1, 4, 4, 3); __PYX_ERR(0, 312, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "err") < 0)) __PYX_ERR(0, 312, __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_unique_id = ((PyObject*)values[0]);
    __pyx_v_t = values[1];
    __pyx_v_ex = values[2];
    __pyx_v_tb = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("err", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 312, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.AsyncHandler.err", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_unique_id), (&PyBytes_Type), 1, "unique_id", 1))) __PYX_ERR(0, 312, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_10err(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_v_self), __pyx_v_unique_id, __pyx_v_t, __pyx_v_ex, __pyx_v_tb);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_10err(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v_unique_id, PyObject *__pyx_v_t, PyObject *__pyx_v_ex, PyObject *__pyx_v_tb) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("err", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_void_to_None(__pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_err(__pyx_v_self, __pyx_v_unique_id, __pyx_v_t, __pyx_v_ex, __pyx_v_tb, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.AsyncHandler.err", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_12__reduce_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_12__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  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;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.async_results,)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->async_results);
  __Pyx_GIVEREF(__pyx_v_self->async_results);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->async_results);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.async_results,)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self.async_results,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.async_results is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.async_results,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.async_results is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_AsyncHandler, (type(self), 0x2e761fc, None), state
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_self->async_results != ((PyObject*)Py_None));
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.async_results is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_AsyncHandler, (type(self), 0x2e761fc, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self.async_results is not None
 *     if use_setstate:
 *         return __pyx_unpickle_AsyncHandler, (type(self), 0x2e761fc, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_AsyncHandler, (type(self), 0x2e761fc, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_AsyncHandler); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_48718332);
    __Pyx_GIVEREF(__pyx_int_48718332);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_48718332);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __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_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.async_results is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_AsyncHandler, (type(self), 0x2e761fc, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_AsyncHandler, (type(self), 0x2e761fc, None), state
 *     else:
 *         return __pyx_unpickle_AsyncHandler, (type(self), 0x2e761fc, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_AsyncHandler__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_AsyncHandler); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_48718332);
    __Pyx_GIVEREF(__pyx_int_48718332);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_48718332);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.AsyncHandler.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_AsyncHandler, (type(self), 0x2e761fc, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_AsyncHandler__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_14__setstate_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_14__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_AsyncHandler, (type(self), 0x2e761fc, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_AsyncHandler__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_AsyncHandler__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_AsyncHandler, (type(self), 0x2e761fc, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_AsyncHandler__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.AsyncHandler.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":320
 *     cdef public object lock
 * 
 *     def __init__(self, conn, lock):             # <<<<<<<<<<<<<<
 *         self.conn = conn
 *         self.lock = lock
 */

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_conn = 0;
  PyObject *__pyx_v_lock = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_conn,&__pyx_n_s_lock,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_conn)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lock)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 320, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 320, __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_conn = values[0];
    __pyx_v_lock = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 320, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Connection.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection___init__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *)__pyx_v_self), __pyx_v_conn, __pyx_v_lock);

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self, PyObject *__pyx_v_conn, PyObject *__pyx_v_lock) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":321
 * 
 *     def __init__(self, conn, lock):
 *         self.conn = conn             # <<<<<<<<<<<<<<
 *         self.lock = lock
 * 
 */
  __Pyx_INCREF(__pyx_v_conn);
  __Pyx_GIVEREF(__pyx_v_conn);
  __Pyx_GOTREF(__pyx_v_self->conn);
  __Pyx_DECREF(__pyx_v_self->conn);
  __pyx_v_self->conn = __pyx_v_conn;

  /* "mars/actors/pool/gevent_pool.pyx":322
 *     def __init__(self, conn, lock):
 *         self.conn = conn
 *         self.lock = lock             # <<<<<<<<<<<<<<
 * 
 *     def __enter__(self):
 */
  __Pyx_INCREF(__pyx_v_lock);
  __Pyx_GIVEREF(__pyx_v_lock);
  __Pyx_GOTREF(__pyx_v_self->lock);
  __Pyx_DECREF(__pyx_v_self->lock);
  __pyx_v_self->lock = __pyx_v_lock;

  /* "mars/actors/pool/gevent_pool.pyx":320
 *     cdef public object lock
 * 
 *     def __init__(self, conn, lock):             # <<<<<<<<<<<<<<
 *         self.conn = conn
 *         self.lock = lock
 */

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

/* "mars/actors/pool/gevent_pool.pyx":324
 *         self.lock = lock
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         return self.conn
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_3__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_3__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__enter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_2__enter__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_2__enter__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__enter__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":325
 * 
 *     def __enter__(self):
 *         return self.conn             # <<<<<<<<<<<<<<
 * 
 *     def __exit__(self, *_):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->conn);
  __pyx_r = __pyx_v_self->conn;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":324
 *         self.lock = lock
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         return self.conn
 * 
 */

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

/* "mars/actors/pool/gevent_pool.pyx":327
 *         return self.conn
 * 
 *     def __exit__(self, *_):             # <<<<<<<<<<<<<<
 *         self.lock.release()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_5__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_5__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v__ = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__exit__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__exit__", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v__ = __pyx_args;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4__exit__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *)__pyx_v_self), __pyx_v__);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4__exit__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v__) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__exit__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":328
 * 
 *     def __exit__(self, *_):
 *         self.lock.release()             # <<<<<<<<<<<<<<
 * 
 *     cpdef void release(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->lock, __pyx_n_s_release); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 328, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 328, __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;

  /* "mars/actors/pool/gevent_pool.pyx":327
 *         return self.conn
 * 
 *     def __exit__(self, *_):             # <<<<<<<<<<<<<<
 *         self.lock.release()
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.Connection.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":330
 *         self.lock.release()
 * 
 *     cpdef void release(self):             # <<<<<<<<<<<<<<
 *         self.lock.release()
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static void __pyx_f_4mars_6actors_4pool_11gevent_pool_10Connection_release(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self, int __pyx_skip_dispatch) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("release", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_release); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_7release)) {
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 330, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":331
 * 
 *     cpdef void release(self):
 *         self.lock.release()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->lock, __pyx_n_s_release); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 331, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 331, __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;

  /* "mars/actors/pool/gevent_pool.pyx":330
 *         self.lock.release()
 * 
 *     cpdef void release(self):             # <<<<<<<<<<<<<<
 *         self.lock.release()
 * 
 */

  /* function exit code */
  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_WriteUnraisable("mars.actors.pool.gevent_pool.Connection.release", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_7release(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("release (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_6release(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_6release(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("release", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_void_to_None(__pyx_f_4mars_6actors_4pool_11gevent_pool_10Connection_release(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Connection.release", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":317
 * 
 * cdef class Connection:
 *     cdef public object conn             # <<<<<<<<<<<<<<
 *     cdef public object lock
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4conn_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4conn_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4conn___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4conn___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->conn);
  __pyx_r = __pyx_v_self->conn;
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4conn_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4conn_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4conn_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4conn_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->conn);
  __Pyx_DECREF(__pyx_v_self->conn);
  __pyx_v_self->conn = __pyx_v_value;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4conn_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4conn_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4conn_4__del__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *)__pyx_v_self));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4conn_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->conn);
  __Pyx_DECREF(__pyx_v_self->conn);
  __pyx_v_self->conn = Py_None;

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

/* "mars/actors/pool/gevent_pool.pyx":318
 * cdef class Connection:
 *     cdef public object conn
 *     cdef public object lock             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, conn, lock):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4lock_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4lock_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4lock___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4lock___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->lock);
  __pyx_r = __pyx_v_self->lock;
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4lock_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4lock_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4lock_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4lock_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->lock);
  __Pyx_DECREF(__pyx_v_self->lock);
  __pyx_v_self->lock = __pyx_v_value;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4lock_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4lock_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4lock_4__del__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *)__pyx_v_self));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_4lock_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->lock);
  __Pyx_DECREF(__pyx_v_self->lock);
  __pyx_v_self->lock = Py_None;

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

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_8__reduce_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_8__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.conn, self.lock)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->conn);
  __Pyx_GIVEREF(__pyx_v_self->conn);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->conn);
  __Pyx_INCREF(__pyx_v_self->lock);
  __Pyx_GIVEREF(__pyx_v_self->lock);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->lock);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.conn, self.lock)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self.conn, self.lock)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.conn is not None or self.lock is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.conn, self.lock)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.conn is not None or self.lock is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Connection, (type(self), 0xe946d0d, None), state
 */
  /*else*/ {
    __pyx_t_2 = (__pyx_v_self->conn != Py_None);
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->lock != Py_None);
    __pyx_t_2 = (__pyx_t_5 != 0);
    __pyx_t_3 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.conn is not None or self.lock is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Connection, (type(self), 0xe946d0d, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self.conn is not None or self.lock is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Connection, (type(self), 0xe946d0d, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Connection, (type(self), 0xe946d0d, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Connection); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_244608269);
    __Pyx_GIVEREF(__pyx_int_244608269);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_244608269);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.conn is not None or self.lock is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Connection, (type(self), 0xe946d0d, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Connection, (type(self), 0xe946d0d, None), state
 *     else:
 *         return __pyx_unpickle_Connection, (type(self), 0xe946d0d, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Connection__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_Connection); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_244608269);
    __Pyx_GIVEREF(__pyx_int_244608269);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_244608269);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Connection.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Connection, (type(self), 0xe946d0d, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Connection__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_10__setstate_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Connection_10__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Connection, (type(self), 0xe946d0d, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Connection__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_Connection__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Connection, (type(self), 0xe946d0d, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Connection__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Connection.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":338
 *     addrs = 0
 * 
 *     def __init__(self, address):             # <<<<<<<<<<<<<<
 *         if isinstance(address, six.string_types):
 *             self.address = address.split(':', 1)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_11Connections_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_address = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_address,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_address)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 338, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 338, __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_address = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 338, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Connections.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections___init__(__pyx_self, __pyx_v_self, __pyx_v_address);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_address) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":339
 * 
 *     def __init__(self, address):
 *         if isinstance(address, six.string_types):             # <<<<<<<<<<<<<<
 *             self.address = address.split(':', 1)
 *         else:
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_six); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_string_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = PyObject_IsInstance(__pyx_v_address, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "mars/actors/pool/gevent_pool.pyx":340
 *     def __init__(self, address):
 *         if isinstance(address, six.string_types):
 *             self.address = address.split(':', 1)             # <<<<<<<<<<<<<<
 *         else:
 *             self.address = address
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_address, __pyx_n_s_split); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 340, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __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_address, __pyx_t_1) < 0) __PYX_ERR(0, 340, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":339
 * 
 *     def __init__(self, address):
 *         if isinstance(address, six.string_types):             # <<<<<<<<<<<<<<
 *             self.address = address.split(':', 1)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "mars/actors/pool/gevent_pool.pyx":342
 *             self.address = address.split(':', 1)
 *         else:
 *             self.address = address             # <<<<<<<<<<<<<<
 * 
 *         with self.global_lock:
 */
  /*else*/ {
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_address, __pyx_v_address) < 0) __PYX_ERR(0, 342, __pyx_L1_error)
  }
  __pyx_L3:;

  /* "mars/actors/pool/gevent_pool.pyx":344
 *             self.address = address
 * 
 *         with self.global_lock:             # <<<<<<<<<<<<<<
 *             Connections.addrs += 1
 * 
 */
  /*with:*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_global_lock); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 344, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 344, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 344, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 344, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_2);
    __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;
    /*try:*/ {
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __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:*/ {

          /* "mars/actors/pool/gevent_pool.pyx":345
 * 
 *         with self.global_lock:
 *             Connections.addrs += 1             # <<<<<<<<<<<<<<
 * 
 *         self.lock = gevent.lock.Semaphore()
 */
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Connections); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_addrs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 345, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 345, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Connections); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 345, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_2);
          if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_n_s_addrs, __pyx_t_1) < 0) __PYX_ERR(0, 345, __pyx_L8_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "mars/actors/pool/gevent_pool.pyx":344
 *             self.address = address
 * 
 *         with self.global_lock:             # <<<<<<<<<<<<<<
 *             Connections.addrs += 1
 * 
 */
        }
        __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_L8_error:;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        /*except:*/ {
          __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Connections.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_6) < 0) __PYX_ERR(0, 344, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_7 = PyTuple_Pack(3, __pyx_t_2, __pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 344, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 344, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (__pyx_t_4 < 0) __PYX_ERR(0, 344, __pyx_L10_except_error)
          __pyx_t_3 = ((!(__pyx_t_4 != 0)) != 0);
          if (__pyx_t_3) {
            __Pyx_GIVEREF(__pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_1);
            __Pyx_XGIVEREF(__pyx_t_6);
            __Pyx_ErrRestoreWithState(__pyx_t_2, __pyx_t_1, __pyx_t_6);
            __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_6 = 0; 
            __PYX_ERR(0, 344, __pyx_L10_except_error)
          }
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          goto __pyx_L9_exception_handled;
        }
        __pyx_L10_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_L9_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_L13_try_end:;
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_5) {
          __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple_, NULL);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 344, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    goto __pyx_L17;
    __pyx_L4_error:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L1_error;
    __pyx_L17:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":347
 *             Connections.addrs += 1
 * 
 *         self.lock = gevent.lock.Semaphore()             # <<<<<<<<<<<<<<
 *         self.conn_locks = OrderedDict()
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __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_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Semaphore); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_6 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_lock, __pyx_t_6) < 0) __PYX_ERR(0, 347, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":348
 * 
 *         self.lock = gevent.lock.Semaphore()
 *         self.conn_locks = OrderedDict()             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(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);
    }
  }
  __pyx_t_6 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 348, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_conn_locks, __pyx_t_6) < 0) __PYX_ERR(0, 348, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":338
 *     addrs = 0
 * 
 *     def __init__(self, address):             # <<<<<<<<<<<<<<
 *         if isinstance(address, six.string_types):
 *             self.address = address.split(':', 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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Connections.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":351
 * 
 *     @property
 *     def conn(self):             # <<<<<<<<<<<<<<
 *         return [conn_lock[0] for conn_lock in six.itervalues(self.conn_locks)]
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_3conn(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_11Connections_3conn = {"conn", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_3conn, METH_O, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_3conn(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("conn (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_2conn(__pyx_self, ((PyObject *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_2conn(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_conn_lock = 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;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  __Pyx_RefNannySetupContext("conn", 0);

  /* "mars/actors/pool/gevent_pool.pyx":352
 *     @property
 *     def conn(self):
 *         return [conn_lock[0] for conn_lock in six.itervalues(self.conn_locks)]             # <<<<<<<<<<<<<<
 * 
 *     def _connect(self, conn, lock):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_six); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_itervalues); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 352, __pyx_L1_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_conn_locks); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_4 = __pyx_t_2; __Pyx_INCREF(__pyx_t_4); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 352, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 352, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 352, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 352, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 352, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 352, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_7(__pyx_t_4);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 352, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_conn_lock, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_conn_lock, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 352, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 352, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":351
 * 
 *     @property
 *     def conn(self):             # <<<<<<<<<<<<<<
 *         return [conn_lock[0] for conn_lock in six.itervalues(self.conn_locks)]
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.Connections.conn", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_conn_lock);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":354
 *         return [conn_lock[0] for conn_lock in six.itervalues(self.conn_locks)]
 * 
 *     def _connect(self, conn, lock):             # <<<<<<<<<<<<<<
 *         return Connection(conn, lock)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_5_connect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_11Connections_5_connect = {"_connect", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_5_connect, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_5_connect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_conn = 0;
  PyObject *__pyx_v_lock = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_connect (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_conn,&__pyx_n_s_lock,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_conn)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_connect", 1, 3, 3, 1); __PYX_ERR(0, 354, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lock)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_connect", 1, 3, 3, 2); __PYX_ERR(0, 354, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_connect") < 0)) __PYX_ERR(0, 354, __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_conn = values[1];
    __pyx_v_lock = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_connect", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 354, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Connections._connect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_4_connect(__pyx_self, __pyx_v_self, __pyx_v_conn, __pyx_v_lock);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_4_connect(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_conn, PyObject *__pyx_v_lock) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("_connect", 0);

  /* "mars/actors/pool/gevent_pool.pyx":355
 * 
 *     def _connect(self, conn, lock):
 *         return Connection(conn, lock)             # <<<<<<<<<<<<<<
 * 
 *     def got_broken_pipe(self, fd):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_conn);
  __Pyx_GIVEREF(__pyx_v_conn);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_conn);
  __Pyx_INCREF(__pyx_v_lock);
  __Pyx_GIVEREF(__pyx_v_lock);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_lock);
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_Connection), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 355, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":354
 *         return [conn_lock[0] for conn_lock in six.itervalues(self.conn_locks)]
 * 
 *     def _connect(self, conn, lock):             # <<<<<<<<<<<<<<
 *         return Connection(conn, lock)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Connections._connect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":357
 *         return Connection(conn, lock)
 * 
 *     def got_broken_pipe(self, fd):             # <<<<<<<<<<<<<<
 *         del self.conn_locks[fd]
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_7got_broken_pipe(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_11Connections_7got_broken_pipe = {"got_broken_pipe", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_7got_broken_pipe, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_7got_broken_pipe(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_fd = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("got_broken_pipe (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_fd,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fd)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("got_broken_pipe", 1, 2, 2, 1); __PYX_ERR(0, 357, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "got_broken_pipe") < 0)) __PYX_ERR(0, 357, __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_fd = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("got_broken_pipe", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 357, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Connections.got_broken_pipe", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_6got_broken_pipe(__pyx_self, __pyx_v_self, __pyx_v_fd);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_6got_broken_pipe(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_fd) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("got_broken_pipe", 0);

  /* "mars/actors/pool/gevent_pool.pyx":358
 * 
 *     def got_broken_pipe(self, fd):
 *         del self.conn_locks[fd]             # <<<<<<<<<<<<<<
 * 
 *     def connect(self):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_conn_locks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 358, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(PyObject_DelItem(__pyx_t_1, __pyx_v_fd) < 0)) __PYX_ERR(0, 358, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":357
 *         return Connection(conn, lock)
 * 
 *     def got_broken_pipe(self, fd):             # <<<<<<<<<<<<<<
 *         del self.conn_locks[fd]
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Connections.got_broken_pipe", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":360
 *         del self.conn_locks[fd]
 * 
 *     def connect(self):             # <<<<<<<<<<<<<<
 *         cdef int maxlen
 *         cdef object conn
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_9connect(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_11Connections_9connect = {"connect", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_9connect, METH_O, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_9connect(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("connect (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_8connect(__pyx_self, ((PyObject *)__pyx_v_self));

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

/* "mars/actors/pool/gevent_pool.pyx":384
 *                 return self._connect(conn, lock)
 * 
 *             def close(c, lk):             # <<<<<<<<<<<<<<
 *                 with lk:
 *                     c.close()
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_7connect_1close(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_11Connections_7connect_1close = {"close", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_7connect_1close, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_7connect_1close(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_c = 0;
  PyObject *__pyx_v_lk = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("close (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_c,&__pyx_n_s_lk,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_c)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lk)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("close", 1, 2, 2, 1); __PYX_ERR(0, 384, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "close") < 0)) __PYX_ERR(0, 384, __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_c = values[0];
    __pyx_v_lk = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("close", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 384, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Connections.connect.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_7connect_close(__pyx_self, __pyx_v_c, __pyx_v_lk);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_7connect_close(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_c, PyObject *__pyx_v_lk) {
  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;
  __Pyx_RefNannySetupContext("close", 0);

  /* "mars/actors/pool/gevent_pool.pyx":385
 * 
 *             def close(c, lk):
 *                 with lk:             # <<<<<<<<<<<<<<
 *                     c.close()
 * 
 */
  /*with:*/ {
    __pyx_t_1 = __Pyx_PyObject_LookupSpecial(__pyx_v_lk, __pyx_n_s_exit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_v_lk, __pyx_n_s_enter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 385, __pyx_L3_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && 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_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 385, __pyx_L3_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    /*try:*/ {
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_5);
        __Pyx_XGOTREF(__pyx_t_6);
        __Pyx_XGOTREF(__pyx_t_7);
        /*try:*/ {

          /* "mars/actors/pool/gevent_pool.pyx":386
 *             def close(c, lk):
 *                 with lk:
 *                     c.close()             # <<<<<<<<<<<<<<
 * 
 *             ps = [gevent.spawn(close, c, l) for c, l in
 */
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_close); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 386, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = NULL;
          if (CYTHON_UNPACK_METHODS && 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_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 386, __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;

          /* "mars/actors/pool/gevent_pool.pyx":385
 * 
 *             def close(c, lk):
 *                 with lk:             # <<<<<<<<<<<<<<
 *                     c.close()
 * 
 */
        }
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L12_try_end;
        __pyx_L7_error:;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        /*except:*/ {
          __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Connections.connect.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4) < 0) __PYX_ERR(0, 385, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_8 = PyTuple_Pack(3, __pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 385, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 385, __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_ERR(0, 385, __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_3);
            __Pyx_XGIVEREF(__pyx_t_4);
            __Pyx_ErrRestoreWithState(__pyx_t_2, __pyx_t_3, __pyx_t_4);
            __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_4 = 0; 
            __PYX_ERR(0, 385, __pyx_L9_except_error)
          }
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          goto __pyx_L8_exception_handled;
        }
        __pyx_L9_except_error:;
        __Pyx_XGIVEREF(__pyx_t_5);
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
        goto __pyx_L1_error;
        __pyx_L8_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_5);
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
        __pyx_L12_try_end:;
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_1) {
          __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple_, NULL);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 385, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        }
        goto __pyx_L6;
      }
      __pyx_L6:;
    }
    goto __pyx_L16;
    __pyx_L3_error:;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L1_error;
    __pyx_L16:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":384
 *                 return self._connect(conn, lock)
 * 
 *             def close(c, lk):             # <<<<<<<<<<<<<<
 *                 with lk:
 *                     c.close()
 */

  /* 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_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Connections.connect.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":360
 *         del self.conn_locks[fd]
 * 
 *     def connect(self):             # <<<<<<<<<<<<<<
 *         cdef int maxlen
 *         cdef object conn
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_8connect(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  int __pyx_v_maxlen;
  PyObject *__pyx_v_conn = 0;
  PyObject *__pyx_v_lock = 0;
  PyObject *__pyx_v_locked = NULL;
  PyObject *__pyx_v_close = 0;
  PyObject *__pyx_v_ps = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_fd = NULL;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_v_l = 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;
  Py_ssize_t __pyx_t_9;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *(*__pyx_t_12)(PyObject *);
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_t_15;
  long __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  __Pyx_RefNannySetupContext("connect", 0);

  /* "mars/actors/pool/gevent_pool.pyx":365
 *         cdef object lock
 * 
 *         with self.lock:             # <<<<<<<<<<<<<<
 *             for conn, lock in six.itervalues(self.conn_locks):
 *                 # try to reuse the connections before
 */
  /*with:*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lock); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __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_ERR(0, 365, __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_ERR(0, 365, __pyx_L3_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 365, __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_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __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:*/ {

          /* "mars/actors/pool/gevent_pool.pyx":366
 * 
 *         with self.lock:
 *             for conn, lock in six.itervalues(self.conn_locks):             # <<<<<<<<<<<<<<
 *                 # try to reuse the connections before
 *                 locked = lock.acquire(blocking=False)
 */
          __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_six); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 366, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_itervalues); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 366, __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_conn_locks); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 366, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_5 = NULL;
          if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
            __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_9 = 0;
            __pyx_t_10 = NULL;
          } else {
            __pyx_t_9 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 366, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 366, __pyx_L7_error)
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          for (;;) {
            if (likely(!__pyx_t_10)) {
              if (likely(PyList_CheckExact(__pyx_t_4))) {
                if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_4)) break;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 366, __pyx_L7_error)
                #else
                __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __pyx_L7_error)
                __Pyx_GOTREF(__pyx_t_1);
                #endif
              } else {
                if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 366, __pyx_L7_error)
                #else
                __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 366, __pyx_L7_error)
                __Pyx_GOTREF(__pyx_t_1);
                #endif
              }
            } else {
              __pyx_t_1 = __pyx_t_10(__pyx_t_4);
              if (unlikely(!__pyx_t_1)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                  else __PYX_ERR(0, 366, __pyx_L7_error)
                }
                break;
              }
              __Pyx_GOTREF(__pyx_t_1);
            }
            if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
              PyObject* sequence = __pyx_t_1;
              Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
              if (unlikely(size != 2)) {
                if (size > 2) __Pyx_RaiseTooManyValuesError(2);
                else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
                __PYX_ERR(0, 366, __pyx_L7_error)
              }
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              if (likely(PyTuple_CheckExact(sequence))) {
                __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
                __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
              } else {
                __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
                __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
              }
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_5);
              #else
              __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 366, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 366, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_5);
              #endif
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            } else {
              Py_ssize_t index = -1;
              __pyx_t_11 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 366, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_11);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
              index = 0; __pyx_t_3 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_3)) goto __pyx_L15_unpacking_failed;
              __Pyx_GOTREF(__pyx_t_3);
              index = 1; __pyx_t_5 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_5)) goto __pyx_L15_unpacking_failed;
              __Pyx_GOTREF(__pyx_t_5);
              if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 2) < 0) __PYX_ERR(0, 366, __pyx_L7_error)
              __pyx_t_12 = NULL;
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              goto __pyx_L16_unpacking_done;
              __pyx_L15_unpacking_failed:;
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              __pyx_t_12 = NULL;
              if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
              __PYX_ERR(0, 366, __pyx_L7_error)
              __pyx_L16_unpacking_done:;
            }
            __Pyx_XDECREF_SET(__pyx_v_conn, __pyx_t_3);
            __pyx_t_3 = 0;
            __Pyx_XDECREF_SET(__pyx_v_lock, __pyx_t_5);
            __pyx_t_5 = 0;

            /* "mars/actors/pool/gevent_pool.pyx":368
 *             for conn, lock in six.itervalues(self.conn_locks):
 *                 # try to reuse the connections before
 *                 locked = lock.acquire(blocking=False)             # <<<<<<<<<<<<<<
 *                 if not locked:
 *                     continue
 */
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_lock, __pyx_n_s_acquire); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 368, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 368, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_5);
            if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_blocking, Py_False) < 0) __PYX_ERR(0, 368, __pyx_L7_error)
            __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 368, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF_SET(__pyx_v_locked, __pyx_t_3);
            __pyx_t_3 = 0;

            /* "mars/actors/pool/gevent_pool.pyx":369
 *                 # try to reuse the connections before
 *                 locked = lock.acquire(blocking=False)
 *                 if not locked:             # <<<<<<<<<<<<<<
 *                     continue
 *                 return self._connect(conn, lock)
 */
            __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_v_locked); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 369, __pyx_L7_error)
            __pyx_t_14 = ((!__pyx_t_13) != 0);
            if (__pyx_t_14) {

              /* "mars/actors/pool/gevent_pool.pyx":370
 *                 locked = lock.acquire(blocking=False)
 *                 if not locked:
 *                     continue             # <<<<<<<<<<<<<<
 *                 return self._connect(conn, lock)
 * 
 */
              goto __pyx_L13_continue;

              /* "mars/actors/pool/gevent_pool.pyx":369
 *                 # try to reuse the connections before
 *                 locked = lock.acquire(blocking=False)
 *                 if not locked:             # <<<<<<<<<<<<<<
 *                     continue
 *                 return self._connect(conn, lock)
 */
            }

            /* "mars/actors/pool/gevent_pool.pyx":371
 *                 if not locked:
 *                     continue
 *                 return self._connect(conn, lock)             # <<<<<<<<<<<<<<
 * 
 *             maxlen = max(REMOTE_MAX_CONNECTION // Connections.addrs, 1)
 */
            __Pyx_XDECREF(__pyx_r);
            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_connect); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 371, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_1 = NULL;
            __pyx_t_15 = 0;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
              __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
              if (likely(__pyx_t_1)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
                __Pyx_INCREF(__pyx_t_1);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_5, function);
                __pyx_t_15 = 1;
              }
            }
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_5)) {
              PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_conn, __pyx_v_lock};
              __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L7_error)
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_GOTREF(__pyx_t_3);
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
              PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_conn, __pyx_v_lock};
              __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L7_error)
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_GOTREF(__pyx_t_3);
            } else
            #endif
            {
              __pyx_t_11 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 371, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_11);
              if (__pyx_t_1) {
                __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __pyx_t_1 = NULL;
              }
              __Pyx_INCREF(__pyx_v_conn);
              __Pyx_GIVEREF(__pyx_v_conn);
              PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_15, __pyx_v_conn);
              __Pyx_INCREF(__pyx_v_lock);
              __Pyx_GIVEREF(__pyx_v_lock);
              PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_15, __pyx_v_lock);
              __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            }
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_r = __pyx_t_3;
            __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            goto __pyx_L11_try_return;

            /* "mars/actors/pool/gevent_pool.pyx":366
 * 
 *         with self.lock:
 *             for conn, lock in six.itervalues(self.conn_locks):             # <<<<<<<<<<<<<<
 *                 # try to reuse the connections before
 *                 locked = lock.acquire(blocking=False)
 */
            __pyx_L13_continue:;
          }
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "mars/actors/pool/gevent_pool.pyx":373
 *                 return self._connect(conn, lock)
 * 
 *             maxlen = max(REMOTE_MAX_CONNECTION // Connections.addrs, 1)             # <<<<<<<<<<<<<<
 * 
 *             if len(self.conn) < maxlen:
 */
          __pyx_t_16 = 1;
          __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_4mars_6actors_4pool_11gevent_pool_REMOTE_MAX_CONNECTION); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 373, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Connections); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 373, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_addrs); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 373, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = PyNumber_FloorDivide(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 373, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_t_16); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 373, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_11 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 373, __pyx_L7_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 373, __pyx_L7_error)
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (__pyx_t_14) {
            __pyx_t_11 = __Pyx_PyInt_From_long(__pyx_t_16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 373, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_11);
            __pyx_t_5 = __pyx_t_11;
            __pyx_t_11 = 0;
          } else {
            __Pyx_INCREF(__pyx_t_3);
            __pyx_t_5 = __pyx_t_3;
          }
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_15 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_15 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 373, __pyx_L7_error)
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_v_maxlen = __pyx_t_15;

          /* "mars/actors/pool/gevent_pool.pyx":375
 *             maxlen = max(REMOTE_MAX_CONNECTION // Connections.addrs, 1)
 * 
 *             if len(self.conn) < maxlen:             # <<<<<<<<<<<<<<
 *                 # create a new connection
 *                 lock = gevent.lock.Semaphore()
 */
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_conn); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 375, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_9 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 375, __pyx_L7_error)
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_14 = ((__pyx_t_9 < __pyx_v_maxlen) != 0);
          if (__pyx_t_14) {

            /* "mars/actors/pool/gevent_pool.pyx":377
 *             if len(self.conn) < maxlen:
 *                 # create a new connection
 *                 lock = gevent.lock.Semaphore()             # <<<<<<<<<<<<<<
 *                 lock.acquire()
 *                 conn = gevent.socket.create_connection(self.address)
 */
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_gevent); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 377, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_lock); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 377, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_11);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_Semaphore); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 377, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            __pyx_t_11 = NULL;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3);
              if (likely(__pyx_t_11)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_11);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_3, function);
              }
            }
            __pyx_t_5 = (__pyx_t_11) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_11) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 377, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF_SET(__pyx_v_lock, __pyx_t_5);
            __pyx_t_5 = 0;

            /* "mars/actors/pool/gevent_pool.pyx":378
 *                 # create a new connection
 *                 lock = gevent.lock.Semaphore()
 *                 lock.acquire()             # <<<<<<<<<<<<<<
 *                 conn = gevent.socket.create_connection(self.address)
 * 
 */
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_lock, __pyx_n_s_acquire); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 378, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_11 = NULL;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3);
              if (likely(__pyx_t_11)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_11);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_3, function);
              }
            }
            __pyx_t_5 = (__pyx_t_11) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_11) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 378, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

            /* "mars/actors/pool/gevent_pool.pyx":379
 *                 lock = gevent.lock.Semaphore()
 *                 lock.acquire()
 *                 conn = gevent.socket.create_connection(self.address)             # <<<<<<<<<<<<<<
 * 
 *                 self.conn_locks[conn.fileno()] = (conn, lock)
 */
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_gevent); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 379, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_socket); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 379, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_11);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_create_connection); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 379, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_address); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 379, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_11);
            __pyx_t_4 = NULL;
            if (CYTHON_UNPACK_METHODS && 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 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_11) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_11);
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 379, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF_SET(__pyx_v_conn, __pyx_t_5);
            __pyx_t_5 = 0;

            /* "mars/actors/pool/gevent_pool.pyx":381
 *                 conn = gevent.socket.create_connection(self.address)
 * 
 *                 self.conn_locks[conn.fileno()] = (conn, lock)             # <<<<<<<<<<<<<<
 *                 return self._connect(conn, lock)
 * 
 */
            __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 381, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_INCREF(__pyx_v_conn);
            __Pyx_GIVEREF(__pyx_v_conn);
            PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_conn);
            __Pyx_INCREF(__pyx_v_lock);
            __Pyx_GIVEREF(__pyx_v_lock);
            PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_lock);
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_conn_locks); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 381, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_conn, __pyx_n_s_fileno); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 381, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_1 = NULL;
            if (CYTHON_UNPACK_METHODS && 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_11 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 381, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_11);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(PyObject_SetItem(__pyx_t_3, __pyx_t_11, __pyx_t_5) < 0)) __PYX_ERR(0, 381, __pyx_L7_error)
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

            /* "mars/actors/pool/gevent_pool.pyx":382
 * 
 *                 self.conn_locks[conn.fileno()] = (conn, lock)
 *                 return self._connect(conn, lock)             # <<<<<<<<<<<<<<
 * 
 *             def close(c, lk):
 */
            __Pyx_XDECREF(__pyx_r);
            __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_connect); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 382, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_11);
            __pyx_t_3 = NULL;
            __pyx_t_15 = 0;
            if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
              __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_11);
              if (likely(__pyx_t_3)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
                __Pyx_INCREF(__pyx_t_3);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_11, function);
                __pyx_t_15 = 1;
              }
            }
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_11)) {
              PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_conn, __pyx_v_lock};
              __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 382, __pyx_L7_error)
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_GOTREF(__pyx_t_5);
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
              PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_conn, __pyx_v_lock};
              __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 382, __pyx_L7_error)
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_GOTREF(__pyx_t_5);
            } else
            #endif
            {
              __pyx_t_4 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 382, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_4);
              if (__pyx_t_3) {
                __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
              }
              __Pyx_INCREF(__pyx_v_conn);
              __Pyx_GIVEREF(__pyx_v_conn);
              PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_15, __pyx_v_conn);
              __Pyx_INCREF(__pyx_v_lock);
              __Pyx_GIVEREF(__pyx_v_lock);
              PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_15, __pyx_v_lock);
              __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 382, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            }
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            __pyx_r = __pyx_t_5;
            __pyx_t_5 = 0;
            goto __pyx_L11_try_return;

            /* "mars/actors/pool/gevent_pool.pyx":375
 *             maxlen = max(REMOTE_MAX_CONNECTION // Connections.addrs, 1)
 * 
 *             if len(self.conn) < maxlen:             # <<<<<<<<<<<<<<
 *                 # create a new connection
 *                 lock = gevent.lock.Semaphore()
 */
          }

          /* "mars/actors/pool/gevent_pool.pyx":384
 *                 return self._connect(conn, lock)
 * 
 *             def close(c, lk):             # <<<<<<<<<<<<<<
 *                 with lk:
 *                     c.close()
 */
          __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_11Connections_7connect_1close, 0, __pyx_n_s_Connections_connect_locals_close, NULL, __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__7)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 384, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_v_close = __pyx_t_5;
          __pyx_t_5 = 0;

          /* "mars/actors/pool/gevent_pool.pyx":388
 *                     c.close()
 * 
 *             ps = [gevent.spawn(close, c, l) for c, l in             # <<<<<<<<<<<<<<
 *                   itertools.islice(six.itervalues(self.conn_locks), maxlen, len(self.conn_locks))]
 * 
 */
          __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 388, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_5);

          /* "mars/actors/pool/gevent_pool.pyx":389
 * 
 *             ps = [gevent.spawn(close, c, l) for c, l in
 *                   itertools.islice(six.itervalues(self.conn_locks), maxlen, len(self.conn_locks))]             # <<<<<<<<<<<<<<
 * 
 *             i = random.randint(0, maxlen - 1)
 */
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_itertools); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 389, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_islice); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 389, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_six); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 389, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_itervalues); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 389, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_conn_locks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 389, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_18 = NULL;
          if (CYTHON_UNPACK_METHODS && 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_4 = (__pyx_t_18) ? __Pyx_PyObject_Call2Args(__pyx_t_17, __pyx_t_18, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_17, __pyx_t_1);
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 389, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __pyx_t_17 = __Pyx_PyInt_From_int(__pyx_v_maxlen); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 389, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_conn_locks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 389, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 389, __pyx_L7_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 389, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_18 = NULL;
          __pyx_t_15 = 0;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_3);
            if (likely(__pyx_t_18)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_18);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_3, function);
              __pyx_t_15 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_3)) {
            PyObject *__pyx_temp[4] = {__pyx_t_18, __pyx_t_4, __pyx_t_17, __pyx_t_1};
            __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_15, 3+__pyx_t_15); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 389, __pyx_L7_error)
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_GOTREF(__pyx_t_11);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
            PyObject *__pyx_temp[4] = {__pyx_t_18, __pyx_t_4, __pyx_t_17, __pyx_t_1};
            __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_15, 3+__pyx_t_15); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 389, __pyx_L7_error)
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_GOTREF(__pyx_t_11);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          } else
          #endif
          {
            __pyx_t_19 = PyTuple_New(3+__pyx_t_15); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 389, __pyx_L7_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_4);
            PyTuple_SET_ITEM(__pyx_t_19, 0+__pyx_t_15, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_17);
            PyTuple_SET_ITEM(__pyx_t_19, 1+__pyx_t_15, __pyx_t_17);
            __Pyx_GIVEREF(__pyx_t_1);
            PyTuple_SET_ITEM(__pyx_t_19, 2+__pyx_t_15, __pyx_t_1);
            __pyx_t_4 = 0;
            __pyx_t_17 = 0;
            __pyx_t_1 = 0;
            __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_19, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 389, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_11);
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          }
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (likely(PyList_CheckExact(__pyx_t_11)) || PyTuple_CheckExact(__pyx_t_11)) {
            __pyx_t_3 = __pyx_t_11; __Pyx_INCREF(__pyx_t_3); __pyx_t_9 = 0;
            __pyx_t_10 = NULL;
          } else {
            __pyx_t_9 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 389, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_10 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 389, __pyx_L7_error)
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          for (;;) {
            if (likely(!__pyx_t_10)) {
              if (likely(PyList_CheckExact(__pyx_t_3))) {
                if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_3)) break;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_11 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 389, __pyx_L7_error)
                #else
                __pyx_t_11 = PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 389, __pyx_L7_error)
                __Pyx_GOTREF(__pyx_t_11);
                #endif
              } else {
                if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 389, __pyx_L7_error)
                #else
                __pyx_t_11 = PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 389, __pyx_L7_error)
                __Pyx_GOTREF(__pyx_t_11);
                #endif
              }
            } else {
              __pyx_t_11 = __pyx_t_10(__pyx_t_3);
              if (unlikely(!__pyx_t_11)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                  else __PYX_ERR(0, 389, __pyx_L7_error)
                }
                break;
              }
              __Pyx_GOTREF(__pyx_t_11);
            }
            if ((likely(PyTuple_CheckExact(__pyx_t_11))) || (PyList_CheckExact(__pyx_t_11))) {
              PyObject* sequence = __pyx_t_11;
              Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
              if (unlikely(size != 2)) {
                if (size > 2) __Pyx_RaiseTooManyValuesError(2);
                else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
                __PYX_ERR(0, 388, __pyx_L7_error)
              }
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              if (likely(PyTuple_CheckExact(sequence))) {
                __pyx_t_19 = PyTuple_GET_ITEM(sequence, 0); 
                __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
              } else {
                __pyx_t_19 = PyList_GET_ITEM(sequence, 0); 
                __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
              }
              __Pyx_INCREF(__pyx_t_19);
              __Pyx_INCREF(__pyx_t_1);
              #else
              __pyx_t_19 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 388, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_19);
              __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 388, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_1);
              #endif
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            } else {
              Py_ssize_t index = -1;
              __pyx_t_17 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 388, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_17);
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              __pyx_t_12 = Py_TYPE(__pyx_t_17)->tp_iternext;
              index = 0; __pyx_t_19 = __pyx_t_12(__pyx_t_17); if (unlikely(!__pyx_t_19)) goto __pyx_L21_unpacking_failed;
              __Pyx_GOTREF(__pyx_t_19);
              index = 1; __pyx_t_1 = __pyx_t_12(__pyx_t_17); if (unlikely(!__pyx_t_1)) goto __pyx_L21_unpacking_failed;
              __Pyx_GOTREF(__pyx_t_1);
              if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_17), 2) < 0) __PYX_ERR(0, 388, __pyx_L7_error)
              __pyx_t_12 = NULL;
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              goto __pyx_L22_unpacking_done;
              __pyx_L21_unpacking_failed:;
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              __pyx_t_12 = NULL;
              if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
              __PYX_ERR(0, 388, __pyx_L7_error)
              __pyx_L22_unpacking_done:;
            }

            /* "mars/actors/pool/gevent_pool.pyx":388
 *                     c.close()
 * 
 *             ps = [gevent.spawn(close, c, l) for c, l in             # <<<<<<<<<<<<<<
 *                   itertools.islice(six.itervalues(self.conn_locks), maxlen, len(self.conn_locks))]
 * 
 */
            __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_19);
            __pyx_t_19 = 0;
            __Pyx_XDECREF_SET(__pyx_v_l, __pyx_t_1);
            __pyx_t_1 = 0;
            __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 388, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_spawn); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 388, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_19);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_1 = NULL;
            __pyx_t_15 = 0;
            if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_19))) {
              __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_19);
              if (likely(__pyx_t_1)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19);
                __Pyx_INCREF(__pyx_t_1);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_19, function);
                __pyx_t_15 = 1;
              }
            }
            #if CYTHON_FAST_PYCALL
            if (PyFunction_Check(__pyx_t_19)) {
              PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_v_close, __pyx_v_c, __pyx_v_l};
              __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_19, __pyx_temp+1-__pyx_t_15, 3+__pyx_t_15); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 388, __pyx_L7_error)
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_GOTREF(__pyx_t_11);
            } else
            #endif
            #if CYTHON_FAST_PYCCALL
            if (__Pyx_PyFastCFunction_Check(__pyx_t_19)) {
              PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_v_close, __pyx_v_c, __pyx_v_l};
              __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_19, __pyx_temp+1-__pyx_t_15, 3+__pyx_t_15); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 388, __pyx_L7_error)
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_GOTREF(__pyx_t_11);
            } else
            #endif
            {
              __pyx_t_17 = PyTuple_New(3+__pyx_t_15); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 388, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_17);
              if (__pyx_t_1) {
                __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_1); __pyx_t_1 = NULL;
              }
              __Pyx_INCREF(__pyx_v_close);
              __Pyx_GIVEREF(__pyx_v_close);
              PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_15, __pyx_v_close);
              __Pyx_INCREF(__pyx_v_c);
              __Pyx_GIVEREF(__pyx_v_c);
              PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_15, __pyx_v_c);
              __Pyx_INCREF(__pyx_v_l);
              __Pyx_GIVEREF(__pyx_v_l);
              PyTuple_SET_ITEM(__pyx_t_17, 2+__pyx_t_15, __pyx_v_l);
              __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_t_17, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 388, __pyx_L7_error)
              __Pyx_GOTREF(__pyx_t_11);
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            }
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_11))) __PYX_ERR(0, 388, __pyx_L7_error)
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          }
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_v_ps = ((PyObject*)__pyx_t_5);
          __pyx_t_5 = 0;

          /* "mars/actors/pool/gevent_pool.pyx":391
 *                   itertools.islice(six.itervalues(self.conn_locks), maxlen, len(self.conn_locks))]
 * 
 *             i = random.randint(0, maxlen - 1)             # <<<<<<<<<<<<<<
 *             fd = next(itertools.islice(six.iterkeys(self.conn_locks), i, i + 1))
 *             conn, lock = self.conn_locks[fd]
 */
          __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 391, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_randint); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 391, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = __Pyx_PyInt_From_long((__pyx_v_maxlen - 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 391, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_19 = NULL;
          __pyx_t_15 = 0;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
            __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_11);
            if (likely(__pyx_t_19)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
              __Pyx_INCREF(__pyx_t_19);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_11, function);
              __pyx_t_15 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_11)) {
            PyObject *__pyx_temp[3] = {__pyx_t_19, __pyx_int_0, __pyx_t_3};
            __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 391, __pyx_L7_error)
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
            PyObject *__pyx_temp[3] = {__pyx_t_19, __pyx_int_0, __pyx_t_3};
            __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 391, __pyx_L7_error)
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          } else
          #endif
          {
            __pyx_t_17 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 391, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_17);
            if (__pyx_t_19) {
              __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_19); __pyx_t_19 = NULL;
            }
            __Pyx_INCREF(__pyx_int_0);
            __Pyx_GIVEREF(__pyx_int_0);
            PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_15, __pyx_int_0);
            __Pyx_GIVEREF(__pyx_t_3);
            PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_15, __pyx_t_3);
            __pyx_t_3 = 0;
            __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_17, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 391, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __pyx_v_i = __pyx_t_5;
          __pyx_t_5 = 0;

          /* "mars/actors/pool/gevent_pool.pyx":392
 * 
 *             i = random.randint(0, maxlen - 1)
 *             fd = next(itertools.islice(six.iterkeys(self.conn_locks), i, i + 1))             # <<<<<<<<<<<<<<
 *             conn, lock = self.conn_locks[fd]
 *             lock.acquire()
 */
          __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_itertools); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 392, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_islice); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 392, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_six); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 392, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_iterkeys); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 392, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_19);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_conn_locks); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 392, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_1 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_19))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_19);
            if (likely(__pyx_t_1)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_19, function);
            }
          }
          __pyx_t_11 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_19, __pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_19, __pyx_t_3);
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 392, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          __pyx_t_19 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 392, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_19);
          __pyx_t_3 = NULL;
          __pyx_t_15 = 0;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_17))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_17);
            if (likely(__pyx_t_3)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_17, function);
              __pyx_t_15 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_17)) {
            PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_t_11, __pyx_v_i, __pyx_t_19};
            __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_17, __pyx_temp+1-__pyx_t_15, 3+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 392, __pyx_L7_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_17)) {
            PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_t_11, __pyx_v_i, __pyx_t_19};
            __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_17, __pyx_temp+1-__pyx_t_15, 3+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 392, __pyx_L7_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          } else
          #endif
          {
            __pyx_t_1 = PyTuple_New(3+__pyx_t_15); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 392, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_1);
            if (__pyx_t_3) {
              __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __pyx_t_3 = NULL;
            }
            __Pyx_GIVEREF(__pyx_t_11);
            PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_15, __pyx_t_11);
            __Pyx_INCREF(__pyx_v_i);
            __Pyx_GIVEREF(__pyx_v_i);
            PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_15, __pyx_v_i);
            __Pyx_GIVEREF(__pyx_t_19);
            PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_15, __pyx_t_19);
            __pyx_t_11 = 0;
            __pyx_t_19 = 0;
            __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 392, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          }
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __pyx_t_17 = __Pyx_PyIter_Next(__pyx_t_5); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 392, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_v_fd = __pyx_t_17;
          __pyx_t_17 = 0;

          /* "mars/actors/pool/gevent_pool.pyx":393
 *             i = random.randint(0, maxlen - 1)
 *             fd = next(itertools.islice(six.iterkeys(self.conn_locks), i, i + 1))
 *             conn, lock = self.conn_locks[fd]             # <<<<<<<<<<<<<<
 *             lock.acquire()
 * 
 */
          __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_conn_locks); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 393, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_17, __pyx_v_fd); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 393, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
            PyObject* sequence = __pyx_t_5;
            Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
            if (unlikely(size != 2)) {
              if (size > 2) __Pyx_RaiseTooManyValuesError(2);
              else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
              __PYX_ERR(0, 393, __pyx_L7_error)
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            if (likely(PyTuple_CheckExact(sequence))) {
              __pyx_t_17 = PyTuple_GET_ITEM(sequence, 0); 
              __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
            } else {
              __pyx_t_17 = PyList_GET_ITEM(sequence, 0); 
              __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
            }
            __Pyx_INCREF(__pyx_t_17);
            __Pyx_INCREF(__pyx_t_1);
            #else
            __pyx_t_17 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 393, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_17);
            __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 393, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_1);
            #endif
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          } else {
            Py_ssize_t index = -1;
            __pyx_t_19 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 393, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_19);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_12 = Py_TYPE(__pyx_t_19)->tp_iternext;
            index = 0; __pyx_t_17 = __pyx_t_12(__pyx_t_19); if (unlikely(!__pyx_t_17)) goto __pyx_L23_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_17);
            index = 1; __pyx_t_1 = __pyx_t_12(__pyx_t_19); if (unlikely(!__pyx_t_1)) goto __pyx_L23_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_1);
            if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_19), 2) < 0) __PYX_ERR(0, 393, __pyx_L7_error)
            __pyx_t_12 = NULL;
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            goto __pyx_L24_unpacking_done;
            __pyx_L23_unpacking_failed:;
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            __pyx_t_12 = NULL;
            if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
            __PYX_ERR(0, 393, __pyx_L7_error)
            __pyx_L24_unpacking_done:;
          }
          __Pyx_XDECREF_SET(__pyx_v_conn, __pyx_t_17);
          __pyx_t_17 = 0;
          __Pyx_XDECREF_SET(__pyx_v_lock, __pyx_t_1);
          __pyx_t_1 = 0;

          /* "mars/actors/pool/gevent_pool.pyx":394
 *             fd = next(itertools.islice(six.iterkeys(self.conn_locks), i, i + 1))
 *             conn, lock = self.conn_locks[fd]
 *             lock.acquire()             # <<<<<<<<<<<<<<
 * 
 *             # wait for conn finished
 */
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_lock, __pyx_n_s_acquire); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 394, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_17 = NULL;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_1);
            if (likely(__pyx_t_17)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_17);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_1, function);
            }
          }
          __pyx_t_5 = (__pyx_t_17) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_17) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 394, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "mars/actors/pool/gevent_pool.pyx":397
 * 
 *             # wait for conn finished
 *             gevent.joinall(ps)             # <<<<<<<<<<<<<<
 *             self.conn_locks = OrderedDict(itertools.islice(six.iteritems(self.conn_locks), maxlen))
 * 
 */
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 397, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_joinall); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 397, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_17))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_17);
            if (likely(__pyx_t_1)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_17, function);
            }
          }
          __pyx_t_5 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_17, __pyx_t_1, __pyx_v_ps) : __Pyx_PyObject_CallOneArg(__pyx_t_17, __pyx_v_ps);
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 397, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "mars/actors/pool/gevent_pool.pyx":398
 *             # wait for conn finished
 *             gevent.joinall(ps)
 *             self.conn_locks = OrderedDict(itertools.islice(six.iteritems(self.conn_locks), maxlen))             # <<<<<<<<<<<<<<
 * 
 *             return self._connect(conn, lock)
 */
          __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 398, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_n_s_itertools); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 398, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_19);
          __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_n_s_islice); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 398, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_six); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 398, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_iteritems); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __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_conn_locks); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 398, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_18 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_4);
            if (likely(__pyx_t_18)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_18);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_4, function);
            }
          }
          __pyx_t_19 = (__pyx_t_18) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_18, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 398, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_19);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_maxlen); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_3 = NULL;
          __pyx_t_15 = 0;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_11);
            if (likely(__pyx_t_3)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_11, function);
              __pyx_t_15 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_11)) {
            PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_19, __pyx_t_4};
            __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __pyx_L7_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
            PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_19, __pyx_t_4};
            __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __pyx_L7_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          } else
          #endif
          {
            __pyx_t_18 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 398, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_18);
            if (__pyx_t_3) {
              __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_3); __pyx_t_3 = NULL;
            }
            __Pyx_GIVEREF(__pyx_t_19);
            PyTuple_SET_ITEM(__pyx_t_18, 0+__pyx_t_15, __pyx_t_19);
            __Pyx_GIVEREF(__pyx_t_4);
            PyTuple_SET_ITEM(__pyx_t_18, 1+__pyx_t_15, __pyx_t_4);
            __pyx_t_19 = 0;
            __pyx_t_4 = 0;
            __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_18, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __pyx_t_11 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_17))) {
            __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_17);
            if (likely(__pyx_t_11)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
              __Pyx_INCREF(__pyx_t_11);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_17, function);
            }
          }
          __pyx_t_5 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_17, __pyx_t_11, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_17, __pyx_t_1);
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 398, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_conn_locks, __pyx_t_5) < 0) __PYX_ERR(0, 398, __pyx_L7_error)
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "mars/actors/pool/gevent_pool.pyx":400
 *             self.conn_locks = OrderedDict(itertools.islice(six.iteritems(self.conn_locks), maxlen))
 * 
 *             return self._connect(conn, lock)             # <<<<<<<<<<<<<<
 * 
 *     def __del__(self):
 */
          __Pyx_XDECREF(__pyx_r);
          __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_connect); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 400, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_1 = NULL;
          __pyx_t_15 = 0;
          if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_17))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_17);
            if (likely(__pyx_t_1)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_17, function);
              __pyx_t_15 = 1;
            }
          }
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_17)) {
            PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_conn, __pyx_v_lock};
            __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_17, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 400, __pyx_L7_error)
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_GOTREF(__pyx_t_5);
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_17)) {
            PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_conn, __pyx_v_lock};
            __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_17, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 400, __pyx_L7_error)
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_GOTREF(__pyx_t_5);
          } else
          #endif
          {
            __pyx_t_11 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 400, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_11);
            if (__pyx_t_1) {
              __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __pyx_t_1 = NULL;
            }
            __Pyx_INCREF(__pyx_v_conn);
            __Pyx_GIVEREF(__pyx_v_conn);
            PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_15, __pyx_v_conn);
            __Pyx_INCREF(__pyx_v_lock);
            __Pyx_GIVEREF(__pyx_v_lock);
            PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_15, __pyx_v_lock);
            __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 400, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          }
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __pyx_r = __pyx_t_5;
          __pyx_t_5 = 0;
          goto __pyx_L11_try_return;

          /* "mars/actors/pool/gevent_pool.pyx":365
 *         cdef object lock
 * 
 *         with self.lock:             # <<<<<<<<<<<<<<
 *             for conn, lock in six.itervalues(self.conn_locks):
 *                 # try to reuse the connections before
 */
        }
        __pyx_L7_error:;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        /*except:*/ {
          __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Connections.connect", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_17, &__pyx_t_11) < 0) __PYX_ERR(0, 365, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_1 = PyTuple_Pack(3, __pyx_t_5, __pyx_t_17, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 365, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_20);
          __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_20);
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          if (__pyx_t_14 < 0) __PYX_ERR(0, 365, __pyx_L9_except_error)
          __pyx_t_13 = ((!(__pyx_t_14 != 0)) != 0);
          if (__pyx_t_13) {
            __Pyx_GIVEREF(__pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_ErrRestoreWithState(__pyx_t_5, __pyx_t_17, __pyx_t_11);
            __pyx_t_5 = 0; __pyx_t_17 = 0; __pyx_t_11 = 0; 
            __PYX_ERR(0, 365, __pyx_L9_except_error)
          }
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 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);
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_2) {
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple_, NULL);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 365, __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_, NULL);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 365, __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_L28;
    __pyx_L3_error:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L1_error;
    __pyx_L28:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":360
 *         del self.conn_locks[fd]
 * 
 *     def connect(self):             # <<<<<<<<<<<<<<
 *         cdef int maxlen
 *         cdef object conn
 */

  /* 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_11);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Connections.connect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_conn);
  __Pyx_XDECREF(__pyx_v_lock);
  __Pyx_XDECREF(__pyx_v_locked);
  __Pyx_XDECREF(__pyx_v_close);
  __Pyx_XDECREF(__pyx_v_ps);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_fd);
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XDECREF(__pyx_v_l);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":402
 *             return self._connect(conn, lock)
 * 
 *     def __del__(self):             # <<<<<<<<<<<<<<
 *         for c, _ in self.conn_locks.values():
 *             try:
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_11__del__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_11Connections_11__del__ = {"__del__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_11__del__, METH_O, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11Connections_11__del__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_10__del__(__pyx_self, ((PyObject *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11Connections_10__del__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_c = 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;
  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;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("__del__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":403
 * 
 *     def __del__(self):
 *         for c, _ in self.conn_locks.values():             # <<<<<<<<<<<<<<
 *             try:
 *                 c.close()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_conn_locks); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 403, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 403, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 403, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 403, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 403, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 403, __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;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 403, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 403, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 403, __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_ERR(0, 403, __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_2 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      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_ERR(0, 403, __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_ERR(0, 403, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_2);
    __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":404
 *     def __del__(self):
 *         for c, _ in self.conn_locks.values():
 *             try:             # <<<<<<<<<<<<<<
 *                 c.close()
 *             except:
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __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:*/ {

        /* "mars/actors/pool/gevent_pool.pyx":405
 *         for c, _ in self.conn_locks.values():
 *             try:
 *                 c.close()             # <<<<<<<<<<<<<<
 *             except:
 *                 pass
 */
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_close); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 405, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_2 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_2)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_2);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
          }
        }
        __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 405, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "mars/actors/pool/gevent_pool.pyx":404
 *     def __del__(self):
 *         for c, _ in self.conn_locks.values():
 *             try:             # <<<<<<<<<<<<<<
 *                 c.close()
 *             except:
 */
      }
      __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_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":406
 *             try:
 *                 c.close()
 *             except:             # <<<<<<<<<<<<<<
 *                 pass
 * 
 */
      /*except:*/ {
        __Pyx_ErrRestore(0,0,0);
        goto __pyx_L8_exception_handled;
      }
      __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:;
    }

    /* "mars/actors/pool/gevent_pool.pyx":403
 * 
 *     def __del__(self):
 *         for c, _ in self.conn_locks.values():             # <<<<<<<<<<<<<<
 *             try:
 *                 c.close()
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":402
 *             return self._connect(conn, lock)
 * 
 *     def __del__(self):             # <<<<<<<<<<<<<<
 *         for c, _ in self.conn_locks.values():
 *             try:
 */

  /* 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_AddTraceback("mars.actors.pool.gevent_pool.Connections.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":424
 *     cdef object _lock
 * 
 *     def __init__(self, parallel=None):             # <<<<<<<<<<<<<<
 *         self._parallel = parallel if parallel is not None else REMOTE_DEFAULT_PARALLEL
 *         self._pool = gevent.pool.Pool(self._parallel)
 */

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_parallel = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_parallel,0};
    PyObject* values[1] = {0};
    values[0] = ((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  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_parallel);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 424, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_parallel = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 424, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper___init__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)__pyx_v_self), __pyx_v_parallel);

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, PyObject *__pyx_v_parallel) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":425
 * 
 *     def __init__(self, parallel=None):
 *         self._parallel = parallel if parallel is not None else REMOTE_DEFAULT_PARALLEL             # <<<<<<<<<<<<<<
 *         self._pool = gevent.pool.Pool(self._parallel)
 *         self._connections = dict()
 */
  __pyx_t_2 = (__pyx_v_parallel != Py_None);
  if ((__pyx_t_2 != 0)) {
    __Pyx_INCREF(__pyx_v_parallel);
    __pyx_t_1 = __pyx_v_parallel;
  } else {
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_4mars_6actors_4pool_11gevent_pool_REMOTE_DEFAULT_PARALLEL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 425, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_parallel);
  __Pyx_DECREF(__pyx_v_self->_parallel);
  __pyx_v_self->_parallel = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":426
 *     def __init__(self, parallel=None):
 *         self._parallel = parallel if parallel is not None else REMOTE_DEFAULT_PARALLEL
 *         self._pool = gevent.pool.Pool(self._parallel)             # <<<<<<<<<<<<<<
 *         self._connections = dict()
 *         self._lock = gevent.lock.RLock()
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_gevent); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_pool); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_Pool); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_self->_parallel) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->_parallel);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 426, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_pool);
  __Pyx_DECREF(__pyx_v_self->_pool);
  __pyx_v_self->_pool = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":427
 *         self._parallel = parallel if parallel is not None else REMOTE_DEFAULT_PARALLEL
 *         self._pool = gevent.pool.Pool(self._parallel)
 *         self._connections = dict()             # <<<<<<<<<<<<<<
 *         self._lock = gevent.lock.RLock()
 * 
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_connections);
  __Pyx_DECREF(__pyx_v_self->_connections);
  __pyx_v_self->_connections = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":428
 *         self._pool = gevent.pool.Pool(self._parallel)
 *         self._connections = dict()
 *         self._lock = gevent.lock.RLock()             # <<<<<<<<<<<<<<
 * 
 *     cdef object _new_connection(self, str address):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_gevent); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_lock); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_RLock); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_lock);
  __Pyx_DECREF(__pyx_v_self->_lock);
  __pyx_v_self->_lock = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":424
 *     cdef object _lock
 * 
 *     def __init__(self, parallel=None):             # <<<<<<<<<<<<<<
 *         self._parallel = parallel if parallel is not None else REMOTE_DEFAULT_PARALLEL
 *         self._pool = gevent.pool.Pool(self._parallel)
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":430
 *         self._lock = gevent.lock.RLock()
 * 
 *     cdef object _new_connection(self, str address):             # <<<<<<<<<<<<<<
 *         with self._lock:
 *             if address not in self._connections:
 */

static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__new_connection(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, PyObject *__pyx_v_address) {
  PyObject *__pyx_v_connections = 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;
  int __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("_new_connection", 0);

  /* "mars/actors/pool/gevent_pool.pyx":431
 * 
 *     cdef object _new_connection(self, str address):
 *         with self._lock:             # <<<<<<<<<<<<<<
 *             if address not in self._connections:
 *                 connections = Connections(address)
 */
  /*with:*/ {
    __pyx_t_1 = __Pyx_PyObject_LookupSpecial(__pyx_v_self->_lock, __pyx_n_s_exit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 431, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_v_self->_lock, __pyx_n_s_enter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 431, __pyx_L3_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && 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_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 431, __pyx_L3_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    /*try:*/ {
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_5);
        __Pyx_XGOTREF(__pyx_t_6);
        __Pyx_XGOTREF(__pyx_t_7);
        /*try:*/ {

          /* "mars/actors/pool/gevent_pool.pyx":432
 *     cdef object _new_connection(self, str address):
 *         with self._lock:
 *             if address not in self._connections:             # <<<<<<<<<<<<<<
 *                 connections = Connections(address)
 *                 self._connections[address] = connections
 */
          if (unlikely(__pyx_v_self->_connections == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
            __PYX_ERR(0, 432, __pyx_L7_error)
          }
          __pyx_t_8 = (__Pyx_PyDict_ContainsTF(__pyx_v_address, __pyx_v_self->_connections, Py_NE)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 432, __pyx_L7_error)
          __pyx_t_9 = (__pyx_t_8 != 0);
          if (__pyx_t_9) {

            /* "mars/actors/pool/gevent_pool.pyx":433
 *         with self._lock:
 *             if address not in self._connections:
 *                 connections = Connections(address)             # <<<<<<<<<<<<<<
 *                 self._connections[address] = connections
 * 
 */
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Connections); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 433, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_4 = NULL;
            if (CYTHON_UNPACK_METHODS && 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);
              }
            }
            __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_address) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_address);
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 433, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_v_connections = __pyx_t_2;
            __pyx_t_2 = 0;

            /* "mars/actors/pool/gevent_pool.pyx":434
 *             if address not in self._connections:
 *                 connections = Connections(address)
 *                 self._connections[address] = connections             # <<<<<<<<<<<<<<
 * 
 *             return self._connections[address].connect()
 */
            if (unlikely(__pyx_v_self->_connections == Py_None)) {
              PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
              __PYX_ERR(0, 434, __pyx_L7_error)
            }
            if (unlikely(PyDict_SetItem(__pyx_v_self->_connections, __pyx_v_address, __pyx_v_connections) < 0)) __PYX_ERR(0, 434, __pyx_L7_error)

            /* "mars/actors/pool/gevent_pool.pyx":432
 *     cdef object _new_connection(self, str address):
 *         with self._lock:
 *             if address not in self._connections:             # <<<<<<<<<<<<<<
 *                 connections = Connections(address)
 *                 self._connections[address] = connections
 */
          }

          /* "mars/actors/pool/gevent_pool.pyx":436
 *                 self._connections[address] = connections
 * 
 *             return self._connections[address].connect()             # <<<<<<<<<<<<<<
 * 
 *     cpdef object _send_remote(self, str address, object binary):
 */
          __Pyx_XDECREF(__pyx_r);
          if (unlikely(__pyx_v_self->_connections == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 436, __pyx_L7_error)
          }
          __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_self->_connections, __pyx_v_address); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 436, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_connect_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 436, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = NULL;
          if (CYTHON_UNPACK_METHODS && 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);
            }
          }
          __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 436, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_r = __pyx_t_2;
          __pyx_t_2 = 0;
          goto __pyx_L11_try_return;

          /* "mars/actors/pool/gevent_pool.pyx":431
 * 
 *     cdef object _new_connection(self, str address):
 *         with self._lock:             # <<<<<<<<<<<<<<
 *             if address not in self._connections:
 *                 connections = Connections(address)
 */
        }
        __pyx_L7_error:;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        /*except:*/ {
          __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper._new_connection", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_4, &__pyx_t_3) < 0) __PYX_ERR(0, 431, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_10 = PyTuple_Pack(3, __pyx_t_2, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 431, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 431, __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_ERR(0, 431, __pyx_L9_except_error)
          __pyx_t_8 = ((!(__pyx_t_9 != 0)) != 0);
          if (__pyx_t_8) {
            __Pyx_GIVEREF(__pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_4);
            __Pyx_XGIVEREF(__pyx_t_3);
            __Pyx_ErrRestoreWithState(__pyx_t_2, __pyx_t_4, __pyx_t_3);
            __pyx_t_2 = 0; __pyx_t_4 = 0; __pyx_t_3 = 0; 
            __PYX_ERR(0, 431, __pyx_L9_except_error)
          }
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          goto __pyx_L8_exception_handled;
        }
        __pyx_L9_except_error:;
        __Pyx_XGIVEREF(__pyx_t_5);
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
        goto __pyx_L1_error;
        __pyx_L11_try_return:;
        __Pyx_XGIVEREF(__pyx_t_5);
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
        goto __pyx_L4_return;
        __pyx_L8_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_5);
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_1) {
          __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple_, NULL);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 431, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        }
        goto __pyx_L6;
      }
      __pyx_L4_return: {
        __pyx_t_7 = __pyx_r;
        __pyx_r = 0;
        if (__pyx_t_1) {
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple_, NULL);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 431, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __pyx_r = __pyx_t_7;
        __pyx_t_7 = 0;
        goto __pyx_L0;
      }
      __pyx_L6:;
    }
    goto __pyx_L17;
    __pyx_L3_error:;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L1_error;
    __pyx_L17:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":430
 *         self._lock = gevent.lock.RLock()
 * 
 *     cdef object _new_connection(self, str address):             # <<<<<<<<<<<<<<
 *         with self._lock:
 *             if address not in self._connections:
 */

  /* 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_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper._new_connection", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_connections);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":438
 *             return self._connections[address].connect()
 * 
 *     cpdef object _send_remote(self, str address, object binary):             # <<<<<<<<<<<<<<
 *         cdef bytes res_binary
 *         cdef object message_type
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_3_send_remote(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__send_remote(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, PyObject *__pyx_v_address, PyObject *__pyx_v_binary, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_res_binary = 0;
  PyObject *__pyx_v_message_type = 0;
  PyObject *__pyx_v_sock = NULL;
  PyObject *__pyx_v_error_message = NULL;
  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;
  int __pyx_t_5;
  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;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  __Pyx_RefNannySetupContext("_send_remote", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send_remote); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_3_send_remote)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && 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);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_address, __pyx_v_binary};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 438, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_address, __pyx_v_binary};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 438, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 438, __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_address);
          __Pyx_GIVEREF(__pyx_v_address);
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_address);
          __Pyx_INCREF(__pyx_v_binary);
          __Pyx_GIVEREF(__pyx_v_binary);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_binary);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 438, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":442
 *         cdef object message_type
 * 
 *         with self._new_connection(address) as sock:             # <<<<<<<<<<<<<<
 *             try:
 *                 write_remote_message(sock.sendall, *binary)
 */
  /*with:*/ {
    __pyx_t_1 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)__pyx_v_self->__pyx_vtab)->_new_connection(__pyx_v_self, __pyx_v_address); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 442, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 442, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 442, __pyx_L3_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 442, __pyx_L3_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __pyx_t_2;
    __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    /*try:*/ {
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __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:*/ {
          __pyx_v_sock = __pyx_t_3;
          __pyx_t_3 = 0;

          /* "mars/actors/pool/gevent_pool.pyx":443
 * 
 *         with self._new_connection(address) as sock:
 *             try:             # <<<<<<<<<<<<<<
 *                 write_remote_message(sock.sendall, *binary)
 *                 res_binary = read_remote_message(sock.recv)
 */
          {
            __Pyx_PyThreadState_declare
            __Pyx_PyThreadState_assign
            __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_13);
            /*try:*/ {

              /* "mars/actors/pool/gevent_pool.pyx":444
 *         with self._new_connection(address) as sock:
 *             try:
 *                 write_remote_message(sock.sendall, *binary)             # <<<<<<<<<<<<<<
 *                 res_binary = read_remote_message(sock.recv)
 *                 message_type = unpack_message_type(res_binary)
 */
              __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_write_remote_message); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 444, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sock, __pyx_n_s_sendall); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 444, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 444, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_GIVEREF(__pyx_t_1);
              PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
              __pyx_t_1 = 0;
              __pyx_t_1 = __Pyx_PySequence_Tuple(__pyx_v_binary); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 444, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_6 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 444, __pyx_L13_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_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 444, __pyx_L13_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_DECREF(__pyx_t_1); __pyx_t_1 = 0;

              /* "mars/actors/pool/gevent_pool.pyx":445
 *             try:
 *                 write_remote_message(sock.sendall, *binary)
 *                 res_binary = read_remote_message(sock.recv)             # <<<<<<<<<<<<<<
 *                 message_type = unpack_message_type(res_binary)
 *                 if message_type == MessageType.error:
 */
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sock, __pyx_n_s_recv); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 445, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_6 = __pyx_f_4mars_6actors_4pool_8messages_read_remote_message(__pyx_t_1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 445, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __pyx_v_res_binary = ((PyObject*)__pyx_t_6);
              __pyx_t_6 = 0;

              /* "mars/actors/pool/gevent_pool.pyx":446
 *                 write_remote_message(sock.sendall, *binary)
 *                 res_binary = read_remote_message(sock.recv)
 *                 message_type = unpack_message_type(res_binary)             # <<<<<<<<<<<<<<
 *                 if message_type == MessageType.error:
 *                     error_message = unpack_error_message(res_binary)
 */
              __pyx_t_6 = __pyx_f_4mars_6actors_4pool_8messages_unpack_message_type(__pyx_v_res_binary, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 446, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_v_message_type = __pyx_t_6;
              __pyx_t_6 = 0;

              /* "mars/actors/pool/gevent_pool.pyx":447
 *                 res_binary = read_remote_message(sock.recv)
 *                 message_type = unpack_message_type(res_binary)
 *                 if message_type == MessageType.error:             # <<<<<<<<<<<<<<
 *                     error_message = unpack_error_message(res_binary)
 *                     six.reraise(error_message.error_type, error_message.error, error_message.traceback)
 */
              __pyx_t_6 = __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(__pyx_e_4mars_6actors_4pool_8messages_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 447, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_1 = PyObject_RichCompare(__pyx_v_message_type, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 447, __pyx_L13_error)
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 447, __pyx_L13_error)
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (__pyx_t_14) {

                /* "mars/actors/pool/gevent_pool.pyx":448
 *                 message_type = unpack_message_type(res_binary)
 *                 if message_type == MessageType.error:
 *                     error_message = unpack_error_message(res_binary)             # <<<<<<<<<<<<<<
 *                     six.reraise(error_message.error_type, error_message.error, error_message.traceback)
 *                 else:
 */
                __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_unpack_error_message(__pyx_v_res_binary, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 448, __pyx_L13_error)
                __Pyx_GOTREF(__pyx_t_1);
                __pyx_v_error_message = __pyx_t_1;
                __pyx_t_1 = 0;

                /* "mars/actors/pool/gevent_pool.pyx":449
 *                 if message_type == MessageType.error:
 *                     error_message = unpack_error_message(res_binary)
 *                     six.reraise(error_message.error_type, error_message.error, error_message.traceback)             # <<<<<<<<<<<<<<
 *                 else:
 *                     assert message_type == MessageType.result
 */
                __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_six); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 449, __pyx_L13_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_reraise); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 449, __pyx_L13_error)
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_error_message, __pyx_n_s_error_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 449, __pyx_L13_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_error_message, __pyx_n_s_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 449, __pyx_L13_error)
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_error_message, __pyx_n_s_traceback); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 449, __pyx_L13_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_15 = NULL;
                __pyx_t_5 = 0;
                if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
                  __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_3);
                  if (likely(__pyx_t_15)) {
                    PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
                    __Pyx_INCREF(__pyx_t_15);
                    __Pyx_INCREF(function);
                    __Pyx_DECREF_SET(__pyx_t_3, function);
                    __pyx_t_5 = 1;
                  }
                }
                #if CYTHON_FAST_PYCALL
                if (PyFunction_Check(__pyx_t_3)) {
                  PyObject *__pyx_temp[4] = {__pyx_t_15, __pyx_t_6, __pyx_t_2, __pyx_t_4};
                  __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L13_error)
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __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_4); __pyx_t_4 = 0;
                } else
                #endif
                #if CYTHON_FAST_PYCCALL
                if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
                  PyObject *__pyx_temp[4] = {__pyx_t_15, __pyx_t_6, __pyx_t_2, __pyx_t_4};
                  __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L13_error)
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __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_4); __pyx_t_4 = 0;
                } else
                #endif
                {
                  __pyx_t_16 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 449, __pyx_L13_error)
                  __Pyx_GOTREF(__pyx_t_16);
                  if (__pyx_t_15) {
                    __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_15); __pyx_t_15 = NULL;
                  }
                  __Pyx_GIVEREF(__pyx_t_6);
                  PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_5, __pyx_t_6);
                  __Pyx_GIVEREF(__pyx_t_2);
                  PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_5, __pyx_t_2);
                  __Pyx_GIVEREF(__pyx_t_4);
                  PyTuple_SET_ITEM(__pyx_t_16, 2+__pyx_t_5, __pyx_t_4);
                  __pyx_t_6 = 0;
                  __pyx_t_2 = 0;
                  __pyx_t_4 = 0;
                  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_16, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 449, __pyx_L13_error)
                  __Pyx_GOTREF(__pyx_t_1);
                  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                }
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                /* "mars/actors/pool/gevent_pool.pyx":447
 *                 res_binary = read_remote_message(sock.recv)
 *                 message_type = unpack_message_type(res_binary)
 *                 if message_type == MessageType.error:             # <<<<<<<<<<<<<<
 *                     error_message = unpack_error_message(res_binary)
 *                     six.reraise(error_message.error_type, error_message.error, error_message.traceback)
 */
                goto __pyx_L19;
              }

              /* "mars/actors/pool/gevent_pool.pyx":451
 *                     six.reraise(error_message.error_type, error_message.error, error_message.traceback)
 *                 else:
 *                     assert message_type == MessageType.result             # <<<<<<<<<<<<<<
 *                     return unpack_result_message(res_binary).result
 *             except BrokenPipeError:
 */
              /*else*/ {
                #ifndef CYTHON_WITHOUT_ASSERTIONS
                if (unlikely(!Py_OptimizeFlag)) {
                  __pyx_t_1 = __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(__pyx_e_4mars_6actors_4pool_8messages_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 451, __pyx_L13_error)
                  __Pyx_GOTREF(__pyx_t_1);
                  __pyx_t_3 = PyObject_RichCompare(__pyx_v_message_type, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 451, __pyx_L13_error)
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                  __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 451, __pyx_L13_error)
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  if (unlikely(!__pyx_t_14)) {
                    PyErr_SetNone(PyExc_AssertionError);
                    __PYX_ERR(0, 451, __pyx_L13_error)
                  }
                }
                #endif

                /* "mars/actors/pool/gevent_pool.pyx":452
 *                 else:
 *                     assert message_type == MessageType.result
 *                     return unpack_result_message(res_binary).result             # <<<<<<<<<<<<<<
 *             except BrokenPipeError:
 *                 self._connections[address].got_broken_pipe(sock.fileno())
 */
                __Pyx_XDECREF(__pyx_r);
                __pyx_t_3 = __pyx_f_4mars_6actors_4pool_8messages_unpack_result_message(__pyx_v_res_binary, 0, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 452, __pyx_L13_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 452, __pyx_L13_error)
                __Pyx_GOTREF(__pyx_t_1);
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                __pyx_r = __pyx_t_1;
                __pyx_t_1 = 0;
                goto __pyx_L17_try_return;
              }
              __pyx_L19:;

              /* "mars/actors/pool/gevent_pool.pyx":443
 * 
 *         with self._new_connection(address) as sock:
 *             try:             # <<<<<<<<<<<<<<
 *                 write_remote_message(sock.sendall, *binary)
 *                 res_binary = read_remote_message(sock.recv)
 */
            }
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            goto __pyx_L18_try_end;
            __pyx_L13_error:;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

            /* "mars/actors/pool/gevent_pool.pyx":453
 *                     assert message_type == MessageType.result
 *                     return unpack_result_message(res_binary).result
 *             except BrokenPipeError:             # <<<<<<<<<<<<<<
 *                 self._connections[address].got_broken_pipe(sock.fileno())
 *                 raise
 */
            __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_3, &__pyx_t_16);
            __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_BrokenPipeError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 453, __pyx_L15_except_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_5 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_4);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_ErrRestore(__pyx_t_1, __pyx_t_3, __pyx_t_16);
            __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_16 = 0;
            if (__pyx_t_5) {
              __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper._send_remote", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_16, &__pyx_t_3, &__pyx_t_1) < 0) __PYX_ERR(0, 453, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_16);
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_GOTREF(__pyx_t_1);

              /* "mars/actors/pool/gevent_pool.pyx":454
 *                     return unpack_result_message(res_binary).result
 *             except BrokenPipeError:
 *                 self._connections[address].got_broken_pipe(sock.fileno())             # <<<<<<<<<<<<<<
 *                 raise
 *             except socket.error as exc:
 */
              if (unlikely(__pyx_v_self->_connections == Py_None)) {
                PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
                __PYX_ERR(0, 454, __pyx_L15_except_error)
              }
              __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->_connections, __pyx_v_address); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 454, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_got_broken_pipe); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 454, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_sock, __pyx_n_s_fileno); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 454, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_15);
              __pyx_t_17 = NULL;
              if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) {
                __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_15);
                if (likely(__pyx_t_17)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
                  __Pyx_INCREF(__pyx_t_17);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_15, function);
                }
              }
              __pyx_t_2 = (__pyx_t_17) ? __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_17) : __Pyx_PyObject_CallNoArg(__pyx_t_15);
              __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 454, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __pyx_t_15 = NULL;
              if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
                __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6);
                if (likely(__pyx_t_15)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
                  __Pyx_INCREF(__pyx_t_15);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_6, function);
                }
              }
              __pyx_t_4 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_15, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_2);
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 454, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

              /* "mars/actors/pool/gevent_pool.pyx":455
 *             except BrokenPipeError:
 *                 self._connections[address].got_broken_pipe(sock.fileno())
 *                 raise             # <<<<<<<<<<<<<<
 *             except socket.error as exc:
 *                 if exc.errno == errno.EPIPE:
 */
              __Pyx_GIVEREF(__pyx_t_16);
              __Pyx_GIVEREF(__pyx_t_3);
              __Pyx_XGIVEREF(__pyx_t_1);
              __Pyx_ErrRestoreWithState(__pyx_t_16, __pyx_t_3, __pyx_t_1);
              __pyx_t_16 = 0; __pyx_t_3 = 0; __pyx_t_1 = 0; 
              __PYX_ERR(0, 455, __pyx_L15_except_error)
            }

            /* "mars/actors/pool/gevent_pool.pyx":456
 *                 self._connections[address].got_broken_pipe(sock.fileno())
 *                 raise
 *             except socket.error as exc:             # <<<<<<<<<<<<<<
 *                 if exc.errno == errno.EPIPE:
 *                     self._connections[address].got_broken_pipe(sock.fileno())
 */
            __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_3, &__pyx_t_16);
            __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_socket); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 456, __pyx_L15_except_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 456, __pyx_L15_except_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_5 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_6);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_ErrRestore(__pyx_t_1, __pyx_t_3, __pyx_t_16);
            __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_16 = 0;
            if (__pyx_t_5) {
              __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper._send_remote", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_16, &__pyx_t_3, &__pyx_t_1) < 0) __PYX_ERR(0, 456, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_16);
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_3);
              __pyx_v_exc = __pyx_t_3;

              /* "mars/actors/pool/gevent_pool.pyx":457
 *                 raise
 *             except socket.error as exc:
 *                 if exc.errno == errno.EPIPE:             # <<<<<<<<<<<<<<
 *                     self._connections[address].got_broken_pipe(sock.fileno())
 *                 raise
 */
              __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_exc, __pyx_n_s_errno); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 457, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_errno); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 457, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_EPIPE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 457, __pyx_L15_except_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __pyx_t_4 = PyObject_RichCompare(__pyx_t_6, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 457, __pyx_L15_except_error)
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 457, __pyx_L15_except_error)
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (__pyx_t_14) {

                /* "mars/actors/pool/gevent_pool.pyx":458
 *             except socket.error as exc:
 *                 if exc.errno == errno.EPIPE:
 *                     self._connections[address].got_broken_pipe(sock.fileno())             # <<<<<<<<<<<<<<
 *                 raise
 * 
 */
                if (unlikely(__pyx_v_self->_connections == Py_None)) {
                  PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
                  __PYX_ERR(0, 458, __pyx_L15_except_error)
                }
                __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->_connections, __pyx_v_address); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 458, __pyx_L15_except_error)
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_got_broken_pipe); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 458, __pyx_L15_except_error)
                __Pyx_GOTREF(__pyx_t_6);
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_sock, __pyx_n_s_fileno); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 458, __pyx_L15_except_error)
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_17 = NULL;
                if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) {
                  __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_15);
                  if (likely(__pyx_t_17)) {
                    PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
                    __Pyx_INCREF(__pyx_t_17);
                    __Pyx_INCREF(function);
                    __Pyx_DECREF_SET(__pyx_t_15, function);
                  }
                }
                __pyx_t_2 = (__pyx_t_17) ? __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_17) : __Pyx_PyObject_CallNoArg(__pyx_t_15);
                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 458, __pyx_L15_except_error)
                __Pyx_GOTREF(__pyx_t_2);
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                __pyx_t_15 = NULL;
                if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
                  __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6);
                  if (likely(__pyx_t_15)) {
                    PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
                    __Pyx_INCREF(__pyx_t_15);
                    __Pyx_INCREF(function);
                    __Pyx_DECREF_SET(__pyx_t_6, function);
                  }
                }
                __pyx_t_4 = (__pyx_t_15) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_15, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_2);
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 458, __pyx_L15_except_error)
                __Pyx_GOTREF(__pyx_t_4);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                /* "mars/actors/pool/gevent_pool.pyx":457
 *                 raise
 *             except socket.error as exc:
 *                 if exc.errno == errno.EPIPE:             # <<<<<<<<<<<<<<
 *                     self._connections[address].got_broken_pipe(sock.fileno())
 *                 raise
 */
              }

              /* "mars/actors/pool/gevent_pool.pyx":459
 *                 if exc.errno == errno.EPIPE:
 *                     self._connections[address].got_broken_pipe(sock.fileno())
 *                 raise             # <<<<<<<<<<<<<<
 * 
 *     def create_actor(self, str address, object uid, object actor_cls, *args, **kwargs):
 */
              __Pyx_GIVEREF(__pyx_t_16);
              __Pyx_GIVEREF(__pyx_t_3);
              __Pyx_XGIVEREF(__pyx_t_1);
              __Pyx_ErrRestoreWithState(__pyx_t_16, __pyx_t_3, __pyx_t_1);
              __pyx_t_16 = 0; __pyx_t_3 = 0; __pyx_t_1 = 0; 
              __PYX_ERR(0, 459, __pyx_L15_except_error)
            }
            goto __pyx_L15_except_error;
            __pyx_L15_except_error:;

            /* "mars/actors/pool/gevent_pool.pyx":443
 * 
 *         with self._new_connection(address) as sock:
 *             try:             # <<<<<<<<<<<<<<
 *                 write_remote_message(sock.sendall, *binary)
 *                 res_binary = read_remote_message(sock.recv)
 */
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            goto __pyx_L7_error;
            __pyx_L17_try_return:;
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            goto __pyx_L11_try_return;
            __pyx_L18_try_end:;
          }

          /* "mars/actors/pool/gevent_pool.pyx":442
 *         cdef object message_type
 * 
 *         with self._new_connection(address) as sock:             # <<<<<<<<<<<<<<
 *             try:
 *                 write_remote_message(sock.sendall, *binary)
 */
        }
        __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_L7_error:;
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 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_16); __pyx_t_16 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        /*except:*/ {
          __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper._send_remote", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_16) < 0) __PYX_ERR(0, 442, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GOTREF(__pyx_t_16);
          __pyx_t_4 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_3, __pyx_t_16); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 442, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_4, NULL);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 442, __pyx_L9_except_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (__pyx_t_14 < 0) __PYX_ERR(0, 442, __pyx_L9_except_error)
          __pyx_t_18 = ((!(__pyx_t_14 != 0)) != 0);
          if (__pyx_t_18) {
            __Pyx_GIVEREF(__pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_3);
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_3, __pyx_t_16);
            __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_16 = 0; 
            __PYX_ERR(0, 442, __pyx_L9_except_error)
          }
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          goto __pyx_L8_exception_handled;
        }
        __pyx_L9_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_L11_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_L4_return;
        __pyx_L8_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:;
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_7) {
          __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple_, NULL);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 442, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
        goto __pyx_L6;
      }
      __pyx_L4_return: {
        __pyx_t_10 = __pyx_r;
        __pyx_r = 0;
        if (__pyx_t_7) {
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple_, NULL);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 442, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
        __pyx_r = __pyx_t_10;
        __pyx_t_10 = 0;
        goto __pyx_L0;
      }
      __pyx_L6:;
    }
    goto __pyx_L28;
    __pyx_L3_error:;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L1_error;
    __pyx_L28:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":438
 *             return self._connections[address].connect()
 * 
 *     cpdef object _send_remote(self, str address, object binary):             # <<<<<<<<<<<<<<
 *         cdef bytes res_binary
 *         cdef object message_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_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper._send_remote", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_res_binary);
  __Pyx_XDECREF(__pyx_v_message_type);
  __Pyx_XDECREF(__pyx_v_sock);
  __Pyx_XDECREF(__pyx_v_error_message);
  __Pyx_XDECREF(__pyx_v_exc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_3_send_remote(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_3_send_remote(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_address = 0;
  PyObject *__pyx_v_binary = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_send_remote (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_address,&__pyx_n_s_binary,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_address)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_binary)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_send_remote", 1, 2, 2, 1); __PYX_ERR(0, 438, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_send_remote") < 0)) __PYX_ERR(0, 438, __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_address = ((PyObject*)values[0]);
    __pyx_v_binary = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_send_remote", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 438, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper._send_remote", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_address), (&PyString_Type), 1, "address", 1))) __PYX_ERR(0, 438, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_2_send_remote(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)__pyx_v_self), __pyx_v_address, __pyx_v_binary);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_2_send_remote(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, PyObject *__pyx_v_address, PyObject *__pyx_v_binary) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_send_remote", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__send_remote(__pyx_v_self, __pyx_v_address, __pyx_v_binary, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper._send_remote", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":461
 *                 raise
 * 
 *     def create_actor(self, str address, object uid, object actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef bint wait
 *         cdef object callback
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_5create_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_5create_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_address = 0;
  PyObject *__pyx_v_uid = 0;
  PyObject *__pyx_v_actor_cls = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_actor (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_address,&__pyx_n_s_uid,&__pyx_n_s_actor_cls,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_address)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_uid)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_actor", 0, 3, 3, 1); __PYX_ERR(0, 461, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_cls)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_actor", 0, 3, 3, 2); __PYX_ERR(0, 461, __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, "create_actor") < 0)) __PYX_ERR(0, 461, __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_address = ((PyObject*)values[0]);
    __pyx_v_uid = values[1];
    __pyx_v_actor_cls = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_actor", 0, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 461, __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("mars.actors.pool.gevent_pool.ActorRemoteHelper.create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_address), (&PyString_Type), 1, "address", 1))) __PYX_ERR(0, 461, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_4create_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)__pyx_v_self), __pyx_v_address, __pyx_v_uid, __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":486
 *         future = gevent.event.AsyncResult()
 * 
 *         def on_success(g):             # <<<<<<<<<<<<<<
 *             actor_ref = g.value
 *             actor_ref.ctx = ActorContext(self)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12create_actor_1on_success(PyObject *__pyx_self, PyObject *__pyx_v_g); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12create_actor_1on_success = {"on_success", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12create_actor_1on_success, METH_O, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12create_actor_1on_success(PyObject *__pyx_self, PyObject *__pyx_v_g) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("on_success (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12create_actor_on_success(__pyx_self, ((PyObject *)__pyx_v_g));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12create_actor_on_success(PyObject *__pyx_self, PyObject *__pyx_v_g) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor *__pyx_outer_scope;
  PyObject *__pyx_v_actor_ref = 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;
  __Pyx_RefNannySetupContext("on_success", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":487
 * 
 *         def on_success(g):
 *             actor_ref = g.value             # <<<<<<<<<<<<<<
 *             actor_ref.ctx = ActorContext(self)
 *             if callback:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 487, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_actor_ref = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":488
 *         def on_success(g):
 *             actor_ref = g.value
 *             actor_ref.ctx = ActorContext(self)             # <<<<<<<<<<<<<<
 *             if callback:
 *                 callback(actor_ref)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 488, __pyx_L1_error) }
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext), ((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_actor_ref, __pyx_n_s_ctx, __pyx_t_1) < 0) __PYX_ERR(0, 488, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":489
 *             actor_ref = g.value
 *             actor_ref.ctx = ActorContext(self)
 *             if callback:             # <<<<<<<<<<<<<<
 *                 callback(actor_ref)
 *             future.set_result(actor_ref)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_callback)) { __Pyx_RaiseClosureNameError("callback"); __PYX_ERR(0, 489, __pyx_L1_error) }
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_callback); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 489, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "mars/actors/pool/gevent_pool.pyx":490
 *             actor_ref.ctx = ActorContext(self)
 *             if callback:
 *                 callback(actor_ref)             # <<<<<<<<<<<<<<
 *             future.set_result(actor_ref)
 * 
 */
    if (unlikely(!__pyx_cur_scope->__pyx_v_callback)) { __Pyx_RaiseClosureNameError("callback"); __PYX_ERR(0, 490, __pyx_L1_error) }
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_callback);
    __pyx_t_3 = __pyx_cur_scope->__pyx_v_callback; __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_actor_ref) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_actor_ref);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 490, __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;

    /* "mars/actors/pool/gevent_pool.pyx":489
 *             actor_ref = g.value
 *             actor_ref.ctx = ActorContext(self)
 *             if callback:             # <<<<<<<<<<<<<<
 *                 callback(actor_ref)
 *             future.set_result(actor_ref)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":491
 *             if callback:
 *                 callback(actor_ref)
 *             future.set_result(actor_ref)             # <<<<<<<<<<<<<<
 * 
 *         def on_failure(g):
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_future)) { __Pyx_RaiseClosureNameError("future"); __PYX_ERR(0, 491, __pyx_L1_error) }
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_future, __pyx_n_s_set_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 491, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_actor_ref) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_actor_ref);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 491, __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;

  /* "mars/actors/pool/gevent_pool.pyx":486
 *         future = gevent.event.AsyncResult()
 * 
 *         def on_success(g):             # <<<<<<<<<<<<<<
 *             actor_ref = g.value
 *             actor_ref.ctx = ActorContext(self)
 */

  /* 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_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.create_actor.on_success", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_actor_ref);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":493
 *             future.set_result(actor_ref)
 * 
 *         def on_failure(g):             # <<<<<<<<<<<<<<
 *             try:
 *                 g.get()
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12create_actor_3on_failure(PyObject *__pyx_self, PyObject *__pyx_v_g); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12create_actor_3on_failure = {"on_failure", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12create_actor_3on_failure, METH_O, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12create_actor_3on_failure(PyObject *__pyx_self, PyObject *__pyx_v_g) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("on_failure (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12create_actor_2on_failure(__pyx_self, ((PyObject *)__pyx_v_g));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12create_actor_2on_failure(PyObject *__pyx_self, PyObject *__pyx_v_g) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor *__pyx_outer_scope;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_ex = NULL;
  PyObject *__pyx_v_tb = 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;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *(*__pyx_t_12)(PyObject *);
  __Pyx_RefNannySetupContext("on_failure", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":494
 * 
 *         def on_failure(g):
 *             try:             # <<<<<<<<<<<<<<
 *                 g.get()
 *             except:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __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:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":495
 *         def on_failure(g):
 *             try:
 *                 g.get()             # <<<<<<<<<<<<<<
 *             except:
 *                 t, ex, tb = sys.exc_info()
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 495, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && 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 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 495, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":494
 * 
 *         def on_failure(g):
 *             try:             # <<<<<<<<<<<<<<
 *                 g.get()
 *             except:
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __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;

    /* "mars/actors/pool/gevent_pool.pyx":496
 *             try:
 *                 g.get()
 *             except:             # <<<<<<<<<<<<<<
 *                 t, ex, tb = sys.exc_info()
 *                 future.set_exception(ex, exc_info=(t, ex, tb))
 */
    /*except:*/ {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.create_actor.on_failure", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 496, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_6);

      /* "mars/actors/pool/gevent_pool.pyx":497
 *                 g.get()
 *             except:
 *                 t, ex, tb = sys.exc_info()             # <<<<<<<<<<<<<<
 *                 future.set_exception(ex, exc_info=(t, ex, tb))
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_sys); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 497, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 497, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && 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_7 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_9);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 497, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) {
        PyObject* sequence = __pyx_t_7;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 497, __pyx_L5_except_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_9 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_10 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_10);
        #else
        __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 497, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 497, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 497, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_10);
        #endif
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 497, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_9 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_9)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_9);
        index = 1; __pyx_t_8 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_8)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_8);
        index = 2; __pyx_t_10 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_10);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 3) < 0) __PYX_ERR(0, 497, __pyx_L5_except_error)
        __pyx_t_12 = NULL;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L12_unpacking_done;
        __pyx_L11_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_12 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 497, __pyx_L5_except_error)
        __pyx_L12_unpacking_done:;
      }
      __pyx_v_t = __pyx_t_9;
      __pyx_t_9 = 0;
      __pyx_v_ex = __pyx_t_8;
      __pyx_t_8 = 0;
      __pyx_v_tb = __pyx_t_10;
      __pyx_t_10 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":498
 *             except:
 *                 t, ex, tb = sys.exc_info()
 *                 future.set_exception(ex, exc_info=(t, ex, tb))             # <<<<<<<<<<<<<<
 * 
 *         p = self._pool.apply_async(self._send_remote, (address, binaries))
 */
      if (unlikely(!__pyx_cur_scope->__pyx_v_future)) { __Pyx_RaiseClosureNameError("future"); __PYX_ERR(0, 498, __pyx_L5_except_error) }
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_future, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 498, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 498, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_v_ex);
      __Pyx_GIVEREF(__pyx_v_ex);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_ex);
      __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 498, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 498, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_v_t);
      __Pyx_GIVEREF(__pyx_v_t);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_t);
      __Pyx_INCREF(__pyx_v_ex);
      __Pyx_GIVEREF(__pyx_v_ex);
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_ex);
      __Pyx_INCREF(__pyx_v_tb);
      __Pyx_GIVEREF(__pyx_v_tb);
      PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_v_tb);
      if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_exc_info, __pyx_t_9) < 0) __PYX_ERR(0, 498, __pyx_L5_except_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 498, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":494
 * 
 *         def on_failure(g):
 *             try:             # <<<<<<<<<<<<<<
 *                 g.get()
 *             except:
 */
    __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_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);
    __pyx_L8_try_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":493
 *             future.set_result(actor_ref)
 * 
 *         def on_failure(g):             # <<<<<<<<<<<<<<
 *             try:
 *                 g.get()
 */

  /* 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_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.create_actor.on_failure", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_ex);
  __Pyx_XDECREF(__pyx_v_tb);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":461
 *                 raise
 * 
 *     def create_actor(self, str address, object uid, object actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef bint wait
 *         cdef object callback
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_4create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, PyObject *__pyx_v_address, PyObject *__pyx_v_uid, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor *__pyx_cur_scope;
  int __pyx_v_wait;
  PyObject *__pyx_v_binaries = 0;
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_on_success = 0;
  PyObject *__pyx_v_on_failure = 0;
  PyObject *__pyx_v_p = 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;
  __pyx_t_4mars_6actors_4pool_8messages_INT32_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;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  __Pyx_RefNannySetupContext("create_actor", 0);
  __pyx_cur_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor *)__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor(__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 461, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);

  /* "mars/actors/pool/gevent_pool.pyx":468
 *         cdef object future
 * 
 *         wait = kwargs.pop('wait', True)             # <<<<<<<<<<<<<<
 *         callback = kwargs.pop('callback', None)
 * 
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_wait, Py_True); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_wait = __pyx_t_2;

  /* "mars/actors/pool/gevent_pool.pyx":469
 * 
 *         wait = kwargs.pop('wait', True)
 *         callback = kwargs.pop('callback', None)             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_callback, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 469, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_callback = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":471
 *         callback = kwargs.pop('callback', None)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             binaries = pack_create_actor_message(
 *                 ActorRemoteHelper.index, UNKNOWN_TO_INDEX,
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __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:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":473
 *         try:
 *             binaries = pack_create_actor_message(
 *                 ActorRemoteHelper.index, UNKNOWN_TO_INDEX,             # <<<<<<<<<<<<<<
 *                 ActorRef(address, uid), actor_cls, args, kwargs)[1:]
 *         except (AttributeError, pickle.PickleError):
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper), __pyx_n_s_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 473, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = __Pyx_PyInt_As_npy_int32(__pyx_t_1); if (unlikely((__pyx_t_6 == ((npy_int32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 473, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":474
 *             binaries = pack_create_actor_message(
 *                 ActorRemoteHelper.index, UNKNOWN_TO_INDEX,
 *                 ActorRef(address, uid), actor_cls, args, kwargs)[1:]             # <<<<<<<<<<<<<<
 *         except (AttributeError, pickle.PickleError):
 *             raise pickle.PicklingError('Unable to pickle {0}(*{1}, **{2})'.format(actor_cls, args, kwargs))
 */
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 474, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v_address);
      __Pyx_GIVEREF(__pyx_v_address);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_address);
      __Pyx_INCREF(__pyx_v_uid);
      __Pyx_GIVEREF(__pyx_v_uid);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_uid);
      __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4mars_6actors_4core_ActorRef), __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 474, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":472
 * 
 *         try:
 *             binaries = pack_create_actor_message(             # <<<<<<<<<<<<<<
 *                 ActorRemoteHelper.index, UNKNOWN_TO_INDEX,
 *                 ActorRef(address, uid), actor_cls, args, kwargs)[1:]
 */
      __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_pack_create_actor_message(__pyx_t_6, __pyx_v_4mars_6actors_4pool_11gevent_pool_UNKNOWN_TO_INDEX, ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)__pyx_t_7), __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 472, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":474
 *             binaries = pack_create_actor_message(
 *                 ActorRemoteHelper.index, UNKNOWN_TO_INDEX,
 *                 ActorRef(address, uid), actor_cls, args, kwargs)[1:]             # <<<<<<<<<<<<<<
 *         except (AttributeError, pickle.PickleError):
 *             raise pickle.PicklingError('Unable to pickle {0}(*{1}, **{2})'.format(actor_cls, args, kwargs))
 */
      __pyx_t_7 = __Pyx_PyObject_GetSlice(__pyx_t_1, 1, 0, NULL, NULL, &__pyx_slice__8, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 474, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(PyTuple_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_7)->tp_name), 0))) __PYX_ERR(0, 474, __pyx_L3_error)
      __pyx_v_binaries = ((PyObject*)__pyx_t_7);
      __pyx_t_7 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":471
 *         callback = kwargs.pop('callback', None)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             binaries = pack_create_actor_message(
 *                 ActorRemoteHelper.index, UNKNOWN_TO_INDEX,
 */
    }
    __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_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":475
 *                 ActorRemoteHelper.index, UNKNOWN_TO_INDEX,
 *                 ActorRef(address, uid), actor_cls, args, kwargs)[1:]
 *         except (AttributeError, pickle.PickleError):             # <<<<<<<<<<<<<<
 *             raise pickle.PicklingError('Unable to pickle {0}(*{1}, **{2})'.format(actor_cls, args, kwargs))
 * 
 */
    __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_1, &__pyx_t_8);
    __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_pickle); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 475, __pyx_L5_except_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 475, __pyx_L5_except_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_11 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_7, __pyx_builtin_AttributeError) || __Pyx_PyErr_GivenExceptionMatches(__pyx_t_7, __pyx_t_10);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_ErrRestore(__pyx_t_7, __pyx_t_1, __pyx_t_8);
    __pyx_t_7 = 0; __pyx_t_1 = 0; __pyx_t_8 = 0;
    if (__pyx_t_11) {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_1, &__pyx_t_7) < 0) __PYX_ERR(0, 475, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_7);

      /* "mars/actors/pool/gevent_pool.pyx":476
 *                 ActorRef(address, uid), actor_cls, args, kwargs)[1:]
 *         except (AttributeError, pickle.PickleError):
 *             raise pickle.PicklingError('Unable to pickle {0}(*{1}, **{2})'.format(actor_cls, args, kwargs))             # <<<<<<<<<<<<<<
 * 
 *         if wait:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_pickle); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 476, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_PicklingError); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 476, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Unable_to_pickle_0_1_2, __pyx_n_s_format); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 476, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14 = NULL;
      __pyx_t_11 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
        __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
        if (likely(__pyx_t_14)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_13, function);
          __pyx_t_11 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[4] = {__pyx_t_14, __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 476, __pyx_L5_except_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[4] = {__pyx_t_14, __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 476, __pyx_L5_except_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      {
        __pyx_t_15 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 476, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_15);
        if (__pyx_t_14) {
          __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
        }
        __Pyx_INCREF(__pyx_v_actor_cls);
        __Pyx_GIVEREF(__pyx_v_actor_cls);
        PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_11, __pyx_v_actor_cls);
        __Pyx_INCREF(__pyx_v_args);
        __Pyx_GIVEREF(__pyx_v_args);
        PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_11, __pyx_v_args);
        __Pyx_INCREF(__pyx_v_kwargs);
        __Pyx_GIVEREF(__pyx_v_kwargs);
        PyTuple_SET_ITEM(__pyx_t_15, 2+__pyx_t_11, __pyx_v_kwargs);
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_15, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 476, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(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);
        }
      }
      __pyx_t_10 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_13, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_9);
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 476, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_Raise(__pyx_t_10, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __PYX_ERR(0, 476, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":471
 *         callback = kwargs.pop('callback', None)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             binaries = pack_create_actor_message(
 *                 ActorRemoteHelper.index, UNKNOWN_TO_INDEX,
 */
    __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_L8_try_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":478
 *             raise pickle.PicklingError('Unable to pickle {0}(*{1}, **{2})'.format(actor_cls, args, kwargs))
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             actor_ref = self._pool.apply(self._send_remote, (address, binaries))
 *             actor_ref.ctx = ActorContext(self)
 */
  __pyx_t_2 = (__pyx_v_wait != 0);
  if (__pyx_t_2) {

    /* "mars/actors/pool/gevent_pool.pyx":479
 * 
 *         if wait:
 *             actor_ref = self._pool.apply(self._send_remote, (address, binaries))             # <<<<<<<<<<<<<<
 *             actor_ref.ctx = ActorContext(self)
 *             return actor_ref
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->_pool, __pyx_n_s_apply); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_send_remote); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_INCREF(__pyx_v_address);
    __Pyx_GIVEREF(__pyx_v_address);
    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_address);
    __Pyx_INCREF(__pyx_v_binaries);
    __Pyx_GIVEREF(__pyx_v_binaries);
    PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_binaries);
    __pyx_t_12 = NULL;
    __pyx_t_11 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_t_8, __pyx_t_10};
      __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 479, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_t_8, __pyx_t_10};
      __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 479, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 479, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_12) {
        __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_12); __pyx_t_12 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_t_10);
      __pyx_t_8 = 0;
      __pyx_t_10 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 479, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4mars_6actors_4core_ActorRef))))) __PYX_ERR(0, 479, __pyx_L1_error)
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":480
 *         if wait:
 *             actor_ref = self._pool.apply(self._send_remote, (address, binaries))
 *             actor_ref.ctx = ActorContext(self)             # <<<<<<<<<<<<<<
 *             return actor_ref
 * 
 */
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext), ((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_actor_ref), __pyx_n_s_ctx, __pyx_t_7) < 0) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":481
 *             actor_ref = self._pool.apply(self._send_remote, (address, binaries))
 *             actor_ref.ctx = ActorContext(self)
 *             return actor_ref             # <<<<<<<<<<<<<<
 * 
 *         # return future
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
    __pyx_r = ((PyObject *)__pyx_v_actor_ref);
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":478
 *             raise pickle.PicklingError('Unable to pickle {0}(*{1}, **{2})'.format(actor_cls, args, kwargs))
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             actor_ref = self._pool.apply(self._send_remote, (address, binaries))
 *             actor_ref.ctx = ActorContext(self)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":484
 * 
 *         # return future
 *         future = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 * 
 *         def on_success(g):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_event); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_AsyncResult); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_7 = (__pyx_t_9) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 484, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_cur_scope->__pyx_v_future = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":486
 *         future = gevent.event.AsyncResult()
 * 
 *         def on_success(g):             # <<<<<<<<<<<<<<
 *             actor_ref = g.value
 *             actor_ref.ctx = ActorContext(self)
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12create_actor_1on_success, 0, __pyx_n_s_create_actor_locals_on_success, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__10)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 486, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_v_on_success = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":493
 *             future.set_result(actor_ref)
 * 
 *         def on_failure(g):             # <<<<<<<<<<<<<<
 *             try:
 *                 g.get()
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12create_actor_3on_failure, 0, __pyx_n_s_create_actor_locals_on_failure, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_v_on_failure = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":500
 *                 future.set_exception(ex, exc_info=(t, ex, tb))
 * 
 *         p = self._pool.apply_async(self._send_remote, (address, binaries))             # <<<<<<<<<<<<<<
 *         p.link_value(on_success)
 *         p.link_exception(on_failure)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->_pool, __pyx_n_s_apply_async); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_send_remote); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_INCREF(__pyx_v_address);
  __Pyx_GIVEREF(__pyx_v_address);
  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_address);
  __Pyx_INCREF(__pyx_v_binaries);
  __Pyx_GIVEREF(__pyx_v_binaries);
  PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_binaries);
  __pyx_t_8 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_9, __pyx_t_10};
    __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 500, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
    PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_9, __pyx_t_10};
    __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 500, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  {
    __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 500, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_10);
    __pyx_t_9 = 0;
    __pyx_t_10 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 500, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_p = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":501
 * 
 *         p = self._pool.apply_async(self._send_remote, (address, binaries))
 *         p.link_value(on_success)             # <<<<<<<<<<<<<<
 *         p.link_exception(on_failure)
 *         return future
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_link_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_12 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_7 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_12, __pyx_v_on_success) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_on_success);
  __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 501, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":502
 *         p = self._pool.apply_async(self._send_remote, (address, binaries))
 *         p.link_value(on_success)
 *         p.link_exception(on_failure)             # <<<<<<<<<<<<<<
 *         return future
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_link_exception); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 502, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_12 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_7 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_12, __pyx_v_on_failure) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_on_failure);
  __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 502, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":503
 *         p.link_value(on_success)
 *         p.link_exception(on_failure)
 *         return future             # <<<<<<<<<<<<<<
 * 
 *     def _async_run(self, str address, object binaries, object callback=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_future);
  __pyx_r = __pyx_cur_scope->__pyx_v_future;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":461
 *                 raise
 * 
 *     def create_actor(self, str address, object uid, object actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef bint wait
 *         cdef object callback
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_binaries);
  __Pyx_XDECREF((PyObject *)__pyx_v_actor_ref);
  __Pyx_XDECREF(__pyx_v_on_success);
  __Pyx_XDECREF(__pyx_v_on_failure);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":505
 *         return future
 * 
 *     def _async_run(self, str address, object binaries, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef object future
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_7_async_run(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_7_async_run(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_address = 0;
  PyObject *__pyx_v_binaries = 0;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_async_run (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_address,&__pyx_n_s_binaries,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_address)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_binaries)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_async_run", 0, 2, 3, 1); __PYX_ERR(0, 505, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_async_run") < 0)) __PYX_ERR(0, 505, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_address = ((PyObject*)values[0]);
    __pyx_v_binaries = values[1];
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_async_run", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 505, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper._async_run", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_address), (&PyString_Type), 1, "address", 1))) __PYX_ERR(0, 505, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_6_async_run(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)__pyx_v_self), __pyx_v_address, __pyx_v_binaries, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":511
 *         future = gevent.event.AsyncResult()
 * 
 *         def on_success(g):             # <<<<<<<<<<<<<<
 *             ret = g.value
 *             if callback:
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10_async_run_1on_success(PyObject *__pyx_self, PyObject *__pyx_v_g); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10_async_run_1on_success = {"on_success", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10_async_run_1on_success, METH_O, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10_async_run_1on_success(PyObject *__pyx_self, PyObject *__pyx_v_g) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("on_success (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10_async_run_on_success(__pyx_self, ((PyObject *)__pyx_v_g));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10_async_run_on_success(PyObject *__pyx_self, PyObject *__pyx_v_g) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run *__pyx_outer_scope;
  PyObject *__pyx_v_ret = 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;
  __Pyx_RefNannySetupContext("on_success", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":512
 * 
 *         def on_success(g):
 *             ret = g.value             # <<<<<<<<<<<<<<
 *             if callback:
 *                 callback(ret)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 512, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":513
 *         def on_success(g):
 *             ret = g.value
 *             if callback:             # <<<<<<<<<<<<<<
 *                 callback(ret)
 *             future.set_result(ret)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_callback)) { __Pyx_RaiseClosureNameError("callback"); __PYX_ERR(0, 513, __pyx_L1_error) }
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_callback); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 513, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "mars/actors/pool/gevent_pool.pyx":514
 *             ret = g.value
 *             if callback:
 *                 callback(ret)             # <<<<<<<<<<<<<<
 *             future.set_result(ret)
 * 
 */
    if (unlikely(!__pyx_cur_scope->__pyx_v_callback)) { __Pyx_RaiseClosureNameError("callback"); __PYX_ERR(0, 514, __pyx_L1_error) }
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_callback);
    __pyx_t_3 = __pyx_cur_scope->__pyx_v_callback; __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_ret) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_ret);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 514, __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;

    /* "mars/actors/pool/gevent_pool.pyx":513
 *         def on_success(g):
 *             ret = g.value
 *             if callback:             # <<<<<<<<<<<<<<
 *                 callback(ret)
 *             future.set_result(ret)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":515
 *             if callback:
 *                 callback(ret)
 *             future.set_result(ret)             # <<<<<<<<<<<<<<
 * 
 *         def on_failure(g):
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_future)) { __Pyx_RaiseClosureNameError("future"); __PYX_ERR(0, 515, __pyx_L1_error) }
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_future, __pyx_n_s_set_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 515, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_ret) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_ret);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 515, __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;

  /* "mars/actors/pool/gevent_pool.pyx":511
 *         future = gevent.event.AsyncResult()
 * 
 *         def on_success(g):             # <<<<<<<<<<<<<<
 *             ret = g.value
 *             if 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_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper._async_run.on_success", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":517
 *             future.set_result(ret)
 * 
 *         def on_failure(g):             # <<<<<<<<<<<<<<
 *             try:
 *                 g.get()
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10_async_run_3on_failure(PyObject *__pyx_self, PyObject *__pyx_v_g); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10_async_run_3on_failure = {"on_failure", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10_async_run_3on_failure, METH_O, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10_async_run_3on_failure(PyObject *__pyx_self, PyObject *__pyx_v_g) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("on_failure (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10_async_run_2on_failure(__pyx_self, ((PyObject *)__pyx_v_g));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10_async_run_2on_failure(PyObject *__pyx_self, PyObject *__pyx_v_g) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run *__pyx_outer_scope;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_ex = NULL;
  PyObject *__pyx_v_tb = 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;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *(*__pyx_t_12)(PyObject *);
  __Pyx_RefNannySetupContext("on_failure", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":518
 * 
 *         def on_failure(g):
 *             try:             # <<<<<<<<<<<<<<
 *                 g.get()
 *             except:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __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:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":519
 *         def on_failure(g):
 *             try:
 *                 g.get()             # <<<<<<<<<<<<<<
 *             except:
 *                 t, ex, tb = sys.exc_info()
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 519, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && 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 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 519, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":518
 * 
 *         def on_failure(g):
 *             try:             # <<<<<<<<<<<<<<
 *                 g.get()
 *             except:
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __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;

    /* "mars/actors/pool/gevent_pool.pyx":520
 *             try:
 *                 g.get()
 *             except:             # <<<<<<<<<<<<<<
 *                 t, ex, tb = sys.exc_info()
 *                 future.set_exception(ex, exc_info=(t, ex, tb))
 */
    /*except:*/ {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper._async_run.on_failure", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 520, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_6);

      /* "mars/actors/pool/gevent_pool.pyx":521
 *                 g.get()
 *             except:
 *                 t, ex, tb = sys.exc_info()             # <<<<<<<<<<<<<<
 *                 future.set_exception(ex, exc_info=(t, ex, tb))
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_sys); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 521, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 521, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && 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_7 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_9);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 521, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) {
        PyObject* sequence = __pyx_t_7;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 521, __pyx_L5_except_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_9 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_10 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_10);
        #else
        __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 521, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 521, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 521, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_10);
        #endif
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 521, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_9 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_9)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_9);
        index = 1; __pyx_t_8 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_8)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_8);
        index = 2; __pyx_t_10 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_10);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 3) < 0) __PYX_ERR(0, 521, __pyx_L5_except_error)
        __pyx_t_12 = NULL;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L12_unpacking_done;
        __pyx_L11_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_12 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 521, __pyx_L5_except_error)
        __pyx_L12_unpacking_done:;
      }
      __pyx_v_t = __pyx_t_9;
      __pyx_t_9 = 0;
      __pyx_v_ex = __pyx_t_8;
      __pyx_t_8 = 0;
      __pyx_v_tb = __pyx_t_10;
      __pyx_t_10 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":522
 *             except:
 *                 t, ex, tb = sys.exc_info()
 *                 future.set_exception(ex, exc_info=(t, ex, tb))             # <<<<<<<<<<<<<<
 * 
 *         p = self._pool.apply_async(self._send_remote, (address, binaries))
 */
      if (unlikely(!__pyx_cur_scope->__pyx_v_future)) { __Pyx_RaiseClosureNameError("future"); __PYX_ERR(0, 522, __pyx_L5_except_error) }
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_future, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 522, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 522, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_v_ex);
      __Pyx_GIVEREF(__pyx_v_ex);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_ex);
      __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 522, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 522, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_v_t);
      __Pyx_GIVEREF(__pyx_v_t);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_t);
      __Pyx_INCREF(__pyx_v_ex);
      __Pyx_GIVEREF(__pyx_v_ex);
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_ex);
      __Pyx_INCREF(__pyx_v_tb);
      __Pyx_GIVEREF(__pyx_v_tb);
      PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_v_tb);
      if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_exc_info, __pyx_t_9) < 0) __PYX_ERR(0, 522, __pyx_L5_except_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 522, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":518
 * 
 *         def on_failure(g):
 *             try:             # <<<<<<<<<<<<<<
 *                 g.get()
 *             except:
 */
    __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_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);
    __pyx_L8_try_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":517
 *             future.set_result(ret)
 * 
 *         def on_failure(g):             # <<<<<<<<<<<<<<
 *             try:
 *                 g.get()
 */

  /* 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_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper._async_run.on_failure", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_ex);
  __Pyx_XDECREF(__pyx_v_tb);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":505
 *         return future
 * 
 *     def _async_run(self, str address, object binaries, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef object future
 * 
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_6_async_run(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, PyObject *__pyx_v_address, PyObject *__pyx_v_binaries, PyObject *__pyx_v_callback) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run *__pyx_cur_scope;
  PyObject *__pyx_v_on_success = 0;
  PyObject *__pyx_v_on_failure = 0;
  PyObject *__pyx_v_p = 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;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("_async_run", 0);
  __pyx_cur_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run *)__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run(__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 505, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __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);

  /* "mars/actors/pool/gevent_pool.pyx":509
 * 
 *         # return future
 *         future = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 * 
 *         def on_success(g):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_event); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 509, __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_AsyncResult); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 509, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_future = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":511
 *         future = gevent.event.AsyncResult()
 * 
 *         def on_success(g):             # <<<<<<<<<<<<<<
 *             ret = g.value
 *             if callback:
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10_async_run_1on_success, 0, __pyx_n_s_async_run_locals_on_success, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 511, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_on_success = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":517
 *             future.set_result(ret)
 * 
 *         def on_failure(g):             # <<<<<<<<<<<<<<
 *             try:
 *                 g.get()
 */
  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10_async_run_3on_failure, 0, __pyx_n_s_async_run_locals_on_failure, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_on_failure = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":524
 *                 future.set_exception(ex, exc_info=(t, ex, tb))
 * 
 *         p = self._pool.apply_async(self._send_remote, (address, binaries))             # <<<<<<<<<<<<<<
 *         p.link_value(on_success)
 *         p.link_exception(on_failure)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_pool, __pyx_n_s_apply_async); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 524, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send_remote); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 524, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 524, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_address);
  __Pyx_GIVEREF(__pyx_v_address);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_address);
  __Pyx_INCREF(__pyx_v_binaries);
  __Pyx_GIVEREF(__pyx_v_binaries);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_binaries);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && likely(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);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 524, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 524, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 524, __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_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 524, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_p = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":525
 * 
 *         p = self._pool.apply_async(self._send_remote, (address, binaries))
 *         p.link_value(on_success)             # <<<<<<<<<<<<<<
 *         p.link_exception(on_failure)
 *         return future
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_link_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 525, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_7, __pyx_v_on_success) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_on_success);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 525, __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;

  /* "mars/actors/pool/gevent_pool.pyx":526
 *         p = self._pool.apply_async(self._send_remote, (address, binaries))
 *         p.link_value(on_success)
 *         p.link_exception(on_failure)             # <<<<<<<<<<<<<<
 *         return future
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_link_exception); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 526, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_7, __pyx_v_on_failure) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_on_failure);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 526, __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;

  /* "mars/actors/pool/gevent_pool.pyx":527
 *         p.link_value(on_success)
 *         p.link_exception(on_failure)
 *         return future             # <<<<<<<<<<<<<<
 * 
 *     cpdef object destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_future);
  __pyx_r = __pyx_cur_scope->__pyx_v_future;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":505
 *         return future
 * 
 *     def _async_run(self, str address, object binaries, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef object future
 * 
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper._async_run", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_on_success);
  __Pyx_XDECREF(__pyx_v_on_failure);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":529
 *         return future
 * 
 *     cpdef object destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef tuple binaries
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_9destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_destroy_actor *__pyx_optional_args) {
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  PyObject *__pyx_v_binaries = 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_t_6;
  PyObject *__pyx_t_7 = NULL;
  __pyx_t_4mars_6actors_4pool_8messages_INT32_t __pyx_t_8;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("destroy_actor", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_wait = __pyx_optional_args->wait;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_callback = __pyx_optional_args->callback;
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_destroy_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 529, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_9destroy_actor)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 529, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        __pyx_t_6 = 0;
        if (CYTHON_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 529, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 529, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 529, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 529, __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_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":532
 *         cdef tuple binaries
 * 
 *         binaries = pack_destroy_actor_message(ActorRemoteHelper.index, UNKNOWN_TO_INDEX, actor_ref)[1:]             # <<<<<<<<<<<<<<
 * 
 *         if wait:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper), __pyx_n_s_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyInt_As_npy_int32(__pyx_t_1); if (unlikely((__pyx_t_8 == ((npy_int32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 532, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_pack_destroy_actor_message(__pyx_t_8, __pyx_v_4mars_6actors_4pool_11gevent_pool_UNKNOWN_TO_INDEX, __pyx_v_actor_ref, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_t_1, 1, 0, NULL, NULL, &__pyx_slice__8, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyTuple_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 532, __pyx_L1_error)
  __pyx_v_binaries = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":534
 *         binaries = pack_destroy_actor_message(ActorRemoteHelper.index, UNKNOWN_TO_INDEX, actor_ref)[1:]
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             return self._pool.apply(self._send_remote, (actor_ref.address, binaries))
 * 
 */
  __pyx_t_9 = (__pyx_v_wait != 0);
  if (__pyx_t_9) {

    /* "mars/actors/pool/gevent_pool.pyx":535
 * 
 *         if wait:
 *             return self._pool.apply(self._send_remote, (actor_ref.address, binaries))             # <<<<<<<<<<<<<<
 * 
 *         # return future
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_pool, __pyx_n_s_apply); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 535, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send_remote); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 535, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 535, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_actor_ref->address);
    __Pyx_GIVEREF(__pyx_v_actor_ref->address);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_actor_ref->address);
    __Pyx_INCREF(__pyx_v_binaries);
    __Pyx_GIVEREF(__pyx_v_binaries);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_binaries);
    __pyx_t_3 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && 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);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, __pyx_t_7};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 535, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, __pyx_t_7};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 535, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 535, __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_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_t_7);
      __pyx_t_4 = 0;
      __pyx_t_7 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 535, __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_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":534
 *         binaries = pack_destroy_actor_message(ActorRemoteHelper.index, UNKNOWN_TO_INDEX, actor_ref)[1:]
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             return self._pool.apply(self._send_remote, (actor_ref.address, binaries))
 * 
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":538
 * 
 *         # return future
 *         return self._async_run(actor_ref.address, binaries, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_async_run); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_actor_ref->address);
  __Pyx_GIVEREF(__pyx_v_actor_ref->address);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_actor_ref->address);
  __Pyx_INCREF(__pyx_v_binaries);
  __Pyx_GIVEREF(__pyx_v_binaries);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_binaries);
  __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 538, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":529
 *         return future
 * 
 *     cpdef object destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef tuple binaries
 * 
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_binaries);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_9destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_9destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("destroy_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "destroy_actor") < 0)) __PYX_ERR(0, 529, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    if (values[1]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 529, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("destroy_actor", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 529, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 529, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_8destroy_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_8destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_destroy_actor __pyx_t_2;
  __Pyx_RefNannySetupContext("destroy_actor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper->destroy_actor(__pyx_v_self, __pyx_v_actor_ref, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 529, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":540
 *         return self._async_run(actor_ref.address, binaries, callback=callback)
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef tuple binaries
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_11has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_has_actor *__pyx_optional_args) {
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  PyObject *__pyx_v_binaries = 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_t_6;
  PyObject *__pyx_t_7 = NULL;
  __pyx_t_4mars_6actors_4pool_8messages_INT32_t __pyx_t_8;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("has_actor", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_wait = __pyx_optional_args->wait;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_callback = __pyx_optional_args->callback;
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_has_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 540, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_11has_actor)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 540, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        __pyx_t_6 = 0;
        if (CYTHON_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 540, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 540, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 540, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 540, __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_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":543
 *         cdef tuple binaries
 * 
 *         binaries = pack_has_actor_message(ActorRemoteHelper.index, UNKNOWN_TO_INDEX, actor_ref)[1:]             # <<<<<<<<<<<<<<
 * 
 *         if wait:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper), __pyx_n_s_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyInt_As_npy_int32(__pyx_t_1); if (unlikely((__pyx_t_8 == ((npy_int32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_pack_has_actor_message(__pyx_t_8, __pyx_v_4mars_6actors_4pool_11gevent_pool_UNKNOWN_TO_INDEX, __pyx_v_actor_ref, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_t_1, 1, 0, NULL, NULL, &__pyx_slice__8, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyTuple_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 543, __pyx_L1_error)
  __pyx_v_binaries = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":545
 *         binaries = pack_has_actor_message(ActorRemoteHelper.index, UNKNOWN_TO_INDEX, actor_ref)[1:]
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             return self._pool.apply(self._send_remote, (actor_ref.address, binaries))
 * 
 */
  __pyx_t_9 = (__pyx_v_wait != 0);
  if (__pyx_t_9) {

    /* "mars/actors/pool/gevent_pool.pyx":546
 * 
 *         if wait:
 *             return self._pool.apply(self._send_remote, (actor_ref.address, binaries))             # <<<<<<<<<<<<<<
 * 
 *         # return future
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_pool, __pyx_n_s_apply); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 546, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send_remote); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 546, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 546, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_actor_ref->address);
    __Pyx_GIVEREF(__pyx_v_actor_ref->address);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_actor_ref->address);
    __Pyx_INCREF(__pyx_v_binaries);
    __Pyx_GIVEREF(__pyx_v_binaries);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_binaries);
    __pyx_t_3 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && 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);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, __pyx_t_7};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 546, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_4, __pyx_t_7};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 546, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 546, __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_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_t_7);
      __pyx_t_4 = 0;
      __pyx_t_7 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 546, __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_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":545
 *         binaries = pack_has_actor_message(ActorRemoteHelper.index, UNKNOWN_TO_INDEX, actor_ref)[1:]
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             return self._pool.apply(self._send_remote, (actor_ref.address, binaries))
 * 
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":549
 * 
 *         # return future
 *         return self._async_run(actor_ref.address, binaries, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *     def actor_ref(self, *args, **kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_async_run); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 549, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 549, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_actor_ref->address);
  __Pyx_GIVEREF(__pyx_v_actor_ref->address);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_actor_ref->address);
  __Pyx_INCREF(__pyx_v_binaries);
  __Pyx_GIVEREF(__pyx_v_binaries);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_binaries);
  __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 549, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 549, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 549, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":540
 *         return self._async_run(actor_ref.address, binaries, callback=callback)
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef tuple binaries
 * 
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_binaries);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_11has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_11has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("has_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "has_actor") < 0)) __PYX_ERR(0, 540, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    if (values[1]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 540, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("has_actor", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 540, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 540, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10has_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_10has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_has_actor __pyx_t_2;
  __Pyx_RefNannySetupContext("has_actor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper->has_actor(__pyx_v_self, __pyx_v_actor_ref, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 540, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":551
 *         return self._async_run(actor_ref.address, binaries, callback=callback)
 * 
 *     def actor_ref(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef ActorRef ref
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_13actor_ref(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_13actor_ref(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("actor_ref (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "actor_ref", 1))) return NULL;
  if (unlikely(__pyx_kwds)) {
    __pyx_v_kwargs = PyDict_Copy(__pyx_kwds); if (unlikely(!__pyx_v_kwargs)) return NULL;
    __Pyx_GOTREF(__pyx_v_kwargs);
  } else {
    __pyx_v_kwargs = NULL;
  }
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12actor_ref(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)__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_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_12actor_ref(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_ref = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("actor_ref", 0);

  /* "mars/actors/pool/gevent_pool.pyx":554
 *         cdef ActorRef ref
 * 
 *         ref = create_actor_ref(*args, **kwargs)             # <<<<<<<<<<<<<<
 *         ref.ctx = self
 *         return ref
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_actor_ref); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 554, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 554, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4mars_6actors_4core_ActorRef))))) __PYX_ERR(0, 554, __pyx_L1_error)
  __pyx_v_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":555
 * 
 *         ref = create_actor_ref(*args, **kwargs)
 *         ref.ctx = self             # <<<<<<<<<<<<<<
 *         return ref
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_ref), __pyx_n_s_ctx, ((PyObject *)__pyx_v_self)) < 0) __PYX_ERR(0, 555, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":556
 *         ref = create_actor_ref(*args, **kwargs)
 *         ref.ctx = self
 *         return ref             # <<<<<<<<<<<<<<
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_ref));
  __pyx_r = ((PyObject *)__pyx_v_ref);
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":551
 *         return self._async_run(actor_ref.address, binaries, callback=callback)
 * 
 *     def actor_ref(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef ActorRef ref
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.actor_ref", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ref);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":558
 *         return ref
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         cdef object func
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_15_send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__send *__pyx_optional_args) {
  int __pyx_v_wait_response = ((int)1);

  /* "mars/actors/pool/gevent_pool.pyx":559
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,
 *                       bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef object func
 *         cdef list binaries
 */
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  PyObject *__pyx_v_binaries = 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;
  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_t_12;
  __pyx_t_4mars_6actors_4pool_8messages_INT32_t __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  __Pyx_RefNannySetupContext("_send", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_wait_response = __pyx_optional_args->wait_response;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_wait = __pyx_optional_args->wait;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_callback = __pyx_optional_args->callback;
        }
      }
    }
  }

  /* "mars/actors/pool/gevent_pool.pyx":558
 *         return ref
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         cdef object func
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 558, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_15_send)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait_response); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 558, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 558, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_5 = __pyx_t_1; __pyx_t_6 = NULL;
        __pyx_t_7 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(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_7 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[6] = {__pyx_t_6, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_t_3, __pyx_t_4, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 558, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[6] = {__pyx_t_6, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_t_3, __pyx_t_4, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 558, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else
        #endif
        {
          __pyx_t_8 = PyTuple_New(5+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 558, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_INCREF(__pyx_v_message);
          __Pyx_GIVEREF(__pyx_v_message);
          PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_message);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_7, __pyx_t_4);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_8, 4+__pyx_t_7, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 558, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":563
 *         cdef list binaries
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if wait_response:
 *                 binaries = pack_send_message(ActorRemoteHelper.index, UNKNOWN_TO_INDEX, actor_ref, message)[1:]
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __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:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":564
 * 
 *         try:
 *             if wait_response:             # <<<<<<<<<<<<<<
 *                 binaries = pack_send_message(ActorRemoteHelper.index, UNKNOWN_TO_INDEX, actor_ref, message)[1:]
 *             else:
 */
      __pyx_t_12 = (__pyx_v_wait_response != 0);
      if (__pyx_t_12) {

        /* "mars/actors/pool/gevent_pool.pyx":565
 *         try:
 *             if wait_response:
 *                 binaries = pack_send_message(ActorRemoteHelper.index, UNKNOWN_TO_INDEX, actor_ref, message)[1:]             # <<<<<<<<<<<<<<
 *             else:
 *                 binaries = pack_tell_message(ActorRemoteHelper.index, UNKNOWN_TO_INDEX, actor_ref, message)[1:]
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper), __pyx_n_s_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 565, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_13 = __Pyx_PyInt_As_npy_int32(__pyx_t_1); if (unlikely((__pyx_t_13 == ((npy_int32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 565, __pyx_L3_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_pack_send_message(__pyx_t_13, __pyx_v_4mars_6actors_4pool_11gevent_pool_UNKNOWN_TO_INDEX, __pyx_v_actor_ref, __pyx_v_message, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 565, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_t_1, 1, 0, NULL, NULL, &__pyx_slice__8, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 565, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 565, __pyx_L3_error)
        __pyx_v_binaries = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;

        /* "mars/actors/pool/gevent_pool.pyx":564
 * 
 *         try:
 *             if wait_response:             # <<<<<<<<<<<<<<
 *                 binaries = pack_send_message(ActorRemoteHelper.index, UNKNOWN_TO_INDEX, actor_ref, message)[1:]
 *             else:
 */
        goto __pyx_L9;
      }

      /* "mars/actors/pool/gevent_pool.pyx":567
 *                 binaries = pack_send_message(ActorRemoteHelper.index, UNKNOWN_TO_INDEX, actor_ref, message)[1:]
 *             else:
 *                 binaries = pack_tell_message(ActorRemoteHelper.index, UNKNOWN_TO_INDEX, actor_ref, message)[1:]             # <<<<<<<<<<<<<<
 *         except (AttributeError, pickle.PickleError):
 *             raise pickle.PicklingError('Unable to pickle message {0}'.format(message))
 */
      /*else*/ {
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper), __pyx_n_s_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 567, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_13 = __Pyx_PyInt_As_npy_int32(__pyx_t_2); if (unlikely((__pyx_t_13 == ((npy_int32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 567, __pyx_L3_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = __pyx_f_4mars_6actors_4pool_8messages_pack_tell_message(__pyx_t_13, __pyx_v_4mars_6actors_4pool_11gevent_pool_UNKNOWN_TO_INDEX, __pyx_v_actor_ref, __pyx_v_message, 0, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 567, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_2, 1, 0, NULL, NULL, &__pyx_slice__8, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 567, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 567, __pyx_L3_error)
        __pyx_v_binaries = ((PyObject*)__pyx_t_1);
        __pyx_t_1 = 0;
      }
      __pyx_L9:;

      /* "mars/actors/pool/gevent_pool.pyx":563
 *         cdef list binaries
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if wait_response:
 *                 binaries = pack_send_message(ActorRemoteHelper.index, UNKNOWN_TO_INDEX, actor_ref, message)[1:]
 */
    }
    __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_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":568
 *             else:
 *                 binaries = pack_tell_message(ActorRemoteHelper.index, UNKNOWN_TO_INDEX, actor_ref, message)[1:]
 *         except (AttributeError, pickle.PickleError):             # <<<<<<<<<<<<<<
 *             raise pickle.PicklingError('Unable to pickle message {0}'.format(message))
 * 
 */
    __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_2, &__pyx_t_5);
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_pickle); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 568, __pyx_L5_except_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 568, __pyx_L5_except_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_7 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_builtin_AttributeError) || __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_ErrRestore(__pyx_t_1, __pyx_t_2, __pyx_t_5);
    __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_5 = 0;
    if (__pyx_t_7) {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper._send", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_2, &__pyx_t_1) < 0) __PYX_ERR(0, 568, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);

      /* "mars/actors/pool/gevent_pool.pyx":569
 *                 binaries = pack_tell_message(ActorRemoteHelper.index, UNKNOWN_TO_INDEX, actor_ref, message)[1:]
 *         except (AttributeError, pickle.PickleError):
 *             raise pickle.PicklingError('Unable to pickle message {0}'.format(message))             # <<<<<<<<<<<<<<
 * 
 *         if wait:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_pickle); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 569, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_PicklingError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 569, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Unable_to_pickle_message_0, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 569, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_14 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_14)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      __pyx_t_8 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_14, __pyx_v_message) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_message);
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 569, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && 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);
        }
      }
      __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_6, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8);
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 569, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 569, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":563
 *         cdef list binaries
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if wait_response:
 *                 binaries = pack_send_message(ActorRemoteHelper.index, UNKNOWN_TO_INDEX, actor_ref, message)[1:]
 */
    __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_try_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":571
 *             raise pickle.PicklingError('Unable to pickle message {0}'.format(message))
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             return self._pool.apply(self._send_remote, (actor_ref.address, binaries))
 * 
 */
  __pyx_t_12 = (__pyx_v_wait != 0);
  if (__pyx_t_12) {

    /* "mars/actors/pool/gevent_pool.pyx":572
 * 
 *         if wait:
 *             return self._pool.apply(self._send_remote, (actor_ref.address, binaries))             # <<<<<<<<<<<<<<
 * 
 *         # return future
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_pool, __pyx_n_s_apply); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send_remote); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_actor_ref->address);
    __Pyx_GIVEREF(__pyx_v_actor_ref->address);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_actor_ref->address);
    __Pyx_INCREF(__pyx_v_binaries);
    __Pyx_GIVEREF(__pyx_v_binaries);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_binaries);
    __pyx_t_3 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && 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_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_5, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 572, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_5, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 572, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 572, __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_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
      __pyx_t_5 = 0;
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 572, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":571
 *             raise pickle.PicklingError('Unable to pickle message {0}'.format(message))
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             return self._pool.apply(self._send_remote, (actor_ref.address, binaries))
 * 
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":575
 * 
 *         # return future
 *         return self._async_run(actor_ref.address, binaries, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *     cpdef send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_async_run); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 575, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 575, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_actor_ref->address);
  __Pyx_GIVEREF(__pyx_v_actor_ref->address);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_actor_ref->address);
  __Pyx_INCREF(__pyx_v_binaries);
  __Pyx_GIVEREF(__pyx_v_binaries);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_binaries);
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 575, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 575, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 575, __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_8); __pyx_t_8 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":558
 *         return ref
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         cdef object func
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper._send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_binaries);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_15_send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_15_send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_message = 0;
  int __pyx_v_wait_response;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_send (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_message,&__pyx_n_s_wait_response,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[5] = {0,0,0,0,0};

    /* "mars/actors/pool/gevent_pool.pyx":559
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,
 *                       bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef object func
 *         cdef list binaries
 */
    values[4] = ((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  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_send", 0, 2, 5, 1); __PYX_ERR(0, 558, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait_response);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_send") < 0)) __PYX_ERR(0, 558, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    __pyx_v_message = values[1];
    if (values[2]) {
      __pyx_v_wait_response = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_wait_response == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 558, __pyx_L3_error)
    } else {

      /* "mars/actors/pool/gevent_pool.pyx":558
 *         return ref
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         cdef object func
 */
      __pyx_v_wait_response = ((int)1);
    }
    if (values[3]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 559, __pyx_L3_error)
    } else {

      /* "mars/actors/pool/gevent_pool.pyx":559
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,
 *                       bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef object func
 *         cdef list binaries
 */
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_send", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 558, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper._send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 558, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_14_send(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_message, __pyx_v_wait_response, __pyx_v_wait, __pyx_v_callback);

  /* "mars/actors/pool/gevent_pool.pyx":558
 *         return ref
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         cdef object func
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_14_send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait_response, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__send __pyx_t_2;
  __Pyx_RefNannySetupContext("_send", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.wait_response = __pyx_v_wait_response;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper->_send(__pyx_v_self, __pyx_v_actor_ref, __pyx_v_message, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper._send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":577
 *         return self._async_run(actor_ref.address, binaries, callback=callback)
 * 
 *     cpdef send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_17send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_send *__pyx_optional_args) {
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  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;
  PyObject *__pyx_t_7 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__send __pyx_t_8;
  __Pyx_RefNannySetupContext("send", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_wait = __pyx_optional_args->wait;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_callback = __pyx_optional_args->callback;
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 577, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_17send)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 577, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        __pyx_t_6 = 0;
        if (CYTHON_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[5] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 4+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 577, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[5] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 4+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 577, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(4+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 577, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_INCREF(__pyx_v_message);
          __Pyx_GIVEREF(__pyx_v_message);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_message);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_6, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 577, __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_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":578
 * 
 *     cpdef send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_8.__pyx_n = 3;
  __pyx_t_8.wait_response = 1;
  __pyx_t_8.wait = __pyx_v_wait;
  __pyx_t_8.callback = __pyx_v_callback;
  __pyx_t_1 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)__pyx_v_self->__pyx_vtab)->_send(__pyx_v_self, __pyx_v_actor_ref, __pyx_v_message, 0, &__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 578, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":577
 *         return self._async_run(actor_ref.address, binaries, callback=callback)
 * 
 *     cpdef send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_17send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_17send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_message = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("send (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_message,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[4] = {0,0,0,0};
    values[3] = ((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);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("send", 0, 2, 4, 1); __PYX_ERR(0, 577, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "send") < 0)) __PYX_ERR(0, 577, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    __pyx_v_message = values[1];
    if (values[2]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 577, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("send", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 577, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 577, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_16send(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_message, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_16send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_send __pyx_t_2;
  __Pyx_RefNannySetupContext("send", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper->send(__pyx_v_self, __pyx_v_actor_ref, __pyx_v_message, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":580
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         if delay is not None:
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_19tell(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_tell *__pyx_optional_args) {
  PyObject *__pyx_v_delay = ((PyObject *)Py_None);

  /* "mars/actors/pool/gevent_pool.pyx":581
 * 
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,
 *                       bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         if delay is not None:
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 */
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  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;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__send __pyx_t_10;
  __Pyx_RefNannySetupContext("tell", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_delay = __pyx_optional_args->delay;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_wait = __pyx_optional_args->wait;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_callback = __pyx_optional_args->callback;
        }
      }
    }
  }

  /* "mars/actors/pool/gevent_pool.pyx":580
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         if delay is not None:
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 580, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_19tell)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 580, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        __pyx_t_6 = 0;
        if (CYTHON_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[6] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_v_delay, __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 580, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[6] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_v_delay, __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 580, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(5+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 580, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_INCREF(__pyx_v_message);
          __Pyx_GIVEREF(__pyx_v_message);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_message);
          __Pyx_INCREF(__pyx_v_delay);
          __Pyx_GIVEREF(__pyx_v_delay);
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_delay);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_7, 4+__pyx_t_6, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 580, __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_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":582
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,
 *                       bint wait=True, object callback=None):
 *         if delay is not None:             # <<<<<<<<<<<<<<
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 *                                wait=wait, callback=callback)
 */
  __pyx_t_8 = (__pyx_v_delay != Py_None);
  __pyx_t_9 = (__pyx_t_8 != 0);
  if (__pyx_t_9) {

    /* "mars/actors/pool/gevent_pool.pyx":583
 *                       bint wait=True, object callback=None):
 *         if delay is not None:
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,             # <<<<<<<<<<<<<<
 *                                wait=wait, callback=callback)
 *             return
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 583, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_spawn_later); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 583, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 583, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 583, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_delay);
    __Pyx_GIVEREF(__pyx_v_delay);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_delay);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
    PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_v_actor_ref));
    __Pyx_INCREF(__pyx_v_message);
    __Pyx_GIVEREF(__pyx_v_message);
    PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_message);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 583, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_wait_response, Py_False) < 0) __PYX_ERR(0, 583, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":584
 *         if delay is not None:
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 *                                wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 584, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_wait, __pyx_t_7) < 0) __PYX_ERR(0, 583, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 583, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":583
 *                       bint wait=True, object callback=None):
 *         if delay is not None:
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,             # <<<<<<<<<<<<<<
 *                                wait=wait, callback=callback)
 *             return
 */
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 583, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __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;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":585
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 *                                wait=wait, callback=callback)
 *             return             # <<<<<<<<<<<<<<
 * 
 *         return self._send(actor_ref, message, wait_response=False, wait=wait, callback=callback)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":582
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,
 *                       bint wait=True, object callback=None):
 *         if delay is not None:             # <<<<<<<<<<<<<<
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 *                                wait=wait, callback=callback)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":587
 *             return
 * 
 *         return self._send(actor_ref, message, wait_response=False, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_10.__pyx_n = 3;
  __pyx_t_10.wait_response = 0;
  __pyx_t_10.wait = __pyx_v_wait;
  __pyx_t_10.callback = __pyx_v_callback;
  __pyx_t_7 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)__pyx_v_self->__pyx_vtab)->_send(__pyx_v_self, __pyx_v_actor_ref, __pyx_v_message, 0, &__pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 587, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":580
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         if delay is not None:
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.tell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_19tell(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_19tell(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_message = 0;
  PyObject *__pyx_v_delay = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tell (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_message,&__pyx_n_s_delay,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[2] = ((PyObject *)Py_None);

    /* "mars/actors/pool/gevent_pool.pyx":581
 * 
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,
 *                       bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         if delay is not None:
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 */
    values[4] = ((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  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tell", 0, 2, 5, 1); __PYX_ERR(0, 580, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_delay);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tell") < 0)) __PYX_ERR(0, 580, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    __pyx_v_message = values[1];
    __pyx_v_delay = values[2];
    if (values[3]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 581, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("tell", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 580, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.tell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 580, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_18tell(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_message, __pyx_v_delay, __pyx_v_wait, __pyx_v_callback);

  /* "mars/actors/pool/gevent_pool.pyx":580
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         if delay is not None:
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_18tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, PyObject *__pyx_v_delay, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_tell __pyx_t_2;
  __Pyx_RefNannySetupContext("tell", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.delay = __pyx_v_delay;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper->tell(__pyx_v_self, __pyx_v_actor_ref, __pyx_v_message, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.tell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_20__reduce_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_20__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self._connections, self._lock, self._parallel, self._pool)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->_connections);
  __Pyx_GIVEREF(__pyx_v_self->_connections);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->_connections);
  __Pyx_INCREF(__pyx_v_self->_lock);
  __Pyx_GIVEREF(__pyx_v_self->_lock);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->_lock);
  __Pyx_INCREF(__pyx_v_self->_parallel);
  __Pyx_GIVEREF(__pyx_v_self->_parallel);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_self->_parallel);
  __Pyx_INCREF(__pyx_v_self->_pool);
  __Pyx_GIVEREF(__pyx_v_self->_pool);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_self->_pool);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self._connections, self._lock, self._parallel, self._pool)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self._connections, self._lock, self._parallel, self._pool)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self._connections is not None or self._lock is not None or self._parallel is not None or self._pool is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self._connections, self._lock, self._parallel, self._pool)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self._connections is not None or self._lock is not None or self._parallel is not None or self._pool is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_ActorRemoteHelper, (type(self), 0x162dc4f, None), state
 */
  /*else*/ {
    __pyx_t_2 = (__pyx_v_self->_connections != ((PyObject*)Py_None));
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->_lock != Py_None);
    __pyx_t_2 = (__pyx_t_5 != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_3 = __pyx_t_2;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_2 = (__pyx_v_self->_parallel != Py_None);
    __pyx_t_5 = (__pyx_t_2 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_3 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->_pool != Py_None);
    __pyx_t_2 = (__pyx_t_5 != 0);
    __pyx_t_3 = __pyx_t_2;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._connections is not None or self._lock is not None or self._parallel is not None or self._pool is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ActorRemoteHelper, (type(self), 0x162dc4f, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self._connections is not None or self._lock is not None or self._parallel is not None or self._pool is not None
 *     if use_setstate:
 *         return __pyx_unpickle_ActorRemoteHelper, (type(self), 0x162dc4f, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_ActorRemoteHelper, (type(self), 0x162dc4f, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_ActorRemoteHelper); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_23256143);
    __Pyx_GIVEREF(__pyx_int_23256143);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_23256143);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._connections is not None or self._lock is not None or self._parallel is not None or self._pool is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ActorRemoteHelper, (type(self), 0x162dc4f, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_ActorRemoteHelper, (type(self), 0x162dc4f, None), state
 *     else:
 *         return __pyx_unpickle_ActorRemoteHelper, (type(self), 0x162dc4f, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ActorRemoteHelper__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_ActorRemoteHelper); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_23256143);
    __Pyx_GIVEREF(__pyx_int_23256143);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_23256143);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ActorRemoteHelper, (type(self), 0x162dc4f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ActorRemoteHelper__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_22__setstate_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_22__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_ActorRemoteHelper, (type(self), 0x162dc4f, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ActorRemoteHelper__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorRemoteHelper__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ActorRemoteHelper, (type(self), 0x162dc4f, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ActorRemoteHelper__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorRemoteHelper.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":611
 *     cdef object __weakref__
 * 
 *     def __init__(self, pool, ClusterInfo cluster_info, pipe, Distributor distributor=None, parallel=None):             # <<<<<<<<<<<<<<
 *         super(Communicator, self).__init__()
 *         AsyncHandler.__init__(self)
 */

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pool = 0;
  struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *__pyx_v_cluster_info = 0;
  PyObject *__pyx_v_pipe = 0;
  struct __pyx_obj_4mars_6actors_11distributor_Distributor *__pyx_v_distributor = 0;
  PyObject *__pyx_v_parallel = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pool,&__pyx_n_s_cluster_info,&__pyx_n_s_pipe,&__pyx_n_s_distributor,&__pyx_n_s_parallel,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[3] = (PyObject *)((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)Py_None);
    values[4] = ((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  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pool)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cluster_info)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 1); __PYX_ERR(0, 611, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pipe)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 2); __PYX_ERR(0, 611, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_distributor);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_parallel);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 611, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        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_pool = values[0];
    __pyx_v_cluster_info = ((struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *)values[1]);
    __pyx_v_pipe = values[2];
    __pyx_v_distributor = ((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)values[3]);
    __pyx_v_parallel = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 611, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cluster_info), __pyx_ptype_4mars_6actors_7cluster_ClusterInfo, 1, "cluster_info", 0))) __PYX_ERR(0, 611, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distributor), __pyx_ptype_4mars_6actors_11distributor_Distributor, 1, "distributor", 0))) __PYX_ERR(0, 611, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator___init__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_pool, __pyx_v_cluster_info, __pyx_v_pipe, __pyx_v_distributor, __pyx_v_parallel);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_pool, struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *__pyx_v_cluster_info, PyObject *__pyx_v_pipe, struct __pyx_obj_4mars_6actors_11distributor_Distributor *__pyx_v_distributor, PyObject *__pyx_v_parallel) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":612
 * 
 *     def __init__(self, pool, ClusterInfo cluster_info, pipe, Distributor distributor=None, parallel=None):
 *         super(Communicator, self).__init__()             # <<<<<<<<<<<<<<
 *         AsyncHandler.__init__(self)
 * 
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 612, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_Communicator));
  __Pyx_GIVEREF(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_Communicator));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_Communicator));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 612, __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_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 612, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 612, __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;

  /* "mars/actors/pool/gevent_pool.pyx":613
 *     def __init__(self, pool, ClusterInfo cluster_info, pipe, Distributor distributor=None, parallel=None):
 *         super(Communicator, self).__init__()
 *         AsyncHandler.__init__(self)             # <<<<<<<<<<<<<<
 * 
 *         self.pool = pool
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_AsyncHandler), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 613, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_v_self)) : __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self));
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 613, __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;

  /* "mars/actors/pool/gevent_pool.pyx":615
 *         AsyncHandler.__init__(self)
 * 
 *         self.pool = pool             # <<<<<<<<<<<<<<
 *         self.index = self.pool.index
 *         self.cluster_info = cluster_info
 */
  __Pyx_INCREF(__pyx_v_pool);
  __Pyx_GIVEREF(__pyx_v_pool);
  __Pyx_GOTREF(__pyx_v_self->pool);
  __Pyx_DECREF(__pyx_v_self->pool);
  __pyx_v_self->pool = __pyx_v_pool;

  /* "mars/actors/pool/gevent_pool.pyx":616
 * 
 *         self.pool = pool
 *         self.index = self.pool.index             # <<<<<<<<<<<<<<
 *         self.cluster_info = cluster_info
 *         self.pipe = pipe
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pool, __pyx_n_s_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 616, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 616, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->index = __pyx_t_4;

  /* "mars/actors/pool/gevent_pool.pyx":617
 *         self.pool = pool
 *         self.index = self.pool.index
 *         self.cluster_info = cluster_info             # <<<<<<<<<<<<<<
 *         self.pipe = pipe
 *         if distributor is None:
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_cluster_info));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_cluster_info));
  __Pyx_GOTREF(__pyx_v_self->cluster_info);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->cluster_info));
  __pyx_v_self->cluster_info = __pyx_v_cluster_info;

  /* "mars/actors/pool/gevent_pool.pyx":618
 *         self.index = self.pool.index
 *         self.cluster_info = cluster_info
 *         self.pipe = pipe             # <<<<<<<<<<<<<<
 *         if distributor is None:
 *             self.distributor = Distributor(self.cluster_info.n_process)
 */
  __Pyx_INCREF(__pyx_v_pipe);
  __Pyx_GIVEREF(__pyx_v_pipe);
  __Pyx_GOTREF(__pyx_v_self->pipe);
  __Pyx_DECREF(__pyx_v_self->pipe);
  __pyx_v_self->pipe = __pyx_v_pipe;

  /* "mars/actors/pool/gevent_pool.pyx":619
 *         self.cluster_info = cluster_info
 *         self.pipe = pipe
 *         if distributor is None:             # <<<<<<<<<<<<<<
 *             self.distributor = Distributor(self.cluster_info.n_process)
 *         else:
 */
  __pyx_t_5 = (((PyObject *)__pyx_v_distributor) == Py_None);
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (__pyx_t_6) {

    /* "mars/actors/pool/gevent_pool.pyx":620
 *         self.pipe = pipe
 *         if distributor is None:
 *             self.distributor = Distributor(self.cluster_info.n_process)             # <<<<<<<<<<<<<<
 *         else:
 *             self.distributor = distributor
 */
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->cluster_info->n_process); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 620, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4mars_6actors_11distributor_Distributor), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 620, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->distributor);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->distributor));
    __pyx_v_self->distributor = ((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":619
 *         self.cluster_info = cluster_info
 *         self.pipe = pipe
 *         if distributor is None:             # <<<<<<<<<<<<<<
 *             self.distributor = Distributor(self.cluster_info.n_process)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "mars/actors/pool/gevent_pool.pyx":622
 *             self.distributor = Distributor(self.cluster_info.n_process)
 *         else:
 *             self.distributor = distributor             # <<<<<<<<<<<<<<
 *         self.remote_handler = ActorRemoteHelper(parallel=parallel)
 * 
 */
  /*else*/ {
    __Pyx_INCREF(((PyObject *)__pyx_v_distributor));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_distributor));
    __Pyx_GOTREF(__pyx_v_self->distributor);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->distributor));
    __pyx_v_self->distributor = __pyx_v_distributor;
  }
  __pyx_L3:;

  /* "mars/actors/pool/gevent_pool.pyx":623
 *         else:
 *             self.distributor = distributor
 *         self.remote_handler = ActorRemoteHelper(parallel=parallel)             # <<<<<<<<<<<<<<
 * 
 *         self.running = gevent.event.Event()
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 623, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_parallel, __pyx_v_parallel) < 0) __PYX_ERR(0, 623, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper), __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 623, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->remote_handler);
  __Pyx_DECREF(__pyx_v_self->remote_handler);
  __pyx_v_self->remote_handler = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":625
 *         self.remote_handler = ActorRemoteHelper(parallel=parallel)
 * 
 *         self.running = gevent.event.Event()             # <<<<<<<<<<<<<<
 *         self.running.set()
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_event); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 625, __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_Event); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->running);
  __Pyx_DECREF(__pyx_v_self->running);
  __pyx_v_self->running = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":626
 * 
 *         self.running = gevent.event.Event()
 *         self.running.set()             # <<<<<<<<<<<<<<
 * 
 *         self._handlers = {
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->running, __pyx_n_s_set); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 626, __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;

  /* "mars/actors/pool/gevent_pool.pyx":629
 * 
 *         self._handlers = {
 *             MessageType.send_all: self._on_receive_send,             # <<<<<<<<<<<<<<
 *             MessageType.tell_all: self._on_receive_tell,
 *             MessageType.create_actor: self._on_receive_create_actor,
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(__pyx_e_4mars_6actors_4pool_8messages_send_all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_send); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_t_3) < 0) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":630
 *         self._handlers = {
 *             MessageType.send_all: self._on_receive_send,
 *             MessageType.tell_all: self._on_receive_tell,             # <<<<<<<<<<<<<<
 *             MessageType.create_actor: self._on_receive_create_actor,
 *             MessageType.destroy_actor: self._on_receive_destroy_actor,
 */
  __pyx_t_3 = __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(__pyx_e_4mars_6actors_4pool_8messages_tell_all); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 630, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_tell); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 630, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_2) < 0) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":631
 *             MessageType.send_all: self._on_receive_send,
 *             MessageType.tell_all: self._on_receive_tell,
 *             MessageType.create_actor: self._on_receive_create_actor,             # <<<<<<<<<<<<<<
 *             MessageType.destroy_actor: self._on_receive_destroy_actor,
 *             MessageType.has_actor: self._on_receive_has_actor,
 */
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(__pyx_e_4mars_6actors_4pool_8messages_create_actor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 631, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_create_actor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 631, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_t_3) < 0) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":632
 *             MessageType.tell_all: self._on_receive_tell,
 *             MessageType.create_actor: self._on_receive_create_actor,
 *             MessageType.destroy_actor: self._on_receive_destroy_actor,             # <<<<<<<<<<<<<<
 *             MessageType.has_actor: self._on_receive_has_actor,
 *             MessageType.result: self._on_receive_result,
 */
  __pyx_t_3 = __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(__pyx_e_4mars_6actors_4pool_8messages_destroy_actor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 632, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_destroy_actor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 632, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_2) < 0) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":633
 *             MessageType.create_actor: self._on_receive_create_actor,
 *             MessageType.destroy_actor: self._on_receive_destroy_actor,
 *             MessageType.has_actor: self._on_receive_has_actor,             # <<<<<<<<<<<<<<
 *             MessageType.result: self._on_receive_result,
 *             MessageType.error: self._on_receive_error,
 */
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(__pyx_e_4mars_6actors_4pool_8messages_has_actor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 633, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_has_actor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 633, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_t_3) < 0) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":634
 *             MessageType.destroy_actor: self._on_receive_destroy_actor,
 *             MessageType.has_actor: self._on_receive_has_actor,
 *             MessageType.result: self._on_receive_result,             # <<<<<<<<<<<<<<
 *             MessageType.error: self._on_receive_error,
 *         }
 */
  __pyx_t_3 = __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(__pyx_e_4mars_6actors_4pool_8messages_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 634, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 634, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_2) < 0) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":635
 *             MessageType.has_actor: self._on_receive_has_actor,
 *             MessageType.result: self._on_receive_result,
 *             MessageType.error: self._on_receive_error,             # <<<<<<<<<<<<<<
 *         }
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(__pyx_e_4mars_6actors_4pool_8messages_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 635, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_error); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 635, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_t_3) < 0) __PYX_ERR(0, 629, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":628
 *         self.running.set()
 * 
 *         self._handlers = {             # <<<<<<<<<<<<<<
 *             MessageType.send_all: self._on_receive_send,
 *             MessageType.tell_all: self._on_receive_tell,
 */
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_handlers);
  __Pyx_DECREF(__pyx_v_self->_handlers);
  __pyx_v_self->_handlers = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":611
 *     cdef object __weakref__
 * 
 *     def __init__(self, pool, ClusterInfo cluster_info, pipe, Distributor distributor=None, parallel=None):             # <<<<<<<<<<<<<<
 *         super(Communicator, self).__init__()
 *         AsyncHandler.__init__(self)
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":638
 *         }
 * 
 *     cpdef _dispatch(self, local_func, redirect_func, remote_func, ActorRef actor_ref, args, kwargs):             # <<<<<<<<<<<<<<
 *         if actor_ref.address is None or actor_ref.address == self.cluster_info.address:
 *             if self.cluster_info.n_process == 1:
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_3_dispatch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__dispatch(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_local_func, PyObject *__pyx_v_redirect_func, PyObject *__pyx_v_remote_func, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_send_to_index = 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;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("_dispatch", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dispatch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 638, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_3_dispatch)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && 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);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[7] = {__pyx_t_4, __pyx_v_local_func, __pyx_v_redirect_func, __pyx_v_remote_func, ((PyObject *)__pyx_v_actor_ref), __pyx_v_args, __pyx_v_kwargs};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 6+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 638, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[7] = {__pyx_t_4, __pyx_v_local_func, __pyx_v_redirect_func, __pyx_v_remote_func, ((PyObject *)__pyx_v_actor_ref), __pyx_v_args, __pyx_v_kwargs};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 6+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 638, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(6+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 638, __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_local_func);
          __Pyx_GIVEREF(__pyx_v_local_func);
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_local_func);
          __Pyx_INCREF(__pyx_v_redirect_func);
          __Pyx_GIVEREF(__pyx_v_redirect_func);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_redirect_func);
          __Pyx_INCREF(__pyx_v_remote_func);
          __Pyx_GIVEREF(__pyx_v_remote_func);
          PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_remote_func);
          __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_INCREF(__pyx_v_args);
          __Pyx_GIVEREF(__pyx_v_args);
          PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_5, __pyx_v_args);
          __Pyx_INCREF(__pyx_v_kwargs);
          __Pyx_GIVEREF(__pyx_v_kwargs);
          PyTuple_SET_ITEM(__pyx_t_6, 5+__pyx_t_5, __pyx_v_kwargs);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 638, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":639
 * 
 *     cpdef _dispatch(self, local_func, redirect_func, remote_func, ActorRef actor_ref, args, kwargs):
 *         if actor_ref.address is None or actor_ref.address == self.cluster_info.address:             # <<<<<<<<<<<<<<
 *             if self.cluster_info.n_process == 1:
 *                 send_to_index = self.pool.index
 */
  __pyx_t_8 = (__pyx_v_actor_ref->address == ((PyObject*)Py_None));
  __pyx_t_9 = (__pyx_t_8 != 0);
  if (!__pyx_t_9) {
  } else {
    __pyx_t_7 = __pyx_t_9;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_9 = (__Pyx_PyString_Equals(__pyx_v_actor_ref->address, __pyx_v_self->cluster_info->address, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 639, __pyx_L1_error)
  __pyx_t_8 = (__pyx_t_9 != 0);
  __pyx_t_7 = __pyx_t_8;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_7) {

    /* "mars/actors/pool/gevent_pool.pyx":640
 *     cpdef _dispatch(self, local_func, redirect_func, remote_func, ActorRef actor_ref, args, kwargs):
 *         if actor_ref.address is None or actor_ref.address == self.cluster_info.address:
 *             if self.cluster_info.n_process == 1:             # <<<<<<<<<<<<<<
 *                 send_to_index = self.pool.index
 *             else:
 */
    __pyx_t_7 = ((__pyx_v_self->cluster_info->n_process == 1) != 0);
    if (__pyx_t_7) {

      /* "mars/actors/pool/gevent_pool.pyx":641
 *         if actor_ref.address is None or actor_ref.address == self.cluster_info.address:
 *             if self.cluster_info.n_process == 1:
 *                 send_to_index = self.pool.index             # <<<<<<<<<<<<<<
 *             else:
 *                 send_to_index = self.distributor.distribute(actor_ref.uid)
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pool, __pyx_n_s_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 641, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_v_send_to_index = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":640
 *     cpdef _dispatch(self, local_func, redirect_func, remote_func, ActorRef actor_ref, args, kwargs):
 *         if actor_ref.address is None or actor_ref.address == self.cluster_info.address:
 *             if self.cluster_info.n_process == 1:             # <<<<<<<<<<<<<<
 *                 send_to_index = self.pool.index
 *             else:
 */
      goto __pyx_L6;
    }

    /* "mars/actors/pool/gevent_pool.pyx":643
 *                 send_to_index = self.pool.index
 *             else:
 *                 send_to_index = self.distributor.distribute(actor_ref.uid)             # <<<<<<<<<<<<<<
 *             if send_to_index == self.pool.index:
 *                 # send to local actor_pool
 */
    /*else*/ {
      __pyx_t_1 = __pyx_v_actor_ref->uid;
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyInt_From_int(((struct __pyx_vtabstruct_4mars_6actors_11distributor_Distributor *)__pyx_v_self->distributor->__pyx_vtab)->distribute(__pyx_v_self->distributor, __pyx_t_1, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 643, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_send_to_index = __pyx_t_2;
      __pyx_t_2 = 0;
    }
    __pyx_L6:;

    /* "mars/actors/pool/gevent_pool.pyx":644
 *             else:
 *                 send_to_index = self.distributor.distribute(actor_ref.uid)
 *             if send_to_index == self.pool.index:             # <<<<<<<<<<<<<<
 *                 # send to local actor_pool
 *                 return local_func(*args, **kwargs)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pool, __pyx_n_s_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 644, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_send_to_index, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 644, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 644, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_7) {

      /* "mars/actors/pool/gevent_pool.pyx":646
 *             if send_to_index == self.pool.index:
 *                 # send to local actor_pool
 *                 return local_func(*args, **kwargs)             # <<<<<<<<<<<<<<
 *             else:
 *                 return redirect_func(send_to_index, *args, **kwargs)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 646, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(__pyx_v_kwargs == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
        __PYX_ERR(0, 646, __pyx_L1_error)
      }
      if (likely(PyDict_CheckExact(__pyx_v_kwargs))) {
        __pyx_t_2 = PyDict_Copy(__pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 646, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_2 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_kwargs, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 646, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_local_func, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 646, __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_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L0;

      /* "mars/actors/pool/gevent_pool.pyx":644
 *             else:
 *                 send_to_index = self.distributor.distribute(actor_ref.uid)
 *             if send_to_index == self.pool.index:             # <<<<<<<<<<<<<<
 *                 # send to local actor_pool
 *                 return local_func(*args, **kwargs)
 */
    }

    /* "mars/actors/pool/gevent_pool.pyx":648
 *                 return local_func(*args, **kwargs)
 *             else:
 *                 return redirect_func(send_to_index, *args, **kwargs)             # <<<<<<<<<<<<<<
 *         else:
 *             if self.cluster_info.standalone:
 */
    /*else*/ {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 648, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_v_send_to_index);
      __Pyx_GIVEREF(__pyx_v_send_to_index);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_send_to_index);
      __pyx_t_2 = __Pyx_PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 648, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 648, __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;
      if (unlikely(__pyx_v_kwargs == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
        __PYX_ERR(0, 648, __pyx_L1_error)
      }
      if (likely(PyDict_CheckExact(__pyx_v_kwargs))) {
        __pyx_t_2 = PyDict_Copy(__pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 648, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_2 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_kwargs, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 648, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_redirect_func, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 648, __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_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L0;
    }

    /* "mars/actors/pool/gevent_pool.pyx":639
 * 
 *     cpdef _dispatch(self, local_func, redirect_func, remote_func, ActorRef actor_ref, args, kwargs):
 *         if actor_ref.address is None or actor_ref.address == self.cluster_info.address:             # <<<<<<<<<<<<<<
 *             if self.cluster_info.n_process == 1:
 *                 send_to_index = self.pool.index
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":650
 *                 return redirect_func(send_to_index, *args, **kwargs)
 *         else:
 *             if self.cluster_info.standalone:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Not allow to send message to remote in standalone mode')
 * 
 */
  /*else*/ {
    __pyx_t_7 = (__pyx_v_self->cluster_info->standalone != 0);
    if (unlikely(__pyx_t_7)) {

      /* "mars/actors/pool/gevent_pool.pyx":651
 *         else:
 *             if self.cluster_info.standalone:
 *                 raise ValueError('Not allow to send message to remote in standalone mode')             # <<<<<<<<<<<<<<
 * 
 *             return remote_func(*args, **kwargs)
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 651, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(0, 651, __pyx_L1_error)

      /* "mars/actors/pool/gevent_pool.pyx":650
 *                 return redirect_func(send_to_index, *args, **kwargs)
 *         else:
 *             if self.cluster_info.standalone:             # <<<<<<<<<<<<<<
 *                 raise ValueError('Not allow to send message to remote in standalone mode')
 * 
 */
    }

    /* "mars/actors/pool/gevent_pool.pyx":653
 *                 raise ValueError('Not allow to send message to remote in standalone mode')
 * 
 *             return remote_func(*args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     def _send_local(self, ActorRef actor_ref, object message, bint wait_response=True,
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 653, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__pyx_v_kwargs == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
      __PYX_ERR(0, 653, __pyx_L1_error)
    }
    if (likely(PyDict_CheckExact(__pyx_v_kwargs))) {
      __pyx_t_2 = PyDict_Copy(__pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 653, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    } else {
      __pyx_t_2 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_kwargs, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 653, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_remote_func, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 653, __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_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "mars/actors/pool/gevent_pool.pyx":638
 *         }
 * 
 *     cpdef _dispatch(self, local_func, redirect_func, remote_func, ActorRef actor_ref, args, kwargs):             # <<<<<<<<<<<<<<
 *         if actor_ref.address is None or actor_ref.address == self.cluster_info.address:
 *             if self.cluster_info.n_process == 1:
 */

  /* 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_6);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._dispatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_send_to_index);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_3_dispatch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_3_dispatch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_local_func = 0;
  PyObject *__pyx_v_redirect_func = 0;
  PyObject *__pyx_v_remote_func = 0;
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_dispatch (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_local_func,&__pyx_n_s_redirect_func,&__pyx_n_s_remote_func,&__pyx_n_s_actor_ref,&__pyx_n_s_args,&__pyx_n_s_kwargs,0};
    PyObject* values[6] = {0,0,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  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_local_func)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_redirect_func)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_dispatch", 1, 6, 6, 1); __PYX_ERR(0, 638, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_remote_func)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_dispatch", 1, 6, 6, 2); __PYX_ERR(0, 638, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_dispatch", 1, 6, 6, 3); __PYX_ERR(0, 638, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_dispatch", 1, 6, 6, 4); __PYX_ERR(0, 638, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_dispatch", 1, 6, 6, 5); __PYX_ERR(0, 638, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_dispatch") < 0)) __PYX_ERR(0, 638, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
      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);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
    }
    __pyx_v_local_func = values[0];
    __pyx_v_redirect_func = values[1];
    __pyx_v_remote_func = values[2];
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[3]);
    __pyx_v_args = values[4];
    __pyx_v_kwargs = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_dispatch", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 638, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._dispatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 638, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_2_dispatch(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_local_func, __pyx_v_redirect_func, __pyx_v_remote_func, __pyx_v_actor_ref, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_2_dispatch(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_local_func, PyObject *__pyx_v_redirect_func, PyObject *__pyx_v_remote_func, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_dispatch", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__dispatch(__pyx_v_self, __pyx_v_local_func, __pyx_v_redirect_func, __pyx_v_remote_func, __pyx_v_actor_ref, __pyx_v_args, __pyx_v_kwargs, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 638, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._dispatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":655
 *             return remote_func(*args, **kwargs)
 * 
 *     def _send_local(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                     bint wait=True, object callback=None):
 *         cdef ActorExecutionContext actor_ctx
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_5_send_local(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_5_send_local(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_message = 0;
  int __pyx_v_wait_response;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_send_local (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_message,&__pyx_n_s_wait_response,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[5] = {0,0,0,0,0};

    /* "mars/actors/pool/gevent_pool.pyx":656
 * 
 *     def _send_local(self, ActorRef actor_ref, object message, bint wait_response=True,
 *                     bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef ActorExecutionContext actor_ctx
 *         cdef object p
 */
    values[4] = ((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  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_send_local", 0, 2, 5, 1); __PYX_ERR(0, 655, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait_response);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_send_local") < 0)) __PYX_ERR(0, 655, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    __pyx_v_message = values[1];
    if (values[2]) {
      __pyx_v_wait_response = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_wait_response == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 655, __pyx_L3_error)
    } else {

      /* "mars/actors/pool/gevent_pool.pyx":655
 *             return remote_func(*args, **kwargs)
 * 
 *     def _send_local(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                     bint wait=True, object callback=None):
 *         cdef ActorExecutionContext actor_ctx
 */
      __pyx_v_wait_response = ((int)1);
    }
    if (values[3]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 656, __pyx_L3_error)
    } else {

      /* "mars/actors/pool/gevent_pool.pyx":656
 * 
 *     def _send_local(self, ActorRef actor_ref, object message, bint wait_response=True,
 *                     bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef ActorExecutionContext actor_ctx
 *         cdef object p
 */
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_send_local", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 655, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._send_local", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 655, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_4_send_local(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_message, __pyx_v_wait_response, __pyx_v_wait, __pyx_v_callback);

  /* "mars/actors/pool/gevent_pool.pyx":655
 *             return remote_func(*args, **kwargs)
 * 
 *     def _send_local(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                     bint wait=True, object callback=None):
 *         cdef ActorExecutionContext actor_ctx
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":679
 *         if wait_response:
 *             # send, not wait
 *             def on_success(g):             # <<<<<<<<<<<<<<
 *                 ret = g.value
 *                 if callback:
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send_local_1on_success(PyObject *__pyx_self, PyObject *__pyx_v_g); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send_local_1on_success = {"on_success", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send_local_1on_success, METH_O, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send_local_1on_success(PyObject *__pyx_self, PyObject *__pyx_v_g) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("on_success (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send_local_on_success(__pyx_self, ((PyObject *)__pyx_v_g));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send_local_on_success(PyObject *__pyx_self, PyObject *__pyx_v_g) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local *__pyx_outer_scope;
  PyObject *__pyx_v_ret = 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;
  __Pyx_RefNannySetupContext("on_success", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":680
 *             # send, not wait
 *             def on_success(g):
 *                 ret = g.value             # <<<<<<<<<<<<<<
 *                 if callback:
 *                     callback(ret)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 680, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_ret = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":681
 *             def on_success(g):
 *                 ret = g.value
 *                 if callback:             # <<<<<<<<<<<<<<
 *                     callback(ret)
 *                 future.set_result(ret)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_callback)) { __Pyx_RaiseClosureNameError("callback"); __PYX_ERR(0, 681, __pyx_L1_error) }
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_callback); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 681, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "mars/actors/pool/gevent_pool.pyx":682
 *                 ret = g.value
 *                 if callback:
 *                     callback(ret)             # <<<<<<<<<<<<<<
 *                 future.set_result(ret)
 * 
 */
    if (unlikely(!__pyx_cur_scope->__pyx_v_callback)) { __Pyx_RaiseClosureNameError("callback"); __PYX_ERR(0, 682, __pyx_L1_error) }
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_callback);
    __pyx_t_3 = __pyx_cur_scope->__pyx_v_callback; __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_ret) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_ret);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 682, __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;

    /* "mars/actors/pool/gevent_pool.pyx":681
 *             def on_success(g):
 *                 ret = g.value
 *                 if callback:             # <<<<<<<<<<<<<<
 *                     callback(ret)
 *                 future.set_result(ret)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":683
 *                 if callback:
 *                     callback(ret)
 *                 future.set_result(ret)             # <<<<<<<<<<<<<<
 * 
 *             def on_failure(g):
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_future)) { __Pyx_RaiseClosureNameError("future"); __PYX_ERR(0, 683, __pyx_L1_error) }
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_future, __pyx_n_s_set_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 683, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_ret) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_ret);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 683, __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;

  /* "mars/actors/pool/gevent_pool.pyx":679
 *         if wait_response:
 *             # send, not wait
 *             def on_success(g):             # <<<<<<<<<<<<<<
 *                 ret = g.value
 *                 if 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_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._send_local.on_success", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":685
 *                 future.set_result(ret)
 * 
 *             def on_failure(g):             # <<<<<<<<<<<<<<
 *                 try:
 *                     g.get()
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send_local_3on_failure(PyObject *__pyx_self, PyObject *__pyx_v_g); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send_local_3on_failure = {"on_failure", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send_local_3on_failure, METH_O, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send_local_3on_failure(PyObject *__pyx_self, PyObject *__pyx_v_g) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("on_failure (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send_local_2on_failure(__pyx_self, ((PyObject *)__pyx_v_g));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send_local_2on_failure(PyObject *__pyx_self, PyObject *__pyx_v_g) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local *__pyx_outer_scope;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_ex = NULL;
  PyObject *__pyx_v_tb = 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;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *(*__pyx_t_12)(PyObject *);
  __Pyx_RefNannySetupContext("on_failure", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":686
 * 
 *             def on_failure(g):
 *                 try:             # <<<<<<<<<<<<<<
 *                     g.get()
 *                 except:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __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:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":687
 *             def on_failure(g):
 *                 try:
 *                     g.get()             # <<<<<<<<<<<<<<
 *                 except:
 *                     t, ex, tb = sys.exc_info()
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_g, __pyx_n_s_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 687, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && 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 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 687, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":686
 * 
 *             def on_failure(g):
 *                 try:             # <<<<<<<<<<<<<<
 *                     g.get()
 *                 except:
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __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;

    /* "mars/actors/pool/gevent_pool.pyx":688
 *                 try:
 *                     g.get()
 *                 except:             # <<<<<<<<<<<<<<
 *                     t, ex, tb = sys.exc_info()
 *                     future.set_exception(ex, exc_info=(t, ex, tb))
 */
    /*except:*/ {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._send_local.on_failure", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 688, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_6);

      /* "mars/actors/pool/gevent_pool.pyx":689
 *                     g.get()
 *                 except:
 *                     t, ex, tb = sys.exc_info()             # <<<<<<<<<<<<<<
 *                     future.set_exception(ex, exc_info=(t, ex, tb))
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_sys); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 689, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 689, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && 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_7 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_9);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 689, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) {
        PyObject* sequence = __pyx_t_7;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 689, __pyx_L5_except_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_9 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_10 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_10);
        #else
        __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 689, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 689, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 689, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_10);
        #endif
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 689, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_9 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_9)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_9);
        index = 1; __pyx_t_8 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_8)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_8);
        index = 2; __pyx_t_10 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_10);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 3) < 0) __PYX_ERR(0, 689, __pyx_L5_except_error)
        __pyx_t_12 = NULL;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L12_unpacking_done;
        __pyx_L11_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_12 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 689, __pyx_L5_except_error)
        __pyx_L12_unpacking_done:;
      }
      __pyx_v_t = __pyx_t_9;
      __pyx_t_9 = 0;
      __pyx_v_ex = __pyx_t_8;
      __pyx_t_8 = 0;
      __pyx_v_tb = __pyx_t_10;
      __pyx_t_10 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":690
 *                 except:
 *                     t, ex, tb = sys.exc_info()
 *                     future.set_exception(ex, exc_info=(t, ex, tb))             # <<<<<<<<<<<<<<
 * 
 *             p.link_value(on_success)
 */
      if (unlikely(!__pyx_cur_scope->__pyx_v_future)) { __Pyx_RaiseClosureNameError("future"); __PYX_ERR(0, 690, __pyx_L5_except_error) }
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_future, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 690, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 690, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_v_ex);
      __Pyx_GIVEREF(__pyx_v_ex);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_ex);
      __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 690, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 690, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_v_t);
      __Pyx_GIVEREF(__pyx_v_t);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_t);
      __Pyx_INCREF(__pyx_v_ex);
      __Pyx_GIVEREF(__pyx_v_ex);
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_ex);
      __Pyx_INCREF(__pyx_v_tb);
      __Pyx_GIVEREF(__pyx_v_tb);
      PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_v_tb);
      if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_exc_info, __pyx_t_9) < 0) __PYX_ERR(0, 690, __pyx_L5_except_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 690, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":686
 * 
 *             def on_failure(g):
 *                 try:             # <<<<<<<<<<<<<<
 *                     g.get()
 *                 except:
 */
    __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_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);
    __pyx_L8_try_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":685
 *                 future.set_result(ret)
 * 
 *             def on_failure(g):             # <<<<<<<<<<<<<<
 *                 try:
 *                     g.get()
 */

  /* 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_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._send_local.on_failure", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_ex);
  __Pyx_XDECREF(__pyx_v_tb);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":655
 *             return remote_func(*args, **kwargs)
 * 
 *     def _send_local(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                     bint wait=True, object callback=None):
 *         cdef ActorExecutionContext actor_ctx
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_4_send_local(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait_response, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_actor_ctx = 0;
  PyObject *__pyx_v_p = 0;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_message_ctx = 0;
  PyObject *__pyx_v_on_success = 0;
  PyObject *__pyx_v_on_failure = 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;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("_send_local", 0);
  __pyx_cur_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local *)__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local(__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 655, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __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);

  /* "mars/actors/pool/gevent_pool.pyx":663
 * 
 *         # send to self's actor pool
 *         actor_ctx = self.pool.get_actor_execution_ctx(actor_ref.uid)             # <<<<<<<<<<<<<<
 *         message_ctx = MessageContext(message)
 *         actor_ctx.receive(message_ctx)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pool, __pyx_n_s_get_actor_execution_ctx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 663, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_actor_ref->uid) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_actor_ref->uid);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 663, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext))))) __PYX_ERR(0, 663, __pyx_L1_error)
  __pyx_v_actor_ctx = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":664
 *         # send to self's actor pool
 *         actor_ctx = self.pool.get_actor_execution_ctx(actor_ref.uid)
 *         message_ctx = MessageContext(message)             # <<<<<<<<<<<<<<
 *         actor_ctx.receive(message_ctx)
 *         gevent.spawn(actor_ctx.fire_run)
 */
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_MessageContext), __pyx_v_message); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 664, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_message_ctx = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":665
 *         actor_ctx = self.pool.get_actor_execution_ctx(actor_ref.uid)
 *         message_ctx = MessageContext(message)
 *         actor_ctx.receive(message_ctx)             # <<<<<<<<<<<<<<
 *         gevent.spawn(actor_ctx.fire_run)
 *         p = gevent.spawn(message_ctx.result)
 */
  ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_actor_ctx->__pyx_vtab)->receive(__pyx_v_actor_ctx, __pyx_v_message_ctx, 0);

  /* "mars/actors/pool/gevent_pool.pyx":666
 *         message_ctx = MessageContext(message)
 *         actor_ctx.receive(message_ctx)
 *         gevent.spawn(actor_ctx.fire_run)             # <<<<<<<<<<<<<<
 *         p = gevent.spawn(message_ctx.result)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 666, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_spawn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 666, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_actor_ctx), __pyx_n_s_fire_run); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 666, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 666, __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;

  /* "mars/actors/pool/gevent_pool.pyx":667
 *         actor_ctx.receive(message_ctx)
 *         gevent.spawn(actor_ctx.fire_run)
 *         p = gevent.spawn(message_ctx.result)             # <<<<<<<<<<<<<<
 * 
 *         if wait:
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_gevent); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 667, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_spawn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 667, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_message_ctx), __pyx_n_s_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 667, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 667, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_p = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":669
 *         p = gevent.spawn(message_ctx.result)
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             if wait_response:
 *                 return p.get()
 */
  __pyx_t_5 = (__pyx_v_wait != 0);
  if (__pyx_t_5) {

    /* "mars/actors/pool/gevent_pool.pyx":670
 * 
 *         if wait:
 *             if wait_response:             # <<<<<<<<<<<<<<
 *                 return p.get()
 *             else:
 */
    __pyx_t_5 = (__pyx_v_wait_response != 0);
    if (__pyx_t_5) {

      /* "mars/actors/pool/gevent_pool.pyx":671
 *         if wait:
 *             if wait_response:
 *                 return p.get()             # <<<<<<<<<<<<<<
 *             else:
 *                 return
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 671, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 671, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;

      /* "mars/actors/pool/gevent_pool.pyx":670
 * 
 *         if wait:
 *             if wait_response:             # <<<<<<<<<<<<<<
 *                 return p.get()
 *             else:
 */
    }

    /* "mars/actors/pool/gevent_pool.pyx":673
 *                 return p.get()
 *             else:
 *                 return             # <<<<<<<<<<<<<<
 * 
 *         future = gevent.event.AsyncResult()
 */
    /*else*/ {
      __Pyx_XDECREF(__pyx_r);
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
    }

    /* "mars/actors/pool/gevent_pool.pyx":669
 *         p = gevent.spawn(message_ctx.result)
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             if wait_response:
 *                 return p.get()
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":675
 *                 return
 * 
 *         future = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 * 
 *         if wait_response:
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 675, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_event); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 675, __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_AsyncResult); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 675, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 675, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_future = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":677
 *         future = gevent.event.AsyncResult()
 * 
 *         if wait_response:             # <<<<<<<<<<<<<<
 *             # send, not wait
 *             def on_success(g):
 */
  __pyx_t_5 = (__pyx_v_wait_response != 0);
  if (__pyx_t_5) {

    /* "mars/actors/pool/gevent_pool.pyx":679
 *         if wait_response:
 *             # send, not wait
 *             def on_success(g):             # <<<<<<<<<<<<<<
 *                 ret = g.value
 *                 if callback:
 */
    __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send_local_1on_success, 0, __pyx_n_s_send_local_locals_on_success, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__19)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 679, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_on_success = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":685
 *                 future.set_result(ret)
 * 
 *             def on_failure(g):             # <<<<<<<<<<<<<<
 *                 try:
 *                     g.get()
 */
    __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send_local_3on_failure, 0, __pyx_n_s_send_local_locals_on_failure, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__21)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 685, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_on_failure = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":692
 *                     future.set_exception(ex, exc_info=(t, ex, tb))
 * 
 *             p.link_value(on_success)             # <<<<<<<<<<<<<<
 *             p.link_exception(on_failure)
 *         else:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_link_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 692, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_on_success) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_on_success);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 692, __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;

    /* "mars/actors/pool/gevent_pool.pyx":693
 * 
 *             p.link_value(on_success)
 *             p.link_exception(on_failure)             # <<<<<<<<<<<<<<
 *         else:
 *             if callback:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_link_exception); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 693, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_on_failure) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_on_failure);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 693, __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;

    /* "mars/actors/pool/gevent_pool.pyx":677
 *         future = gevent.event.AsyncResult()
 * 
 *         if wait_response:             # <<<<<<<<<<<<<<
 *             # send, not wait
 *             def on_success(g):
 */
    goto __pyx_L5;
  }

  /* "mars/actors/pool/gevent_pool.pyx":695
 *             p.link_exception(on_failure)
 *         else:
 *             if callback:             # <<<<<<<<<<<<<<
 *                 callback(None)
 *             # tell, directly set future result None
 */
  /*else*/ {
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_callback); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 695, __pyx_L1_error)
    if (__pyx_t_5) {

      /* "mars/actors/pool/gevent_pool.pyx":696
 *         else:
 *             if callback:
 *                 callback(None)             # <<<<<<<<<<<<<<
 *             # tell, directly set future result None
 *             future.set_result(None)
 */
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_callback);
      __pyx_t_2 = __pyx_cur_scope->__pyx_v_callback; __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, Py_None) : __Pyx_PyObject_CallOneArg(__pyx_t_2, Py_None);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 696, __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;

      /* "mars/actors/pool/gevent_pool.pyx":695
 *             p.link_exception(on_failure)
 *         else:
 *             if callback:             # <<<<<<<<<<<<<<
 *                 callback(None)
 *             # tell, directly set future result None
 */
    }

    /* "mars/actors/pool/gevent_pool.pyx":698
 *                 callback(None)
 *             # tell, directly set future result None
 *             future.set_result(None)             # <<<<<<<<<<<<<<
 * 
 *         return future
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_future, __pyx_n_s_set_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 698, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, Py_None) : __Pyx_PyObject_CallOneArg(__pyx_t_2, Py_None);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 698, __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;
  }
  __pyx_L5:;

  /* "mars/actors/pool/gevent_pool.pyx":700
 *             future.set_result(None)
 * 
 *         return future             # <<<<<<<<<<<<<<
 * 
 *     def _send_process(self, int to_index, ActorRef actor_ref, message, bint wait_response=True,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_future);
  __pyx_r = __pyx_cur_scope->__pyx_v_future;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":655
 *             return remote_func(*args, **kwargs)
 * 
 *     def _send_local(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                     bint wait=True, object callback=None):
 *         cdef ActorExecutionContext actor_ctx
 */

  /* 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("mars.actors.pool.gevent_pool.Communicator._send_local", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_actor_ctx);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XDECREF((PyObject *)__pyx_v_message_ctx);
  __Pyx_XDECREF(__pyx_v_on_success);
  __Pyx_XDECREF(__pyx_v_on_failure);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":702
 *         return future
 * 
 *     def _send_process(self, int to_index, ActorRef actor_ref, message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, callback=None):
 *         cdef object func
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_7_send_process(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_7_send_process(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_to_index;
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_message = 0;
  int __pyx_v_wait_response;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_send_process (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_to_index,&__pyx_n_s_actor_ref,&__pyx_n_s_message,&__pyx_n_s_wait_response,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[6] = {0,0,0,0,0,0};

    /* "mars/actors/pool/gevent_pool.pyx":703
 * 
 *     def _send_process(self, int to_index, ActorRef actor_ref, message, bint wait_response=True,
 *                       bint wait=True, callback=None):             # <<<<<<<<<<<<<<
 *         cdef object func
 *         cdef list msg
 */
    values[5] = ((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  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_to_index)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_send_process", 0, 3, 6, 1); __PYX_ERR(0, 702, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_send_process", 0, 3, 6, 2); __PYX_ERR(0, 702, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait_response);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          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_process") < 0)) __PYX_ERR(0, 702, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        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_to_index = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_to_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 702, __pyx_L3_error)
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[1]);
    __pyx_v_message = values[2];
    if (values[3]) {
      __pyx_v_wait_response = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_wait_response == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 702, __pyx_L3_error)
    } else {

      /* "mars/actors/pool/gevent_pool.pyx":702
 *         return future
 * 
 *     def _send_process(self, int to_index, ActorRef actor_ref, message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, callback=None):
 *         cdef object func
 */
      __pyx_v_wait_response = ((int)1);
    }
    if (values[4]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 703, __pyx_L3_error)
    } else {

      /* "mars/actors/pool/gevent_pool.pyx":703
 * 
 *     def _send_process(self, int to_index, ActorRef actor_ref, message, bint wait_response=True,
 *                       bint wait=True, callback=None):             # <<<<<<<<<<<<<<
 *         cdef object func
 *         cdef list msg
 */
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_send_process", 0, 3, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 702, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._send_process", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 702, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_6_send_process(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_to_index, __pyx_v_actor_ref, __pyx_v_message, __pyx_v_wait_response, __pyx_v_wait, __pyx_v_callback);

  /* "mars/actors/pool/gevent_pool.pyx":702
 *         return future
 * 
 *     def _send_process(self, int to_index, ActorRef actor_ref, message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, callback=None):
 *         cdef object func
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":723
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipe.put(*message)
 *             self.future(message_id, future, callback=callback)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_13_send_process_1check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_12Communicator_13_send_process_1check = {"check", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_13_send_process_1check, METH_NOARGS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_13_send_process_1check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_13_send_process_check(__pyx_self);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_13_send_process_check(PyObject *__pyx_self) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process *__pyx_outer_scope;
  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;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future __pyx_t_5;
  __Pyx_RefNannySetupContext("check", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":724
 * 
 *         def check():
 *             self.pipe.put(*message)             # <<<<<<<<<<<<<<
 *             self.future(message_id, future, callback=callback)
 * 
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 724, __pyx_L1_error) }
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->pipe, __pyx_n_s_put); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 724, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (unlikely(!__pyx_cur_scope->__pyx_v_message)) { __Pyx_RaiseClosureNameError("message"); __PYX_ERR(0, 724, __pyx_L1_error) }
  __pyx_t_2 = __Pyx_PySequence_Tuple(__pyx_cur_scope->__pyx_v_message); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 724, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 724, __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_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":725
 *         def check():
 *             self.pipe.put(*message)
 *             self.future(message_id, future, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *         gevent.spawn(check)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 725, __pyx_L1_error) }
  if (unlikely(!__pyx_cur_scope->__pyx_v_message_id)) { __Pyx_RaiseClosureNameError("message_id"); __PYX_ERR(0, 725, __pyx_L1_error) }
  if (!(likely(PyBytes_CheckExact(__pyx_cur_scope->__pyx_v_message_id))||((__pyx_cur_scope->__pyx_v_message_id) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_cur_scope->__pyx_v_message_id)->tp_name), 0))) __PYX_ERR(0, 725, __pyx_L1_error)
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_message_id;
  __Pyx_INCREF(__pyx_t_3);
  if (unlikely(!__pyx_cur_scope->__pyx_v_future)) { __Pyx_RaiseClosureNameError("future"); __PYX_ERR(0, 725, __pyx_L1_error) }
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_future;
  __Pyx_INCREF(__pyx_t_2);
  if (unlikely(!__pyx_cur_scope->__pyx_v_callback)) { __Pyx_RaiseClosureNameError("callback"); __PYX_ERR(0, 725, __pyx_L1_error) }
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_callback;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_5.__pyx_n = 1;
  __pyx_t_5.callback = __pyx_t_1;
  __pyx_t_4 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.future(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_3), __pyx_t_2, 0, &__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 725, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":723
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipe.put(*message)
 *             self.future(message_id, future, 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_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._send_process.check", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":702
 *         return future
 * 
 *     def _send_process(self, int to_index, ActorRef actor_ref, message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, callback=None):
 *         cdef object func
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_6_send_process(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, int __pyx_v_to_index, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait_response, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process *__pyx_cur_scope;
  PyObject *__pyx_v_msg = 0;
  PyObject *__pyx_v_check = 0;
  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 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  __Pyx_RefNannySetupContext("_send_process", 0);
  __pyx_cur_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process *)__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process(__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 702, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_message = __pyx_v_message;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_message);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_message);
  __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);

  /* "mars/actors/pool/gevent_pool.pyx":708
 *         cdef object future
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if wait_response:
 *                 msg = pack_send_message(self.index, to_index, actor_ref, message)
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __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:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":709
 * 
 *         try:
 *             if wait_response:             # <<<<<<<<<<<<<<
 *                 msg = pack_send_message(self.index, to_index, actor_ref, message)
 *             else:
 */
      __pyx_t_4 = (__pyx_v_wait_response != 0);
      if (__pyx_t_4) {

        /* "mars/actors/pool/gevent_pool.pyx":710
 *         try:
 *             if wait_response:
 *                 msg = pack_send_message(self.index, to_index, actor_ref, message)             # <<<<<<<<<<<<<<
 *             else:
 *                 msg = pack_tell_message(self.index, to_index, actor_ref, message)
 */
        __pyx_t_5 = __pyx_cur_scope->__pyx_v_message;
        __Pyx_INCREF(__pyx_t_5);
        __pyx_t_6 = __pyx_f_4mars_6actors_4pool_8messages_pack_send_message(__pyx_cur_scope->__pyx_v_self->index, __pyx_v_to_index, __pyx_v_actor_ref, __pyx_t_5, 0, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 710, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (!(likely(PyList_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_6)->tp_name), 0))) __PYX_ERR(0, 710, __pyx_L3_error)
        __pyx_v_msg = ((PyObject*)__pyx_t_6);
        __pyx_t_6 = 0;

        /* "mars/actors/pool/gevent_pool.pyx":709
 * 
 *         try:
 *             if wait_response:             # <<<<<<<<<<<<<<
 *                 msg = pack_send_message(self.index, to_index, actor_ref, message)
 *             else:
 */
        goto __pyx_L9;
      }

      /* "mars/actors/pool/gevent_pool.pyx":712
 *                 msg = pack_send_message(self.index, to_index, actor_ref, message)
 *             else:
 *                 msg = pack_tell_message(self.index, to_index, actor_ref, message)             # <<<<<<<<<<<<<<
 *             message_id, message = msg[0], msg[1:]
 *         except (AttributeError, pickle.PickleError):
 */
      /*else*/ {
        __pyx_t_6 = __pyx_cur_scope->__pyx_v_message;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_5 = __pyx_f_4mars_6actors_4pool_8messages_pack_tell_message(__pyx_cur_scope->__pyx_v_self->index, __pyx_v_to_index, __pyx_v_actor_ref, __pyx_t_6, 0, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 712, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (!(likely(PyList_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(0, 712, __pyx_L3_error)
        __pyx_v_msg = ((PyObject*)__pyx_t_5);
        __pyx_t_5 = 0;
      }
      __pyx_L9:;

      /* "mars/actors/pool/gevent_pool.pyx":713
 *             else:
 *                 msg = pack_tell_message(self.index, to_index, actor_ref, message)
 *             message_id, message = msg[0], msg[1:]             # <<<<<<<<<<<<<<
 *         except (AttributeError, pickle.PickleError):
 *             raise pickle.PicklingError('Unable to pickle message {0}'.format(message))
 */
      if (unlikely(__pyx_v_msg == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 713, __pyx_L3_error)
      }
      __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_v_msg, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 713, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (unlikely(__pyx_v_msg == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 713, __pyx_L3_error)
      }
      __pyx_t_6 = __Pyx_PyList_GetSlice(__pyx_v_msg, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 713, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_cur_scope->__pyx_v_message_id = __pyx_t_5;
      __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_message);
      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_message, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_t_6 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":708
 *         cdef object future
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if wait_response:
 *                 msg = pack_send_message(self.index, to_index, actor_ref, message)
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":714
 *                 msg = pack_tell_message(self.index, to_index, actor_ref, message)
 *             message_id, message = msg[0], msg[1:]
 *         except (AttributeError, pickle.PickleError):             # <<<<<<<<<<<<<<
 *             raise pickle.PicklingError('Unable to pickle message {0}'.format(message))
 * 
 */
    __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_5, &__pyx_t_7);
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_pickle); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 714, __pyx_L5_except_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 714, __pyx_L5_except_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_6, __pyx_builtin_AttributeError) || __Pyx_PyErr_GivenExceptionMatches(__pyx_t_6, __pyx_t_9);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_ErrRestore(__pyx_t_6, __pyx_t_5, __pyx_t_7);
    __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_7 = 0;
    if (__pyx_t_10) {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._send_process", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 714, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_6);

      /* "mars/actors/pool/gevent_pool.pyx":715
 *             message_id, message = msg[0], msg[1:]
 *         except (AttributeError, pickle.PickleError):
 *             raise pickle.PicklingError('Unable to pickle message {0}'.format(message))             # <<<<<<<<<<<<<<
 * 
 *         if wait:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_pickle); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 715, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_PicklingError); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 715, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Unable_to_pickle_message_0, __pyx_n_s_format); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 715, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = NULL;
      if (CYTHON_UNPACK_METHODS && 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);
        }
      }
      __pyx_t_8 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_13, __pyx_cur_scope->__pyx_v_message) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_cur_scope->__pyx_v_message);
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 715, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      __pyx_t_9 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_12, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_8);
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 715, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __PYX_ERR(0, 715, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":708
 *         cdef object future
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             if wait_response:
 *                 msg = pack_send_message(self.index, to_index, actor_ref, message)
 */
    __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_L8_try_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":717
 *             raise pickle.PicklingError('Unable to pickle message {0}'.format(message))
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             self.pipe.put(*message)
 *             return self.submit(message_id)
 */
  __pyx_t_4 = (__pyx_v_wait != 0);
  if (__pyx_t_4) {

    /* "mars/actors/pool/gevent_pool.pyx":718
 * 
 *         if wait:
 *             self.pipe.put(*message)             # <<<<<<<<<<<<<<
 *             return self.submit(message_id)
 * 
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->pipe, __pyx_n_s_put); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 718, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_cur_scope->__pyx_v_message); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 718, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 718, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":719
 *         if wait:
 *             self.pipe.put(*message)
 *             return self.submit(message_id)             # <<<<<<<<<<<<<<
 * 
 *         future = gevent.event.AsyncResult()
 */
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(PyBytes_CheckExact(__pyx_cur_scope->__pyx_v_message_id))||((__pyx_cur_scope->__pyx_v_message_id) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_cur_scope->__pyx_v_message_id)->tp_name), 0))) __PYX_ERR(0, 719, __pyx_L1_error)
    __pyx_t_7 = __pyx_cur_scope->__pyx_v_message_id;
    __Pyx_INCREF(__pyx_t_7);
    __pyx_t_5 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.submit(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_7), 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 719, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":717
 *             raise pickle.PicklingError('Unable to pickle message {0}'.format(message))
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             self.pipe.put(*message)
 *             return self.submit(message_id)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":721
 *             return self.submit(message_id)
 * 
 *         future = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 * 
 *         def check():
 */
  __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_gevent); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_event); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_AsyncResult); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(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_5 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_cur_scope->__pyx_v_future = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":723
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipe.put(*message)
 *             self.future(message_id, future, callback=callback)
 */
  __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_12Communicator_13_send_process_1check, 0, __pyx_n_s_send_process_locals_check, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 723, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_check = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":727
 *             self.future(message_id, future, callback=callback)
 * 
 *         gevent.spawn(check)             # <<<<<<<<<<<<<<
 *         return future
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_gevent); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 727, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_spawn); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 727, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(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);
    }
  }
  __pyx_t_5 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_v_check) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_check);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 727, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":728
 * 
 *         gevent.spawn(check)
 *         return future             # <<<<<<<<<<<<<<
 * 
 *     cpdef object _send_remote(self, ActorRef actor_ref, object message,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_future);
  __pyx_r = __pyx_cur_scope->__pyx_v_future;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":702
 *         return future
 * 
 *     def _send_process(self, int to_index, ActorRef actor_ref, message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, callback=None):
 *         cdef object func
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._send_process", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XDECREF(__pyx_v_check);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":730
 *         return future
 * 
 *     cpdef object _send_remote(self, ActorRef actor_ref, object message,             # <<<<<<<<<<<<<<
 *                               bint wait_response=True, bint wait=True, object callback=None):
 *         if wait_response:
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_9_send_remote(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__send_remote(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__send_remote *__pyx_optional_args) {

  /* "mars/actors/pool/gevent_pool.pyx":731
 * 
 *     cpdef object _send_remote(self, ActorRef actor_ref, object message,
 *                               bint wait_response=True, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         if wait_response:
 *             return self.remote_handler.send(actor_ref, message, wait=wait, callback=callback)
 */
  int __pyx_v_wait_response = ((int)1);
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  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;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("_send_remote", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_wait_response = __pyx_optional_args->wait_response;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_wait = __pyx_optional_args->wait;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_callback = __pyx_optional_args->callback;
        }
      }
    }
  }

  /* "mars/actors/pool/gevent_pool.pyx":730
 *         return future
 * 
 *     cpdef object _send_remote(self, ActorRef actor_ref, object message,             # <<<<<<<<<<<<<<
 *                               bint wait_response=True, bint wait=True, object callback=None):
 *         if wait_response:
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send_remote); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 730, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_9_send_remote)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait_response); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 730, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 730, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_5 = __pyx_t_1; __pyx_t_6 = NULL;
        __pyx_t_7 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(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_7 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[6] = {__pyx_t_6, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_t_3, __pyx_t_4, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 730, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[6] = {__pyx_t_6, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_t_3, __pyx_t_4, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 730, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else
        #endif
        {
          __pyx_t_8 = PyTuple_New(5+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 730, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_INCREF(__pyx_v_message);
          __Pyx_GIVEREF(__pyx_v_message);
          PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_message);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_7, __pyx_t_4);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_8, 4+__pyx_t_7, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 730, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":732
 *     cpdef object _send_remote(self, ActorRef actor_ref, object message,
 *                               bint wait_response=True, bint wait=True, object callback=None):
 *         if wait_response:             # <<<<<<<<<<<<<<
 *             return self.remote_handler.send(actor_ref, message, wait=wait, callback=callback)
 *         else:
 */
  __pyx_t_9 = (__pyx_v_wait_response != 0);
  if (__pyx_t_9) {

    /* "mars/actors/pool/gevent_pool.pyx":733
 *                               bint wait_response=True, bint wait=True, object callback=None):
 *         if wait_response:
 *             return self.remote_handler.send(actor_ref, message, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 *         else:
 *             return self.remote_handler.tell(actor_ref, message, wait=wait, callback=callback)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->remote_handler, __pyx_n_s_send); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 733, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 733, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_actor_ref));
    __Pyx_INCREF(__pyx_v_message);
    __Pyx_GIVEREF(__pyx_v_message);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_message);
    __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 733, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 733, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_wait, __pyx_t_8) < 0) __PYX_ERR(0, 733, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 733, __pyx_L1_error)
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 733, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __pyx_t_8;
    __pyx_t_8 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":732
 *     cpdef object _send_remote(self, ActorRef actor_ref, object message,
 *                               bint wait_response=True, bint wait=True, object callback=None):
 *         if wait_response:             # <<<<<<<<<<<<<<
 *             return self.remote_handler.send(actor_ref, message, wait=wait, callback=callback)
 *         else:
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":735
 *             return self.remote_handler.send(actor_ref, message, wait=wait, callback=callback)
 *         else:
 *             return self.remote_handler.tell(actor_ref, message, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->remote_handler, __pyx_n_s_tell); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 735, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 735, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_actor_ref));
    __Pyx_INCREF(__pyx_v_message);
    __Pyx_GIVEREF(__pyx_v_message);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_message);
    __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 735, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 735, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_wait, __pyx_t_1) < 0) __PYX_ERR(0, 735, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 735, __pyx_L1_error)
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 735, __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_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "mars/actors/pool/gevent_pool.pyx":730
 *         return future
 * 
 *     cpdef object _send_remote(self, ActorRef actor_ref, object message,             # <<<<<<<<<<<<<<
 *                               bint wait_response=True, bint wait=True, object callback=None):
 *         if wait_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_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._send_remote", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_9_send_remote(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_9_send_remote(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_message = 0;
  int __pyx_v_wait_response;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_send_remote (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_message,&__pyx_n_s_wait_response,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[5] = {0,0,0,0,0};

    /* "mars/actors/pool/gevent_pool.pyx":731
 * 
 *     cpdef object _send_remote(self, ActorRef actor_ref, object message,
 *                               bint wait_response=True, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         if wait_response:
 *             return self.remote_handler.send(actor_ref, message, wait=wait, callback=callback)
 */
    values[4] = ((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  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_send_remote", 0, 2, 5, 1); __PYX_ERR(0, 730, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait_response);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_send_remote") < 0)) __PYX_ERR(0, 730, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    __pyx_v_message = values[1];
    if (values[2]) {
      __pyx_v_wait_response = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_wait_response == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 731, __pyx_L3_error)
    } else {
      __pyx_v_wait_response = ((int)1);
    }
    if (values[3]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 731, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_send_remote", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 730, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._send_remote", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 730, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_8_send_remote(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_message, __pyx_v_wait_response, __pyx_v_wait, __pyx_v_callback);

  /* "mars/actors/pool/gevent_pool.pyx":730
 *         return future
 * 
 *     cpdef object _send_remote(self, ActorRef actor_ref, object message,             # <<<<<<<<<<<<<<
 *                               bint wait_response=True, bint wait=True, object callback=None):
 *         if wait_response:
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_8_send_remote(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait_response, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__send_remote __pyx_t_2;
  __Pyx_RefNannySetupContext("_send_remote", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.wait_response = __pyx_v_wait_response;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Communicator->_send_remote(__pyx_v_self, __pyx_v_actor_ref, __pyx_v_message, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 730, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._send_remote", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":737
 *             return self.remote_handler.tell(actor_ref, message, wait=wait, callback=callback)
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                 bint wait=True, object callback=None):
 *         return self._dispatch(self._send_local, self._send_process, self._send_remote, actor_ref,
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__send *__pyx_optional_args) {
  int __pyx_v_wait_response = ((int)1);

  /* "mars/actors/pool/gevent_pool.pyx":738
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,
 *                 bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._dispatch(self._send_local, self._send_process, self._send_remote, actor_ref,
 *                               (actor_ref, message),
 */
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  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;
  __Pyx_RefNannySetupContext("_send", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_wait_response = __pyx_optional_args->wait_response;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_wait = __pyx_optional_args->wait;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_callback = __pyx_optional_args->callback;
        }
      }
    }
  }

  /* "mars/actors/pool/gevent_pool.pyx":737
 *             return self.remote_handler.tell(actor_ref, message, wait=wait, callback=callback)
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                 bint wait=True, object callback=None):
 *         return self._dispatch(self._send_local, self._send_process, self._send_remote, actor_ref,
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 737, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait_response); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 737, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 737, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_5 = __pyx_t_1; __pyx_t_6 = NULL;
        __pyx_t_7 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(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_7 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[6] = {__pyx_t_6, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_t_3, __pyx_t_4, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 737, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[6] = {__pyx_t_6, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_t_3, __pyx_t_4, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 5+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 737, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else
        #endif
        {
          __pyx_t_8 = PyTuple_New(5+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 737, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_INCREF(__pyx_v_message);
          __Pyx_GIVEREF(__pyx_v_message);
          PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_message);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_8, 3+__pyx_t_7, __pyx_t_4);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_8, 4+__pyx_t_7, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_4 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 737, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":739
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,
 *                 bint wait=True, object callback=None):
 *         return self._dispatch(self._send_local, self._send_process, self._send_remote, actor_ref,             # <<<<<<<<<<<<<<
 *                               (actor_ref, message),
 *                               dict(wait_response=wait_response, wait=wait, callback=callback))
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send_local); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 739, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send_process); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 739, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send_remote); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 739, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "mars/actors/pool/gevent_pool.pyx":740
 *                 bint wait=True, object callback=None):
 *         return self._dispatch(self._send_local, self._send_process, self._send_remote, actor_ref,
 *                               (actor_ref, message),             # <<<<<<<<<<<<<<
 *                               dict(wait_response=wait_response, wait=wait, callback=callback))
 * 
 */
  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
  PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_actor_ref));
  __Pyx_INCREF(__pyx_v_message);
  __Pyx_GIVEREF(__pyx_v_message);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_message);

  /* "mars/actors/pool/gevent_pool.pyx":741
 *         return self._dispatch(self._send_local, self._send_process, self._send_remote, actor_ref,
 *                               (actor_ref, message),
 *                               dict(wait_response=wait_response, wait=wait, callback=callback))             # <<<<<<<<<<<<<<
 * 
 *     cpdef send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):
 */
  __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 741, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait_response); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 741, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_wait_response, __pyx_t_3) < 0) __PYX_ERR(0, 741, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 741, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_wait, __pyx_t_3) < 0) __PYX_ERR(0, 741, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 741, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":739
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,
 *                 bint wait=True, object callback=None):
 *         return self._dispatch(self._send_local, self._send_process, self._send_remote, actor_ref,             # <<<<<<<<<<<<<<
 *                               (actor_ref, message),
 *                               dict(wait_response=wait_response, wait=wait, callback=callback))
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self->__pyx_base.__pyx_vtab)->_dispatch(__pyx_v_self, __pyx_t_1, __pyx_t_2, __pyx_t_5, __pyx_v_actor_ref, __pyx_t_8, __pyx_t_4, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 739, __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_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":737
 *             return self.remote_handler.tell(actor_ref, message, wait=wait, callback=callback)
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                 bint wait=True, object callback=None):
 *         return self._dispatch(self._send_local, self._send_process, self._send_remote, actor_ref,
 */

  /* 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_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_message = 0;
  int __pyx_v_wait_response;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_send (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_message,&__pyx_n_s_wait_response,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[5] = {0,0,0,0,0};

    /* "mars/actors/pool/gevent_pool.pyx":738
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,
 *                 bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._dispatch(self._send_local, self._send_process, self._send_remote, actor_ref,
 *                               (actor_ref, message),
 */
    values[4] = ((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  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_send", 0, 2, 5, 1); __PYX_ERR(0, 737, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait_response);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_send") < 0)) __PYX_ERR(0, 737, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    __pyx_v_message = values[1];
    if (values[2]) {
      __pyx_v_wait_response = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_wait_response == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 737, __pyx_L3_error)
    } else {

      /* "mars/actors/pool/gevent_pool.pyx":737
 *             return self.remote_handler.tell(actor_ref, message, wait=wait, callback=callback)
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                 bint wait=True, object callback=None):
 *         return self._dispatch(self._send_local, self._send_process, self._send_remote, actor_ref,
 */
      __pyx_v_wait_response = ((int)1);
    }
    if (values[3]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 738, __pyx_L3_error)
    } else {

      /* "mars/actors/pool/gevent_pool.pyx":738
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,
 *                 bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._dispatch(self._send_local, self._send_process, self._send_remote, actor_ref,
 *                               (actor_ref, message),
 */
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_send", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 737, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 737, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_10_send(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_message, __pyx_v_wait_response, __pyx_v_wait, __pyx_v_callback);

  /* "mars/actors/pool/gevent_pool.pyx":737
 *             return self.remote_handler.tell(actor_ref, message, wait=wait, callback=callback)
 * 
 *     cpdef _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                 bint wait=True, object callback=None):
 *         return self._dispatch(self._send_local, self._send_process, self._send_remote, actor_ref,
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_10_send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait_response, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__send __pyx_t_2;
  __Pyx_RefNannySetupContext("_send", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.wait_response = __pyx_v_wait_response;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Communicator->_send(__pyx_v_self, __pyx_v_actor_ref, __pyx_v_message, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 737, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":743
 *                               dict(wait_response=wait_response, wait=wait, callback=callback))
 * 
 *     cpdef send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_13send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator_send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_send *__pyx_optional_args) {
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  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;
  PyObject *__pyx_t_7 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__send __pyx_t_8;
  __Pyx_RefNannySetupContext("send", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_wait = __pyx_optional_args->wait;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_callback = __pyx_optional_args->callback;
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 743, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_13send)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 743, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        __pyx_t_6 = 0;
        if (CYTHON_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[5] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 4+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 743, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[5] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 4+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 743, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(4+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 743, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_INCREF(__pyx_v_message);
          __Pyx_GIVEREF(__pyx_v_message);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_message);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_6, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 743, __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_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":744
 * 
 *     cpdef send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_8.__pyx_n = 3;
  __pyx_t_8.wait_response = 1;
  __pyx_t_8.wait = __pyx_v_wait;
  __pyx_t_8.callback = __pyx_v_callback;
  __pyx_t_1 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self->__pyx_base.__pyx_vtab)->_send(__pyx_v_self, __pyx_v_actor_ref, __pyx_v_message, 0, &__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 744, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":743
 *                               dict(wait_response=wait_response, wait=wait, callback=callback))
 * 
 *     cpdef send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_13send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_13send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_message = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("send (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_message,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[4] = {0,0,0,0};
    values[3] = ((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);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("send", 0, 2, 4, 1); __PYX_ERR(0, 743, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "send") < 0)) __PYX_ERR(0, 743, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    __pyx_v_message = values[1];
    if (values[2]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 743, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("send", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 743, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 743, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_12send(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_message, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_12send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_send __pyx_t_2;
  __Pyx_RefNannySetupContext("send", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Communicator->send(__pyx_v_self, __pyx_v_actor_ref, __pyx_v_message, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 743, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":746
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *                bint wait=True, object callback=None):
 *         if delay is not None:
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_15tell(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator_tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_tell *__pyx_optional_args) {
  PyObject *__pyx_v_delay = ((PyObject *)Py_None);

  /* "mars/actors/pool/gevent_pool.pyx":747
 * 
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,
 *                bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         if delay is not None:
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 */
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  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;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__send __pyx_t_10;
  __Pyx_RefNannySetupContext("tell", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_delay = __pyx_optional_args->delay;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_wait = __pyx_optional_args->wait;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_callback = __pyx_optional_args->callback;
        }
      }
    }
  }

  /* "mars/actors/pool/gevent_pool.pyx":746
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *                bint wait=True, object callback=None):
 *         if delay is not None:
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 746, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_15tell)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 746, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        __pyx_t_6 = 0;
        if (CYTHON_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[6] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_v_delay, __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 746, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[6] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_v_delay, __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 746, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(5+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 746, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_INCREF(__pyx_v_message);
          __Pyx_GIVEREF(__pyx_v_message);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_message);
          __Pyx_INCREF(__pyx_v_delay);
          __Pyx_GIVEREF(__pyx_v_delay);
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_delay);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_7, 4+__pyx_t_6, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 746, __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_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":748
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,
 *                bint wait=True, object callback=None):
 *         if delay is not None:             # <<<<<<<<<<<<<<
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 *                                wait=wait, callback=callback)
 */
  __pyx_t_8 = (__pyx_v_delay != Py_None);
  __pyx_t_9 = (__pyx_t_8 != 0);
  if (__pyx_t_9) {

    /* "mars/actors/pool/gevent_pool.pyx":749
 *                bint wait=True, object callback=None):
 *         if delay is not None:
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,             # <<<<<<<<<<<<<<
 *                                wait=wait, callback=callback)
 *             return
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_spawn_later); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_delay);
    __Pyx_GIVEREF(__pyx_v_delay);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_delay);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
    PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_v_actor_ref));
    __Pyx_INCREF(__pyx_v_message);
    __Pyx_GIVEREF(__pyx_v_message);
    PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_message);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_wait_response, Py_False) < 0) __PYX_ERR(0, 749, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":750
 *         if delay is not None:
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 *                                wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 750, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_wait, __pyx_t_7) < 0) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 749, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":749
 *                bint wait=True, object callback=None):
 *         if delay is not None:
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,             # <<<<<<<<<<<<<<
 *                                wait=wait, callback=callback)
 *             return
 */
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __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;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":751
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 *                                wait=wait, callback=callback)
 *             return             # <<<<<<<<<<<<<<
 * 
 *         return self._send(actor_ref, message, wait_response=False, wait=wait, callback=callback)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":748
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,
 *                bint wait=True, object callback=None):
 *         if delay is not None:             # <<<<<<<<<<<<<<
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 *                                wait=wait, callback=callback)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":753
 *             return
 * 
 *         return self._send(actor_ref, message, wait_response=False, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *     cpdef object _create_local_actor(self, ActorRef actor_ref, actor_cls, args, kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_10.__pyx_n = 3;
  __pyx_t_10.wait_response = 0;
  __pyx_t_10.wait = __pyx_v_wait;
  __pyx_t_10.callback = __pyx_v_callback;
  __pyx_t_7 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self->__pyx_base.__pyx_vtab)->_send(__pyx_v_self, __pyx_v_actor_ref, __pyx_v_message, 0, &__pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 753, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":746
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *                bint wait=True, object callback=None):
 *         if delay is not None:
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.tell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_15tell(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_15tell(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_message = 0;
  PyObject *__pyx_v_delay = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tell (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_message,&__pyx_n_s_delay,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[2] = ((PyObject *)Py_None);

    /* "mars/actors/pool/gevent_pool.pyx":747
 * 
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,
 *                bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         if delay is not None:
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 */
    values[4] = ((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  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tell", 0, 2, 5, 1); __PYX_ERR(0, 746, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_delay);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tell") < 0)) __PYX_ERR(0, 746, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    __pyx_v_message = values[1];
    __pyx_v_delay = values[2];
    if (values[3]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 747, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("tell", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 746, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.tell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 746, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_14tell(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_message, __pyx_v_delay, __pyx_v_wait, __pyx_v_callback);

  /* "mars/actors/pool/gevent_pool.pyx":746
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 *     cpdef tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *                bint wait=True, object callback=None):
 *         if delay is not None:
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_14tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, PyObject *__pyx_v_delay, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_tell __pyx_t_2;
  __Pyx_RefNannySetupContext("tell", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.delay = __pyx_v_delay;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Communicator->tell(__pyx_v_self, __pyx_v_actor_ref, __pyx_v_message, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 746, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.tell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":755
 *         return self._send(actor_ref, message, wait_response=False, wait=wait, callback=callback)
 * 
 *     cpdef object _create_local_actor(self, ActorRef actor_ref, actor_cls, args, kwargs):             # <<<<<<<<<<<<<<
 *         cdef bint wait
 *         cdef object callback
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_17_create_local_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__create_local_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, int __pyx_skip_dispatch) {
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_v_future = 0;
  PyObject *__pyx_v_res = 0;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_ex = NULL;
  PyObject *__pyx_v_tb = 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;
  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;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *(*__pyx_t_14)(PyObject *);
  __Pyx_RefNannySetupContext("_create_local_actor", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_local_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 755, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_17_create_local_actor)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && 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);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[5] = {__pyx_t_4, ((PyObject *)__pyx_v_actor_ref), __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 755, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[5] = {__pyx_t_4, ((PyObject *)__pyx_v_actor_ref), __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 755, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 755, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_INCREF(__pyx_v_actor_cls);
          __Pyx_GIVEREF(__pyx_v_actor_cls);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_actor_cls);
          __Pyx_INCREF(__pyx_v_args);
          __Pyx_GIVEREF(__pyx_v_args);
          PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_args);
          __Pyx_INCREF(__pyx_v_kwargs);
          __Pyx_GIVEREF(__pyx_v_kwargs);
          PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_kwargs);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 755, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":761
 *         cdef object res
 * 
 *         wait = kwargs.pop('wait', True)             # <<<<<<<<<<<<<<
 *         callback = kwargs.pop('callback', None)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 761, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 761, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 761, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_wait = __pyx_t_7;

  /* "mars/actors/pool/gevent_pool.pyx":762
 * 
 *         wait = kwargs.pop('wait', True)
 *         callback = kwargs.pop('callback', None)             # <<<<<<<<<<<<<<
 * 
 *         if wait:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_callback = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":764
 *         callback = kwargs.pop('callback', None)
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             return self.pool.create_actor(actor_cls, actor_ref.uid, *args, **kwargs)
 * 
 */
  __pyx_t_7 = (__pyx_v_wait != 0);
  if (__pyx_t_7) {

    /* "mars/actors/pool/gevent_pool.pyx":765
 * 
 *         if wait:
 *             return self.pool.create_actor(actor_cls, actor_ref.uid, *args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *         future = gevent.event.AsyncResult()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pool, __pyx_n_s_create_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 765, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 765, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_actor_cls);
    __Pyx_GIVEREF(__pyx_v_actor_cls);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_actor_cls);
    __Pyx_INCREF(__pyx_v_actor_ref->uid);
    __Pyx_GIVEREF(__pyx_v_actor_ref->uid);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_actor_ref->uid);
    __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 765, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyNumber_Add(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 765, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(__pyx_v_kwargs == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
      __PYX_ERR(0, 765, __pyx_L1_error)
    }
    if (likely(PyDict_CheckExact(__pyx_v_kwargs))) {
      __pyx_t_3 = PyDict_Copy(__pyx_v_kwargs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 765, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      __pyx_t_3 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_kwargs, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 765, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 765, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":764
 *         callback = kwargs.pop('callback', None)
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             return self.pool.create_actor(actor_cls, actor_ref.uid, *args, **kwargs)
 * 
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":767
 *             return self.pool.create_actor(actor_cls, actor_ref.uid, *args, **kwargs)
 * 
 *         future = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 *         try:
 *             res = self.pool.create_actor(actor_cls, actor_ref.uid, *args, **kwargs)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_gevent); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_event); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_AsyncResult); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(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);
    }
  }
  __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_future = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":768
 * 
 *         future = gevent.event.AsyncResult()
 *         try:             # <<<<<<<<<<<<<<
 *             res = self.pool.create_actor(actor_cls, actor_ref.uid, *args, **kwargs)
 *             if callback:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __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:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":769
 *         future = gevent.event.AsyncResult()
 *         try:
 *             res = self.pool.create_actor(actor_cls, actor_ref.uid, *args, **kwargs)             # <<<<<<<<<<<<<<
 *             if callback:
 *                 callback(res)
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pool, __pyx_n_s_create_actor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 769, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 769, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_v_actor_cls);
      __Pyx_GIVEREF(__pyx_v_actor_cls);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_actor_cls);
      __Pyx_INCREF(__pyx_v_actor_ref->uid);
      __Pyx_GIVEREF(__pyx_v_actor_ref->uid);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_actor_ref->uid);
      __pyx_t_6 = __Pyx_PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 769, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 769, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(__pyx_v_kwargs == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
        __PYX_ERR(0, 769, __pyx_L4_error)
      }
      if (likely(PyDict_CheckExact(__pyx_v_kwargs))) {
        __pyx_t_6 = PyDict_Copy(__pyx_v_kwargs); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 769, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        __pyx_t_6 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_kwargs, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 769, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 769, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_res = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":770
 *         try:
 *             res = self.pool.create_actor(actor_cls, actor_ref.uid, *args, **kwargs)
 *             if callback:             # <<<<<<<<<<<<<<
 *                 callback(res)
 *             future.set_result(res)
 */
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 770, __pyx_L4_error)
      if (__pyx_t_7) {

        /* "mars/actors/pool/gevent_pool.pyx":771
 *             res = self.pool.create_actor(actor_cls, actor_ref.uid, *args, **kwargs)
 *             if callback:
 *                 callback(res)             # <<<<<<<<<<<<<<
 *             future.set_result(res)
 *         except:
 */
        __Pyx_INCREF(__pyx_v_callback);
        __pyx_t_6 = __pyx_v_callback; __pyx_t_1 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
          }
        }
        __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_1, __pyx_v_res) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_res);
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 771, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "mars/actors/pool/gevent_pool.pyx":770
 *         try:
 *             res = self.pool.create_actor(actor_cls, actor_ref.uid, *args, **kwargs)
 *             if callback:             # <<<<<<<<<<<<<<
 *                 callback(res)
 *             future.set_result(res)
 */
      }

      /* "mars/actors/pool/gevent_pool.pyx":772
 *             if callback:
 *                 callback(res)
 *             future.set_result(res)             # <<<<<<<<<<<<<<
 *         except:
 *             t, ex, tb = sys.exc_info()
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_future, __pyx_n_s_set_result); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 772, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_1, __pyx_v_res) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_res);
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 772, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":768
 * 
 *         future = gevent.event.AsyncResult()
 *         try:             # <<<<<<<<<<<<<<
 *             res = self.pool.create_actor(actor_cls, actor_ref.uid, *args, **kwargs)
 *             if callback:
 */
    }
    __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_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":773
 *                 callback(res)
 *             future.set_result(res)
 *         except:             # <<<<<<<<<<<<<<
 *             t, ex, tb = sys.exc_info()
 *             future.set_exception(ex, exc_info=(t, ex, tb))
 */
    /*except:*/ {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._create_local_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_6, &__pyx_t_1) < 0) __PYX_ERR(0, 773, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_1);

      /* "mars/actors/pool/gevent_pool.pyx":774
 *             future.set_result(res)
 *         except:
 *             t, ex, tb = sys.exc_info()             # <<<<<<<<<<<<<<
 *             future.set_exception(ex, exc_info=(t, ex, tb))
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_sys); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 774, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 774, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_11);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 774, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
        PyObject* sequence = __pyx_t_2;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 774, __pyx_L6_except_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_11 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_12);
        #else
        __pyx_t_11 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 774, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 774, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_12 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 774, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_13 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 774, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_14 = Py_TYPE(__pyx_t_13)->tp_iternext;
        index = 0; __pyx_t_11 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_11)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_11);
        index = 1; __pyx_t_4 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_4)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 2; __pyx_t_12 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_12)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_12);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_13), 3) < 0) __PYX_ERR(0, 774, __pyx_L6_except_error)
        __pyx_t_14 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L14_unpacking_done;
        __pyx_L13_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_14 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 774, __pyx_L6_except_error)
        __pyx_L14_unpacking_done:;
      }
      __pyx_v_t = __pyx_t_11;
      __pyx_t_11 = 0;
      __pyx_v_ex = __pyx_t_4;
      __pyx_t_4 = 0;
      __pyx_v_tb = __pyx_t_12;
      __pyx_t_12 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":775
 *         except:
 *             t, ex, tb = sys.exc_info()
 *             future.set_exception(ex, exc_info=(t, ex, tb))             # <<<<<<<<<<<<<<
 * 
 *         return future
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_future, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 775, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 775, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_v_ex);
      __Pyx_GIVEREF(__pyx_v_ex);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_ex);
      __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 775, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 775, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_INCREF(__pyx_v_t);
      __Pyx_GIVEREF(__pyx_v_t);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_t);
      __Pyx_INCREF(__pyx_v_ex);
      __Pyx_GIVEREF(__pyx_v_ex);
      PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_v_ex);
      __Pyx_INCREF(__pyx_v_tb);
      __Pyx_GIVEREF(__pyx_v_tb);
      PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_v_tb);
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_exc_info, __pyx_t_11) < 0) __PYX_ERR(0, 775, __pyx_L6_except_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, __pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 775, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L5_exception_handled;
    }
    __pyx_L6_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":768
 * 
 *         future = gevent.event.AsyncResult()
 *         try:             # <<<<<<<<<<<<<<
 *             res = self.pool.create_actor(actor_cls, actor_ref.uid, *args, **kwargs)
 *             if callback:
 */
    __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_L5_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_L9_try_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":777
 *             future.set_exception(ex, exc_info=(t, ex, tb))
 * 
 *         return future             # <<<<<<<<<<<<<<
 * 
 *     def _create_process_actor(self, int to_index, ActorRef actor_ref, object actor_cls,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_future);
  __pyx_r = __pyx_v_future;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":755
 *         return self._send(actor_ref, message, wait_response=False, wait=wait, callback=callback)
 * 
 *     cpdef object _create_local_actor(self, ActorRef actor_ref, actor_cls, args, kwargs):             # <<<<<<<<<<<<<<
 *         cdef bint wait
 *         cdef object callback
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._create_local_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_callback);
  __Pyx_XDECREF(__pyx_v_future);
  __Pyx_XDECREF(__pyx_v_res);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_ex);
  __Pyx_XDECREF(__pyx_v_tb);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_17_create_local_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_17_create_local_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_actor_cls = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_create_local_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_actor_cls,&__pyx_n_s_args,&__pyx_n_s_kwargs,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);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_cls)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_local_actor", 1, 4, 4, 1); __PYX_ERR(0, 755, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_local_actor", 1, 4, 4, 2); __PYX_ERR(0, 755, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_local_actor", 1, 4, 4, 3); __PYX_ERR(0, 755, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_create_local_actor") < 0)) __PYX_ERR(0, 755, __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_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    __pyx_v_actor_cls = values[1];
    __pyx_v_args = values[2];
    __pyx_v_kwargs = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_create_local_actor", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 755, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._create_local_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 755, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_16_create_local_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_16_create_local_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_create_local_actor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__create_local_actor(__pyx_v_self, __pyx_v_actor_ref, __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 755, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._create_local_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":779
 *         return future
 * 
 *     def _create_process_actor(self, int to_index, ActorRef actor_ref, object actor_cls,             # <<<<<<<<<<<<<<
 *                               args, kwargs):
 *         cdef bint wait
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_19_create_process_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_19_create_process_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_to_index;
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_actor_cls = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_create_process_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_to_index,&__pyx_n_s_actor_ref,&__pyx_n_s_actor_cls,&__pyx_n_s_args,&__pyx_n_s_kwargs,0};
    PyObject* values[5] = {0,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  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_to_index)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_process_actor", 1, 5, 5, 1); __PYX_ERR(0, 779, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_cls)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_process_actor", 1, 5, 5, 2); __PYX_ERR(0, 779, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_process_actor", 1, 5, 5, 3); __PYX_ERR(0, 779, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_process_actor", 1, 5, 5, 4); __PYX_ERR(0, 779, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_create_process_actor") < 0)) __PYX_ERR(0, 779, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
      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);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
    }
    __pyx_v_to_index = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_to_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 779, __pyx_L3_error)
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[1]);
    __pyx_v_actor_cls = values[2];
    __pyx_v_args = values[3];
    __pyx_v_kwargs = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_create_process_actor", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 779, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._create_process_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 779, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_18_create_process_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_to_index, __pyx_v_actor_ref, __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":803
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             self.future(message_id, future, callback=callback)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_21_create_process_actor_1check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_12Communicator_21_create_process_actor_1check = {"check", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_21_create_process_actor_1check, METH_NOARGS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_21_create_process_actor_1check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_21_create_process_actor_check(__pyx_self);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_21_create_process_actor_check(PyObject *__pyx_self) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor *__pyx_outer_scope;
  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;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future __pyx_t_5;
  __Pyx_RefNannySetupContext("check", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":804
 * 
 *         def check():
 *             self.pipe.put(message)             # <<<<<<<<<<<<<<
 *             self.future(message_id, future, callback=callback)
 * 
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 804, __pyx_L1_error) }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->pipe, __pyx_n_s_put); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 804, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(!__pyx_cur_scope->__pyx_v_message)) { __Pyx_RaiseClosureNameError("message"); __PYX_ERR(0, 804, __pyx_L1_error) }
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_cur_scope->__pyx_v_message) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_cur_scope->__pyx_v_message);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 804, __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;

  /* "mars/actors/pool/gevent_pool.pyx":805
 *         def check():
 *             self.pipe.put(message)
 *             self.future(message_id, future, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *         gevent.spawn(check)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 805, __pyx_L1_error) }
  if (unlikely(!__pyx_cur_scope->__pyx_v_message_id)) { __Pyx_RaiseClosureNameError("message_id"); __PYX_ERR(0, 805, __pyx_L1_error) }
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_message_id;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(!__pyx_cur_scope->__pyx_v_future)) { __Pyx_RaiseClosureNameError("future"); __PYX_ERR(0, 805, __pyx_L1_error) }
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_future;
  __Pyx_INCREF(__pyx_t_2);
  if (unlikely(!__pyx_cur_scope->__pyx_v_callback)) { __Pyx_RaiseClosureNameError("callback"); __PYX_ERR(0, 805, __pyx_L1_error) }
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_callback;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_5.__pyx_n = 1;
  __pyx_t_5.callback = __pyx_t_3;
  __pyx_t_4 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.future(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_1), __pyx_t_2, 0, &__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 805, __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_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":803
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             self.future(message_id, future, 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_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._create_process_actor.check", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":779
 *         return future
 * 
 *     def _create_process_actor(self, int to_index, ActorRef actor_ref, object actor_cls,             # <<<<<<<<<<<<<<
 *                               args, kwargs):
 *         cdef bint wait
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_18_create_process_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, int __pyx_v_to_index, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor *__pyx_cur_scope;
  int __pyx_v_wait;
  PyObject *__pyx_v_check = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  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;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  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;
  __Pyx_RefNannySetupContext("_create_process_actor", 0);
  __pyx_cur_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor *)__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor(__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 779, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);

  /* "mars/actors/pool/gevent_pool.pyx":787
 *         cdef object future
 * 
 *         wait = kwargs.pop('wait', True)             # <<<<<<<<<<<<<<
 *         callback = kwargs.pop('callback', None)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 787, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 787, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 787, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_wait = __pyx_t_3;

  /* "mars/actors/pool/gevent_pool.pyx":788
 * 
 *         wait = kwargs.pop('wait', True)
 *         callback = kwargs.pop('callback', None)             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_kwargs, __pyx_n_s_pop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_callback = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":790
 *         callback = kwargs.pop('callback', None)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             message_id, message = pack_create_actor_message(
 *                 self.index, to_index, actor_ref, actor_cls, args, kwargs)
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":792
 *         try:
 *             message_id, message = pack_create_actor_message(
 *                 self.index, to_index, actor_ref, actor_cls, args, kwargs)             # <<<<<<<<<<<<<<
 *         except (AttributeError, pickle.PickleError):
 *             raise pickle.PicklingError('Unable to pickle {0}(*{1}, **{2})'.format(actor_cls, args, kwargs))
 */
      if (!(likely(PyTuple_CheckExact(__pyx_v_args))||((__pyx_v_args) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v_args)->tp_name), 0))) __PYX_ERR(0, 792, __pyx_L3_error)
      if (!(likely(PyDict_CheckExact(__pyx_v_kwargs))||((__pyx_v_kwargs) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_kwargs)->tp_name), 0))) __PYX_ERR(0, 792, __pyx_L3_error)

      /* "mars/actors/pool/gevent_pool.pyx":791
 * 
 *         try:
 *             message_id, message = pack_create_actor_message(             # <<<<<<<<<<<<<<
 *                 self.index, to_index, actor_ref, actor_cls, args, kwargs)
 *         except (AttributeError, pickle.PickleError):
 */
      __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_pack_create_actor_message(__pyx_cur_scope->__pyx_v_self->index, __pyx_v_to_index, __pyx_v_actor_ref, __pyx_v_actor_cls, ((PyObject*)__pyx_v_args), ((PyObject*)__pyx_v_kwargs), 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 791, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 791, __pyx_L3_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_7);
        #else
        __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 791, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 791, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_8 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 791, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_2)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) __PYX_ERR(0, 791, __pyx_L3_error)
        __pyx_t_9 = NULL;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L10_unpacking_done;
        __pyx_L9_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 791, __pyx_L3_error)
        __pyx_L10_unpacking_done:;
      }
      if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 791, __pyx_L3_error)
      if (!(likely(PyByteArray_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_7)->tp_name), 0))) __PYX_ERR(0, 791, __pyx_L3_error)
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_cur_scope->__pyx_v_message_id = ((PyObject*)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_GIVEREF(__pyx_t_7);
      __pyx_cur_scope->__pyx_v_message = ((PyObject*)__pyx_t_7);
      __pyx_t_7 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":790
 *         callback = kwargs.pop('callback', None)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             message_id, message = pack_create_actor_message(
 *                 self.index, to_index, actor_ref, actor_cls, args, kwargs)
 */
    }
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 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;

    /* "mars/actors/pool/gevent_pool.pyx":793
 *             message_id, message = pack_create_actor_message(
 *                 self.index, to_index, actor_ref, actor_cls, args, kwargs)
 *         except (AttributeError, pickle.PickleError):             # <<<<<<<<<<<<<<
 *             raise pickle.PicklingError('Unable to pickle {0}(*{1}, **{2})'.format(actor_cls, args, kwargs))
 * 
 */
    __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_7, &__pyx_t_2);
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_pickle); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 793, __pyx_L5_except_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 793, __pyx_L5_except_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_11 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_builtin_AttributeError) || __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_10);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_ErrRestore(__pyx_t_1, __pyx_t_7, __pyx_t_2);
    __pyx_t_1 = 0; __pyx_t_7 = 0; __pyx_t_2 = 0;
    if (__pyx_t_11) {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._create_process_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_7, &__pyx_t_1) < 0) __PYX_ERR(0, 793, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_1);

      /* "mars/actors/pool/gevent_pool.pyx":794
 *                 self.index, to_index, actor_ref, actor_cls, args, kwargs)
 *         except (AttributeError, pickle.PickleError):
 *             raise pickle.PicklingError('Unable to pickle {0}(*{1}, **{2})'.format(actor_cls, args, kwargs))             # <<<<<<<<<<<<<<
 * 
 *         if wait:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_pickle); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 794, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_PicklingError); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 794, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Unable_to_pickle_0_1_2, __pyx_n_s_format); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 794, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14 = NULL;
      __pyx_t_11 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
        __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
        if (likely(__pyx_t_14)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_13, function);
          __pyx_t_11 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[4] = {__pyx_t_14, __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs};
        __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 794, __pyx_L5_except_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_8);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[4] = {__pyx_t_14, __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs};
        __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 794, __pyx_L5_except_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_8);
      } else
      #endif
      {
        __pyx_t_15 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 794, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_15);
        if (__pyx_t_14) {
          __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
        }
        __Pyx_INCREF(__pyx_v_actor_cls);
        __Pyx_GIVEREF(__pyx_v_actor_cls);
        PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_11, __pyx_v_actor_cls);
        __Pyx_INCREF(__pyx_v_args);
        __Pyx_GIVEREF(__pyx_v_args);
        PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_11, __pyx_v_args);
        __Pyx_INCREF(__pyx_v_kwargs);
        __Pyx_GIVEREF(__pyx_v_kwargs);
        PyTuple_SET_ITEM(__pyx_t_15, 2+__pyx_t_11, __pyx_v_kwargs);
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_15, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 794, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(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);
        }
      }
      __pyx_t_10 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_13, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_8);
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 794, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_Raise(__pyx_t_10, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __PYX_ERR(0, 794, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":790
 *         callback = kwargs.pop('callback', None)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             message_id, message = pack_create_actor_message(
 *                 self.index, to_index, actor_ref, actor_cls, args, kwargs)
 */
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L8_try_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":796
 *             raise pickle.PicklingError('Unable to pickle {0}(*{1}, **{2})'.format(actor_cls, args, kwargs))
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             return self.submit(message_id)
 */
  __pyx_t_3 = (__pyx_v_wait != 0);
  if (__pyx_t_3) {

    /* "mars/actors/pool/gevent_pool.pyx":797
 * 
 *         if wait:
 *             self.pipe.put(message)             # <<<<<<<<<<<<<<
 *             return self.submit(message_id)
 * 
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->pipe, __pyx_n_s_put); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 797, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_2, __pyx_cur_scope->__pyx_v_message) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_cur_scope->__pyx_v_message);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 797, __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;

    /* "mars/actors/pool/gevent_pool.pyx":798
 *         if wait:
 *             self.pipe.put(message)
 *             return self.submit(message_id)             # <<<<<<<<<<<<<<
 * 
 *         # return future
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __pyx_cur_scope->__pyx_v_message_id;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_7 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.submit(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_1), 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 798, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":796
 *             raise pickle.PicklingError('Unable to pickle {0}(*{1}, **{2})'.format(actor_cls, args, kwargs))
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             return self.submit(message_id)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":801
 * 
 *         # return future
 *         future = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 * 
 *         def check():
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_event); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_AsyncResult); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_7 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_cur_scope->__pyx_v_future = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":803
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             self.future(message_id, future, callback=callback)
 */
  __pyx_t_7 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_12Communicator_21_create_process_actor_1check, 0, __pyx_n_s_create_process_actor_locals_che, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 803, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_v_check = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":807
 *             self.future(message_id, future, callback=callback)
 * 
 *         gevent.spawn(check)             # <<<<<<<<<<<<<<
 *         return future
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 807, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_spawn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 807, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_7 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_v_check) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_check);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 807, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":808
 * 
 *         gevent.spawn(check)
 *         return future             # <<<<<<<<<<<<<<
 * 
 *     cpdef object _create_remote_actor(self, ActorRef actor_ref, object actor_cls, args, kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_future);
  __pyx_r = __pyx_cur_scope->__pyx_v_future;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":779
 *         return future
 * 
 *     def _create_process_actor(self, int to_index, ActorRef actor_ref, object actor_cls,             # <<<<<<<<<<<<<<
 *                               args, kwargs):
 *         cdef bint wait
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._create_process_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_check);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":810
 *         return future
 * 
 *     cpdef object _create_remote_actor(self, ActorRef actor_ref, object actor_cls, args, kwargs):             # <<<<<<<<<<<<<<
 *         return self.remote_handler.create_actor(actor_ref.address, actor_ref.uid,
 *                                                 actor_cls, *args, **kwargs)
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_21_create_remote_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__create_remote_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, int __pyx_skip_dispatch) {
  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;
  __Pyx_RefNannySetupContext("_create_remote_actor", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_remote_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 810, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_21_create_remote_actor)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && 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);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[5] = {__pyx_t_4, ((PyObject *)__pyx_v_actor_ref), __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 810, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[5] = {__pyx_t_4, ((PyObject *)__pyx_v_actor_ref), __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 810, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 810, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_INCREF(__pyx_v_actor_cls);
          __Pyx_GIVEREF(__pyx_v_actor_cls);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_actor_cls);
          __Pyx_INCREF(__pyx_v_args);
          __Pyx_GIVEREF(__pyx_v_args);
          PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_args);
          __Pyx_INCREF(__pyx_v_kwargs);
          __Pyx_GIVEREF(__pyx_v_kwargs);
          PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_kwargs);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 810, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":811
 * 
 *     cpdef object _create_remote_actor(self, ActorRef actor_ref, object actor_cls, args, kwargs):
 *         return self.remote_handler.create_actor(actor_ref.address, actor_ref.uid,             # <<<<<<<<<<<<<<
 *                                                 actor_cls, *args, **kwargs)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->remote_handler, __pyx_n_s_create_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "mars/actors/pool/gevent_pool.pyx":812
 *     cpdef object _create_remote_actor(self, ActorRef actor_ref, object actor_cls, args, kwargs):
 *         return self.remote_handler.create_actor(actor_ref.address, actor_ref.uid,
 *                                                 actor_cls, *args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     def create_actor(self, str address, object uid,
 */
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_actor_ref->address);
  __Pyx_GIVEREF(__pyx_v_actor_ref->address);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_actor_ref->address);
  __Pyx_INCREF(__pyx_v_actor_ref->uid);
  __Pyx_GIVEREF(__pyx_v_actor_ref->uid);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_actor_ref->uid);
  __Pyx_INCREF(__pyx_v_actor_cls);
  __Pyx_GIVEREF(__pyx_v_actor_cls);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_actor_cls);

  /* "mars/actors/pool/gevent_pool.pyx":811
 * 
 *     cpdef object _create_remote_actor(self, ActorRef actor_ref, object actor_cls, args, kwargs):
 *         return self.remote_handler.create_actor(actor_ref.address, actor_ref.uid,             # <<<<<<<<<<<<<<
 *                                                 actor_cls, *args, **kwargs)
 * 
 */
  __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PyNumber_Add(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":812
 *     cpdef object _create_remote_actor(self, ActorRef actor_ref, object actor_cls, args, kwargs):
 *         return self.remote_handler.create_actor(actor_ref.address, actor_ref.uid,
 *                                                 actor_cls, *args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     def create_actor(self, str address, object uid,
 */
  if (unlikely(__pyx_v_kwargs == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
    __PYX_ERR(0, 812, __pyx_L1_error)
  }
  if (likely(PyDict_CheckExact(__pyx_v_kwargs))) {
    __pyx_t_3 = PyDict_Copy(__pyx_v_kwargs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 812, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    __pyx_t_3 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_kwargs, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 811, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }

  /* "mars/actors/pool/gevent_pool.pyx":811
 * 
 *     cpdef object _create_remote_actor(self, ActorRef actor_ref, object actor_cls, args, kwargs):
 *         return self.remote_handler.create_actor(actor_ref.address, actor_ref.uid,             # <<<<<<<<<<<<<<
 *                                                 actor_cls, *args, **kwargs)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":810
 *         return future
 * 
 *     cpdef object _create_remote_actor(self, ActorRef actor_ref, object actor_cls, args, kwargs):             # <<<<<<<<<<<<<<
 *         return self.remote_handler.create_actor(actor_ref.address, actor_ref.uid,
 *                                                 actor_cls, *args, **kwargs)
 */

  /* 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_6);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._create_remote_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_21_create_remote_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_21_create_remote_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_actor_cls = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_create_remote_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_actor_cls,&__pyx_n_s_args,&__pyx_n_s_kwargs,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);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_cls)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_remote_actor", 1, 4, 4, 1); __PYX_ERR(0, 810, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_remote_actor", 1, 4, 4, 2); __PYX_ERR(0, 810, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_remote_actor", 1, 4, 4, 3); __PYX_ERR(0, 810, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_create_remote_actor") < 0)) __PYX_ERR(0, 810, __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_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    __pyx_v_actor_cls = values[1];
    __pyx_v_args = values[2];
    __pyx_v_kwargs = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_create_remote_actor", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 810, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._create_remote_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 810, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_20_create_remote_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_20_create_remote_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_create_remote_actor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__create_remote_actor(__pyx_v_self, __pyx_v_actor_ref, __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 810, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._create_remote_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":814
 *                                                 actor_cls, *args, **kwargs)
 * 
 *     def create_actor(self, str address, object uid,             # <<<<<<<<<<<<<<
 *                      object actor_cls, *args, **kwargs):
 *         cdef object actor_id
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_23create_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_23create_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_address = 0;
  PyObject *__pyx_v_uid = 0;
  PyObject *__pyx_v_actor_cls = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_actor (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_address,&__pyx_n_s_uid,&__pyx_n_s_actor_cls,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_address)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_uid)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_actor", 0, 3, 3, 1); __PYX_ERR(0, 814, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_cls)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_actor", 0, 3, 3, 2); __PYX_ERR(0, 814, __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, "create_actor") < 0)) __PYX_ERR(0, 814, __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_address = ((PyObject*)values[0]);
    __pyx_v_uid = values[1];
    __pyx_v_actor_cls = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_actor", 0, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 814, __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("mars.actors.pool.gevent_pool.Communicator.create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_address), (&PyString_Type), 1, "address", 1))) __PYX_ERR(0, 814, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_22create_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_address, __pyx_v_uid, __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_22create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_address, PyObject *__pyx_v_uid, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_actor_id = 0;
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  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;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("create_actor", 0);

  /* "mars/actors/pool/gevent_pool.pyx":819
 *         cdef ActorRef actor_ref
 * 
 *         actor_id = uid or new_actor_id()             # <<<<<<<<<<<<<<
 *         actor_ref = ActorRef(address, actor_id)
 *         return self._dispatch(self._create_local_actor, self._create_process_actor,
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_uid); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 819, __pyx_L1_error)
  if (!__pyx_t_2) {
  } else {
    __Pyx_INCREF(__pyx_v_uid);
    __pyx_t_1 = __pyx_v_uid;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_3 = __pyx_f_4mars_6actors_4pool_5utils_new_actor_id(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 819, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_1 = __pyx_t_3;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_L3_bool_binop_done:;
  __pyx_v_actor_id = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":820
 * 
 *         actor_id = uid or new_actor_id()
 *         actor_ref = ActorRef(address, actor_id)             # <<<<<<<<<<<<<<
 *         return self._dispatch(self._create_local_actor, self._create_process_actor,
 *                               self._create_remote_actor, actor_ref,
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 820, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_address);
  __Pyx_GIVEREF(__pyx_v_address);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_address);
  __Pyx_INCREF(__pyx_v_actor_id);
  __Pyx_GIVEREF(__pyx_v_actor_id);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_actor_id);
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4mars_6actors_4core_ActorRef), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 820, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":821
 *         actor_id = uid or new_actor_id()
 *         actor_ref = ActorRef(address, actor_id)
 *         return self._dispatch(self._create_local_actor, self._create_process_actor,             # <<<<<<<<<<<<<<
 *                               self._create_remote_actor, actor_ref,
 *                               (actor_ref, actor_cls, args, kwargs), dict())
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_local_actor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 821, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_process_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 821, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "mars/actors/pool/gevent_pool.pyx":822
 *         actor_ref = ActorRef(address, actor_id)
 *         return self._dispatch(self._create_local_actor, self._create_process_actor,
 *                               self._create_remote_actor, actor_ref,             # <<<<<<<<<<<<<<
 *                               (actor_ref, actor_cls, args, kwargs), dict())
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_remote_actor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 822, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "mars/actors/pool/gevent_pool.pyx":823
 *         return self._dispatch(self._create_local_actor, self._create_process_actor,
 *                               self._create_remote_actor, actor_ref,
 *                               (actor_ref, actor_cls, args, kwargs), dict())             # <<<<<<<<<<<<<<
 * 
 *     cpdef _destroy_local_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 */
  __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 823, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
  PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_actor_ref));
  __Pyx_INCREF(__pyx_v_actor_cls);
  __Pyx_GIVEREF(__pyx_v_actor_cls);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_actor_cls);
  __Pyx_INCREF(__pyx_v_args);
  __Pyx_GIVEREF(__pyx_v_args);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_args);
  __Pyx_INCREF(__pyx_v_kwargs);
  __Pyx_GIVEREF(__pyx_v_kwargs);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_kwargs);
  __pyx_t_6 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 823, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "mars/actors/pool/gevent_pool.pyx":821
 *         actor_id = uid or new_actor_id()
 *         actor_ref = ActorRef(address, actor_id)
 *         return self._dispatch(self._create_local_actor, self._create_process_actor,             # <<<<<<<<<<<<<<
 *                               self._create_remote_actor, actor_ref,
 *                               (actor_ref, actor_cls, args, kwargs), dict())
 */
  __pyx_t_7 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self->__pyx_base.__pyx_vtab)->_dispatch(__pyx_v_self, __pyx_t_3, __pyx_t_1, __pyx_t_4, __pyx_v_actor_ref, __pyx_t_5, __pyx_t_6, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 821, __pyx_L1_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_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":814
 *                                                 actor_cls, *args, **kwargs)
 * 
 *     def create_actor(self, str address, object uid,             # <<<<<<<<<<<<<<
 *                      object actor_cls, *args, **kwargs):
 *         cdef object actor_id
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_actor_id);
  __Pyx_XDECREF((PyObject *)__pyx_v_actor_ref);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":825
 *                               (actor_ref, actor_cls, args, kwargs), dict())
 * 
 *     cpdef _destroy_local_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef object future
 *         cdef object res
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_25_destroy_local_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__destroy_local_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__destroy_local_actor *__pyx_optional_args) {
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  PyObject *__pyx_v_future = 0;
  PyObject *__pyx_v_res = 0;
  PyObject *__pyx_v_t = 0;
  PyObject *__pyx_v_ex = 0;
  PyObject *__pyx_v_tb = 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_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __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 = NULL;
  PyObject *(*__pyx_t_14)(PyObject *);
  __Pyx_RefNannySetupContext("_destroy_local_actor", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_wait = __pyx_optional_args->wait;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_callback = __pyx_optional_args->callback;
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_destroy_local_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 825, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_25_destroy_local_actor)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 825, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        __pyx_t_6 = 0;
        if (CYTHON_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 825, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 825, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 825, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 825, __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_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":832
 *         cdef object tb
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             return self.pool.destroy_actor(actor_ref.uid)
 * 
 */
  __pyx_t_8 = (__pyx_v_wait != 0);
  if (__pyx_t_8) {

    /* "mars/actors/pool/gevent_pool.pyx":833
 * 
 *         if wait:
 *             return self.pool.destroy_actor(actor_ref.uid)             # <<<<<<<<<<<<<<
 * 
 *         future = gevent.event.AsyncResult()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pool, __pyx_n_s_destroy_actor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 833, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v_actor_ref->uid) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_actor_ref->uid);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 833, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":832
 *         cdef object tb
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             return self.pool.destroy_actor(actor_ref.uid)
 * 
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":835
 *             return self.pool.destroy_actor(actor_ref.uid)
 * 
 *         future = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 *         try:
 *             res = self.pool.destroy_actor(actor_ref.uid)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 835, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_event); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 835, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_AsyncResult); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 835, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 835, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_future = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":836
 * 
 *         future = gevent.event.AsyncResult()
 *         try:             # <<<<<<<<<<<<<<
 *             res = self.pool.destroy_actor(actor_ref.uid)
 *             if callback:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __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:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":837
 *         future = gevent.event.AsyncResult()
 *         try:
 *             res = self.pool.destroy_actor(actor_ref.uid)             # <<<<<<<<<<<<<<
 *             if callback:
 *                 callback(res)
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pool, __pyx_n_s_destroy_actor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 837, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && 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);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v_actor_ref->uid) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_actor_ref->uid);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 837, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_res = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":838
 *         try:
 *             res = self.pool.destroy_actor(actor_ref.uid)
 *             if callback:             # <<<<<<<<<<<<<<
 *                 callback(res)
 *             future.set_result(res)
 */
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 838, __pyx_L4_error)
      if (__pyx_t_8) {

        /* "mars/actors/pool/gevent_pool.pyx":839
 *             res = self.pool.destroy_actor(actor_ref.uid)
 *             if callback:
 *                 callback(res)             # <<<<<<<<<<<<<<
 *             future.set_result(res)
 *         except:
 */
        __Pyx_INCREF(__pyx_v_callback);
        __pyx_t_2 = __pyx_v_callback; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v_res) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_res);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 839, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "mars/actors/pool/gevent_pool.pyx":838
 *         try:
 *             res = self.pool.destroy_actor(actor_ref.uid)
 *             if callback:             # <<<<<<<<<<<<<<
 *                 callback(res)
 *             future.set_result(res)
 */
      }

      /* "mars/actors/pool/gevent_pool.pyx":840
 *             if callback:
 *                 callback(res)
 *             future.set_result(res)             # <<<<<<<<<<<<<<
 *         except:
 *             t, ex, tb = sys.exc_info()
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_future, __pyx_n_s_set_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 840, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && 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);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v_res) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_res);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 840, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":836
 * 
 *         future = gevent.event.AsyncResult()
 *         try:             # <<<<<<<<<<<<<<
 *             res = self.pool.destroy_actor(actor_ref.uid)
 *             if callback:
 */
    }
    __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_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":841
 *                 callback(res)
 *             future.set_result(res)
 *         except:             # <<<<<<<<<<<<<<
 *             t, ex, tb = sys.exc_info()
 *             future.set_exception(ex, exc_info=(t, ex, tb))
 */
    /*except:*/ {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._destroy_local_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_4) < 0) __PYX_ERR(0, 841, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_4);

      /* "mars/actors/pool/gevent_pool.pyx":842
 *             future.set_result(res)
 *         except:
 *             t, ex, tb = sys.exc_info()             # <<<<<<<<<<<<<<
 *             future.set_exception(ex, exc_info=(t, ex, tb))
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_sys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 842, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 842, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(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);
        }
      }
      __pyx_t_7 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 842, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) {
        PyObject* sequence = __pyx_t_7;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 842, __pyx_L6_except_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_12);
        #else
        __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 842, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 842, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_12 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 842, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        #endif
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_13 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 842, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_14 = Py_TYPE(__pyx_t_13)->tp_iternext;
        index = 0; __pyx_t_5 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_5)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 1; __pyx_t_3 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_3)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        index = 2; __pyx_t_12 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_12)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_12);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_13), 3) < 0) __PYX_ERR(0, 842, __pyx_L6_except_error)
        __pyx_t_14 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L14_unpacking_done;
        __pyx_L13_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_14 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 842, __pyx_L6_except_error)
        __pyx_L14_unpacking_done:;
      }
      __pyx_v_t = __pyx_t_5;
      __pyx_t_5 = 0;
      __pyx_v_ex = __pyx_t_3;
      __pyx_t_3 = 0;
      __pyx_v_tb = __pyx_t_12;
      __pyx_t_12 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":843
 *         except:
 *             t, ex, tb = sys.exc_info()
 *             future.set_exception(ex, exc_info=(t, ex, tb))             # <<<<<<<<<<<<<<
 * 
 *         return future
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_future, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 843, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 843, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_v_ex);
      __Pyx_GIVEREF(__pyx_v_ex);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_ex);
      __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 843, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 843, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_t);
      __Pyx_GIVEREF(__pyx_v_t);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_t);
      __Pyx_INCREF(__pyx_v_ex);
      __Pyx_GIVEREF(__pyx_v_ex);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_ex);
      __Pyx_INCREF(__pyx_v_tb);
      __Pyx_GIVEREF(__pyx_v_tb);
      PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_tb);
      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_exc_info, __pyx_t_5) < 0) __PYX_ERR(0, 843, __pyx_L6_except_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 843, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__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;
      goto __pyx_L5_exception_handled;
    }
    __pyx_L6_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":836
 * 
 *         future = gevent.event.AsyncResult()
 *         try:             # <<<<<<<<<<<<<<
 *             res = self.pool.destroy_actor(actor_ref.uid)
 *             if callback:
 */
    __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_L5_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_L9_try_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":845
 *             future.set_exception(ex, exc_info=(t, ex, tb))
 * 
 *         return future             # <<<<<<<<<<<<<<
 * 
 *     def _destroy_process_actor(self, int to_index, ActorRef actor_ref,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_future);
  __pyx_r = __pyx_v_future;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":825
 *                               (actor_ref, actor_cls, args, kwargs), dict())
 * 
 *     cpdef _destroy_local_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef object future
 *         cdef object res
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._destroy_local_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_future);
  __Pyx_XDECREF(__pyx_v_res);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_ex);
  __Pyx_XDECREF(__pyx_v_tb);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_25_destroy_local_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_25_destroy_local_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_destroy_local_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_destroy_local_actor") < 0)) __PYX_ERR(0, 825, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    if (values[1]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 825, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_destroy_local_actor", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 825, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._destroy_local_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 825, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_24_destroy_local_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_24_destroy_local_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__destroy_local_actor __pyx_t_2;
  __Pyx_RefNannySetupContext("_destroy_local_actor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Communicator->_destroy_local_actor(__pyx_v_self, __pyx_v_actor_ref, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 825, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._destroy_local_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":847
 *         return future
 * 
 *     def _destroy_process_actor(self, int to_index, ActorRef actor_ref,             # <<<<<<<<<<<<<<
 *                                bint wait=True, object callback=None):
 *         cdef bytes message_id
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_27_destroy_process_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_27_destroy_process_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_to_index;
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_destroy_process_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_to_index,&__pyx_n_s_actor_ref,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[4] = {0,0,0,0};

    /* "mars/actors/pool/gevent_pool.pyx":848
 * 
 *     def _destroy_process_actor(self, int to_index, ActorRef actor_ref,
 *                                bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef bytes message_id
 *         cdef bytearray message
 */
    values[3] = ((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);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_to_index)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_destroy_process_actor", 0, 2, 4, 1); __PYX_ERR(0, 847, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_destroy_process_actor") < 0)) __PYX_ERR(0, 847, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_to_index = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_to_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 847, __pyx_L3_error)
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[1]);
    if (values[2]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 848, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_destroy_process_actor", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 847, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._destroy_process_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 847, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_26_destroy_process_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_to_index, __pyx_v_actor_ref, __pyx_v_wait, __pyx_v_callback);

  /* "mars/actors/pool/gevent_pool.pyx":847
 *         return future
 * 
 *     def _destroy_process_actor(self, int to_index, ActorRef actor_ref,             # <<<<<<<<<<<<<<
 *                                bint wait=True, object callback=None):
 *         cdef bytes message_id
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":860
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             self.future(message_id, future, callback=callback)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_22_destroy_process_actor_1check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_12Communicator_22_destroy_process_actor_1check = {"check", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_22_destroy_process_actor_1check, METH_NOARGS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_22_destroy_process_actor_1check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_22_destroy_process_actor_check(__pyx_self);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_22_destroy_process_actor_check(PyObject *__pyx_self) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor *__pyx_outer_scope;
  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;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future __pyx_t_5;
  __Pyx_RefNannySetupContext("check", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":861
 * 
 *         def check():
 *             self.pipe.put(message)             # <<<<<<<<<<<<<<
 *             self.future(message_id, future, callback=callback)
 * 
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 861, __pyx_L1_error) }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->pipe, __pyx_n_s_put); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 861, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(!__pyx_cur_scope->__pyx_v_message)) { __Pyx_RaiseClosureNameError("message"); __PYX_ERR(0, 861, __pyx_L1_error) }
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_cur_scope->__pyx_v_message) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_cur_scope->__pyx_v_message);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 861, __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;

  /* "mars/actors/pool/gevent_pool.pyx":862
 *         def check():
 *             self.pipe.put(message)
 *             self.future(message_id, future, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *         gevent.spawn(check)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 862, __pyx_L1_error) }
  if (unlikely(!__pyx_cur_scope->__pyx_v_message_id)) { __Pyx_RaiseClosureNameError("message_id"); __PYX_ERR(0, 862, __pyx_L1_error) }
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_message_id;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(!__pyx_cur_scope->__pyx_v_future)) { __Pyx_RaiseClosureNameError("future"); __PYX_ERR(0, 862, __pyx_L1_error) }
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_future;
  __Pyx_INCREF(__pyx_t_2);
  if (unlikely(!__pyx_cur_scope->__pyx_v_callback)) { __Pyx_RaiseClosureNameError("callback"); __PYX_ERR(0, 862, __pyx_L1_error) }
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_callback;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_5.__pyx_n = 1;
  __pyx_t_5.callback = __pyx_t_3;
  __pyx_t_4 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.future(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_1), __pyx_t_2, 0, &__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 862, __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_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":860
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             self.future(message_id, future, 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_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._destroy_process_actor.check", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":847
 *         return future
 * 
 *     def _destroy_process_actor(self, int to_index, ActorRef actor_ref,             # <<<<<<<<<<<<<<
 *                                bint wait=True, object callback=None):
 *         cdef bytes message_id
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_26_destroy_process_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, int __pyx_v_to_index, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor *__pyx_cur_scope;
  PyObject *__pyx_v_check = 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)(PyObject *);
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("_destroy_process_actor", 0);
  __pyx_cur_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor *)__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor(__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 847, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __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);

  /* "mars/actors/pool/gevent_pool.pyx":853
 *         cdef object future
 * 
 *         message_id, message = pack_destroy_actor_message(self.index, to_index, actor_ref)             # <<<<<<<<<<<<<<
 *         if wait:
 *             self.pipe.put(message)
 */
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_pack_destroy_actor_message(__pyx_cur_scope->__pyx_v_self->index, __pyx_v_to_index, __pyx_v_actor_ref, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 853, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 853, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    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_ERR(0, 853, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 853, __pyx_L1_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_ERR(0, 853, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(0, 853, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 853, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 853, __pyx_L1_error)
  if (!(likely(PyByteArray_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 853, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_cur_scope->__pyx_v_message_id = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_message = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":854
 * 
 *         message_id, message = pack_destroy_actor_message(self.index, to_index, actor_ref)
 *         if wait:             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             return self.submit(message_id)
 */
  __pyx_t_6 = (__pyx_v_wait != 0);
  if (__pyx_t_6) {

    /* "mars/actors/pool/gevent_pool.pyx":855
 *         message_id, message = pack_destroy_actor_message(self.index, to_index, actor_ref)
 *         if wait:
 *             self.pipe.put(message)             # <<<<<<<<<<<<<<
 *             return self.submit(message_id)
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->pipe, __pyx_n_s_put); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_cur_scope->__pyx_v_message) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_cur_scope->__pyx_v_message);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 855, __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;

    /* "mars/actors/pool/gevent_pool.pyx":856
 *         if wait:
 *             self.pipe.put(message)
 *             return self.submit(message_id)             # <<<<<<<<<<<<<<
 * 
 *         future = gevent.event.AsyncResult()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __pyx_cur_scope->__pyx_v_message_id;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_3 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.submit(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_1), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":854
 * 
 *         message_id, message = pack_destroy_actor_message(self.index, to_index, actor_ref)
 *         if wait:             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             return self.submit(message_id)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":858
 *             return self.submit(message_id)
 * 
 *         future = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 * 
 *         def check():
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 858, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_event); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 858, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_AsyncResult); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 858, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 858, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_future = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":860
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             self.future(message_id, future, callback=callback)
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_12Communicator_22_destroy_process_actor_1check, 0, __pyx_n_s_destroy_process_actor_locals_ch, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__26)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 860, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_check = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":864
 *             self.future(message_id, future, callback=callback)
 * 
 *         gevent.spawn(check)             # <<<<<<<<<<<<<<
 *         return future
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 864, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_spawn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 864, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_v_check) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_check);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 864, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":865
 * 
 *         gevent.spawn(check)
 *         return future             # <<<<<<<<<<<<<<
 * 
 *     cpdef destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_future);
  __pyx_r = __pyx_cur_scope->__pyx_v_future;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":847
 *         return future
 * 
 *     def _destroy_process_actor(self, int to_index, ActorRef actor_ref,             # <<<<<<<<<<<<<<
 *                                bint wait=True, object callback=None):
 *         cdef bytes message_id
 */

  /* 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("mars.actors.pool.gevent_pool.Communicator._destroy_process_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_check);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":867
 *         return future
 * 
 *     cpdef destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._dispatch(self._destroy_local_actor, self._destroy_process_actor,
 *                               self.remote_handler.destroy_actor, actor_ref,
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_29destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator_destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_destroy_actor *__pyx_optional_args) {
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  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;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("destroy_actor", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_wait = __pyx_optional_args->wait;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_callback = __pyx_optional_args->callback;
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_destroy_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 867, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_29destroy_actor)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 867, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        __pyx_t_6 = 0;
        if (CYTHON_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 867, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 867, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 867, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 867, __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_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":868
 * 
 *     cpdef destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 *         return self._dispatch(self._destroy_local_actor, self._destroy_process_actor,             # <<<<<<<<<<<<<<
 *                               self.remote_handler.destroy_actor, actor_ref,
 *                               (actor_ref,), dict(wait=wait, callback=callback))
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_destroy_local_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 868, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_destroy_process_actor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 868, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "mars/actors/pool/gevent_pool.pyx":869
 *     cpdef destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 *         return self._dispatch(self._destroy_local_actor, self._destroy_process_actor,
 *                               self.remote_handler.destroy_actor, actor_ref,             # <<<<<<<<<<<<<<
 *                               (actor_ref,), dict(wait=wait, callback=callback))
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->remote_handler, __pyx_n_s_destroy_actor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 869, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "mars/actors/pool/gevent_pool.pyx":870
 *         return self._dispatch(self._destroy_local_actor, self._destroy_process_actor,
 *                               self.remote_handler.destroy_actor, actor_ref,
 *                               (actor_ref,), dict(wait=wait, callback=callback))             # <<<<<<<<<<<<<<
 * 
 *     cpdef _has_local_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 */
  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
  PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_actor_ref));
  __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_wait, __pyx_t_5) < 0) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 870, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":868
 * 
 *     cpdef destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 *         return self._dispatch(self._destroy_local_actor, self._destroy_process_actor,             # <<<<<<<<<<<<<<
 *                               self.remote_handler.destroy_actor, actor_ref,
 *                               (actor_ref,), dict(wait=wait, callback=callback))
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self->__pyx_base.__pyx_vtab)->_dispatch(__pyx_v_self, __pyx_t_1, __pyx_t_2, __pyx_t_4, __pyx_v_actor_ref, __pyx_t_7, __pyx_t_3, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 868, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":867
 *         return future
 * 
 *     cpdef destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._dispatch(self._destroy_local_actor, self._destroy_process_actor,
 *                               self.remote_handler.destroy_actor, actor_ref,
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_29destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_29destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("destroy_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "destroy_actor") < 0)) __PYX_ERR(0, 867, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    if (values[1]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 867, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("destroy_actor", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 867, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 867, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_28destroy_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_28destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_destroy_actor __pyx_t_2;
  __Pyx_RefNannySetupContext("destroy_actor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Communicator->destroy_actor(__pyx_v_self, __pyx_v_actor_ref, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 867, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":872
 *                               (actor_ref,), dict(wait=wait, callback=callback))
 * 
 *     cpdef _has_local_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         if wait:
 *             return self.pool.has_actor(actor_ref.uid)
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_31_has_local_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__has_local_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__has_local_actor *__pyx_optional_args) {
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  PyObject *__pyx_v_future = NULL;
  PyObject *__pyx_v_ret = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_ex = NULL;
  PyObject *__pyx_v_tb = 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;
  PyObject *__pyx_t_7 = NULL;
  int __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 = NULL;
  PyObject *(*__pyx_t_14)(PyObject *);
  __Pyx_RefNannySetupContext("_has_local_actor", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_wait = __pyx_optional_args->wait;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_callback = __pyx_optional_args->callback;
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_has_local_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 872, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_31_has_local_actor)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 872, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        __pyx_t_6 = 0;
        if (CYTHON_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 872, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 872, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 872, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 872, __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_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":873
 * 
 *     cpdef _has_local_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 *         if wait:             # <<<<<<<<<<<<<<
 *             return self.pool.has_actor(actor_ref.uid)
 * 
 */
  __pyx_t_8 = (__pyx_v_wait != 0);
  if (__pyx_t_8) {

    /* "mars/actors/pool/gevent_pool.pyx":874
 *     cpdef _has_local_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 *         if wait:
 *             return self.pool.has_actor(actor_ref.uid)             # <<<<<<<<<<<<<<
 * 
 *         future = gevent.event.AsyncResult()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pool, __pyx_n_s_has_actor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 874, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v_actor_ref->uid) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_actor_ref->uid);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 874, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":873
 * 
 *     cpdef _has_local_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 *         if wait:             # <<<<<<<<<<<<<<
 *             return self.pool.has_actor(actor_ref.uid)
 * 
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":876
 *             return self.pool.has_actor(actor_ref.uid)
 * 
 *         future = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 *         try:
 *             ret = self.pool.has_actor(actor_ref.uid)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 876, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_event); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 876, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_AsyncResult); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 876, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 876, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_future = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":877
 * 
 *         future = gevent.event.AsyncResult()
 *         try:             # <<<<<<<<<<<<<<
 *             ret = self.pool.has_actor(actor_ref.uid)
 *             if callback:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __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:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":878
 *         future = gevent.event.AsyncResult()
 *         try:
 *             ret = self.pool.has_actor(actor_ref.uid)             # <<<<<<<<<<<<<<
 *             if callback:
 *                 callback(ret)
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pool, __pyx_n_s_has_actor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 878, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && 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);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v_actor_ref->uid) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_actor_ref->uid);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 878, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_ret = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":879
 *         try:
 *             ret = self.pool.has_actor(actor_ref.uid)
 *             if callback:             # <<<<<<<<<<<<<<
 *                 callback(ret)
 *             future.set_result(ret)
 */
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 879, __pyx_L4_error)
      if (__pyx_t_8) {

        /* "mars/actors/pool/gevent_pool.pyx":880
 *             ret = self.pool.has_actor(actor_ref.uid)
 *             if callback:
 *                 callback(ret)             # <<<<<<<<<<<<<<
 *             future.set_result(ret)
 *         except:
 */
        __Pyx_INCREF(__pyx_v_callback);
        __pyx_t_2 = __pyx_v_callback; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v_ret) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_ret);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 880, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "mars/actors/pool/gevent_pool.pyx":879
 *         try:
 *             ret = self.pool.has_actor(actor_ref.uid)
 *             if callback:             # <<<<<<<<<<<<<<
 *                 callback(ret)
 *             future.set_result(ret)
 */
      }

      /* "mars/actors/pool/gevent_pool.pyx":881
 *             if callback:
 *                 callback(ret)
 *             future.set_result(ret)             # <<<<<<<<<<<<<<
 *         except:
 *             t, ex, tb = sys.exc_info()
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_future, __pyx_n_s_set_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 881, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && 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);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v_ret) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_ret);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 881, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":877
 * 
 *         future = gevent.event.AsyncResult()
 *         try:             # <<<<<<<<<<<<<<
 *             ret = self.pool.has_actor(actor_ref.uid)
 *             if callback:
 */
    }
    __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_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":882
 *                 callback(ret)
 *             future.set_result(ret)
 *         except:             # <<<<<<<<<<<<<<
 *             t, ex, tb = sys.exc_info()
 *             future.set_exception(ex, exc_info=(t, ex, tb))
 */
    /*except:*/ {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._has_local_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_4) < 0) __PYX_ERR(0, 882, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_4);

      /* "mars/actors/pool/gevent_pool.pyx":883
 *             future.set_result(ret)
 *         except:
 *             t, ex, tb = sys.exc_info()             # <<<<<<<<<<<<<<
 *             future.set_exception(ex, exc_info=(t, ex, tb))
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_sys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 883, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 883, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(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);
        }
      }
      __pyx_t_7 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 883, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) {
        PyObject* sequence = __pyx_t_7;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 883, __pyx_L6_except_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_12);
        #else
        __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 883, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 883, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_12 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 883, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        #endif
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_13 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 883, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_14 = Py_TYPE(__pyx_t_13)->tp_iternext;
        index = 0; __pyx_t_5 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_5)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 1; __pyx_t_3 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_3)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        index = 2; __pyx_t_12 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_12)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_12);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_13), 3) < 0) __PYX_ERR(0, 883, __pyx_L6_except_error)
        __pyx_t_14 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L14_unpacking_done;
        __pyx_L13_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_14 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 883, __pyx_L6_except_error)
        __pyx_L14_unpacking_done:;
      }
      __pyx_v_t = __pyx_t_5;
      __pyx_t_5 = 0;
      __pyx_v_ex = __pyx_t_3;
      __pyx_t_3 = 0;
      __pyx_v_tb = __pyx_t_12;
      __pyx_t_12 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":884
 *         except:
 *             t, ex, tb = sys.exc_info()
 *             future.set_exception(ex, exc_info=(t, ex, tb))             # <<<<<<<<<<<<<<
 * 
 *         return future
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_future, __pyx_n_s_set_exception); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 884, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 884, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_v_ex);
      __Pyx_GIVEREF(__pyx_v_ex);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_ex);
      __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 884, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 884, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_t);
      __Pyx_GIVEREF(__pyx_v_t);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_t);
      __Pyx_INCREF(__pyx_v_ex);
      __Pyx_GIVEREF(__pyx_v_ex);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_ex);
      __Pyx_INCREF(__pyx_v_tb);
      __Pyx_GIVEREF(__pyx_v_tb);
      PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_tb);
      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_exc_info, __pyx_t_5) < 0) __PYX_ERR(0, 884, __pyx_L6_except_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 884, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__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;
      goto __pyx_L5_exception_handled;
    }
    __pyx_L6_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":877
 * 
 *         future = gevent.event.AsyncResult()
 *         try:             # <<<<<<<<<<<<<<
 *             ret = self.pool.has_actor(actor_ref.uid)
 *             if callback:
 */
    __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_L5_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_L9_try_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":886
 *             future.set_exception(ex, exc_info=(t, ex, tb))
 * 
 *         return future             # <<<<<<<<<<<<<<
 * 
 *     def _has_process_actor(self, int to_index, ActorRef actor_ref,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_future);
  __pyx_r = __pyx_v_future;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":872
 *                               (actor_ref,), dict(wait=wait, callback=callback))
 * 
 *     cpdef _has_local_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         if wait:
 *             return self.pool.has_actor(actor_ref.uid)
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._has_local_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_future);
  __Pyx_XDECREF(__pyx_v_ret);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_ex);
  __Pyx_XDECREF(__pyx_v_tb);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_31_has_local_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_31_has_local_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_has_local_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_has_local_actor") < 0)) __PYX_ERR(0, 872, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    if (values[1]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 872, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_has_local_actor", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 872, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._has_local_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 872, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_30_has_local_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_30_has_local_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__has_local_actor __pyx_t_2;
  __Pyx_RefNannySetupContext("_has_local_actor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Communicator->_has_local_actor(__pyx_v_self, __pyx_v_actor_ref, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 872, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._has_local_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":888
 *         return future
 * 
 *     def _has_process_actor(self, int to_index, ActorRef actor_ref,             # <<<<<<<<<<<<<<
 *                            bint wait=True, object callback=None):
 *         cdef bytes message_id
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_33_has_process_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_33_has_process_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_to_index;
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_has_process_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_to_index,&__pyx_n_s_actor_ref,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[4] = {0,0,0,0};

    /* "mars/actors/pool/gevent_pool.pyx":889
 * 
 *     def _has_process_actor(self, int to_index, ActorRef actor_ref,
 *                            bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef bytes message_id
 *         cdef bytearray message
 */
    values[3] = ((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);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_to_index)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_has_process_actor", 0, 2, 4, 1); __PYX_ERR(0, 888, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_has_process_actor") < 0)) __PYX_ERR(0, 888, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_to_index = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_to_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 888, __pyx_L3_error)
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[1]);
    if (values[2]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 889, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_has_process_actor", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 888, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._has_process_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 888, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_32_has_process_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_to_index, __pyx_v_actor_ref, __pyx_v_wait, __pyx_v_callback);

  /* "mars/actors/pool/gevent_pool.pyx":888
 *         return future
 * 
 *     def _has_process_actor(self, int to_index, ActorRef actor_ref,             # <<<<<<<<<<<<<<
 *                            bint wait=True, object callback=None):
 *         cdef bytes message_id
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":902
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             self.future(message_id, future, callback=callback)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_18_has_process_actor_1check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_12Communicator_18_has_process_actor_1check = {"check", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_18_has_process_actor_1check, METH_NOARGS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_18_has_process_actor_1check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_18_has_process_actor_check(__pyx_self);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_18_has_process_actor_check(PyObject *__pyx_self) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor *__pyx_outer_scope;
  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;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future __pyx_t_5;
  __Pyx_RefNannySetupContext("check", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":903
 * 
 *         def check():
 *             self.pipe.put(message)             # <<<<<<<<<<<<<<
 *             self.future(message_id, future, callback=callback)
 * 
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 903, __pyx_L1_error) }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->pipe, __pyx_n_s_put); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 903, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(!__pyx_cur_scope->__pyx_v_message)) { __Pyx_RaiseClosureNameError("message"); __PYX_ERR(0, 903, __pyx_L1_error) }
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_cur_scope->__pyx_v_message) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_cur_scope->__pyx_v_message);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 903, __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;

  /* "mars/actors/pool/gevent_pool.pyx":904
 *         def check():
 *             self.pipe.put(message)
 *             self.future(message_id, future, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *         gevent.spawn(check)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 904, __pyx_L1_error) }
  if (unlikely(!__pyx_cur_scope->__pyx_v_message_id)) { __Pyx_RaiseClosureNameError("message_id"); __PYX_ERR(0, 904, __pyx_L1_error) }
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_message_id;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(!__pyx_cur_scope->__pyx_v_future)) { __Pyx_RaiseClosureNameError("future"); __PYX_ERR(0, 904, __pyx_L1_error) }
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_future;
  __Pyx_INCREF(__pyx_t_2);
  if (unlikely(!__pyx_cur_scope->__pyx_v_callback)) { __Pyx_RaiseClosureNameError("callback"); __PYX_ERR(0, 904, __pyx_L1_error) }
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_callback;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_5.__pyx_n = 1;
  __pyx_t_5.callback = __pyx_t_3;
  __pyx_t_4 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.future(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_1), __pyx_t_2, 0, &__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 904, __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_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":902
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             self.future(message_id, future, 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_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._has_process_actor.check", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":888
 *         return future
 * 
 *     def _has_process_actor(self, int to_index, ActorRef actor_ref,             # <<<<<<<<<<<<<<
 *                            bint wait=True, object callback=None):
 *         cdef bytes message_id
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_32_has_process_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, int __pyx_v_to_index, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor *__pyx_cur_scope;
  PyObject *__pyx_v_check = 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)(PyObject *);
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("_has_process_actor", 0);
  __pyx_cur_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor *)__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor(__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 888, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __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);

  /* "mars/actors/pool/gevent_pool.pyx":894
 *         cdef object future
 * 
 *         message_id, message = pack_has_actor_message(self.index, to_index, actor_ref)             # <<<<<<<<<<<<<<
 * 
 *         if wait:
 */
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_pack_has_actor_message(__pyx_cur_scope->__pyx_v_self->index, __pyx_v_to_index, __pyx_v_actor_ref, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 894, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 894, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    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_ERR(0, 894, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 894, __pyx_L1_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_ERR(0, 894, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(0, 894, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 894, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 894, __pyx_L1_error)
  if (!(likely(PyByteArray_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 894, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_cur_scope->__pyx_v_message_id = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_message = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":896
 *         message_id, message = pack_has_actor_message(self.index, to_index, actor_ref)
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             return self.submit(message_id)
 */
  __pyx_t_6 = (__pyx_v_wait != 0);
  if (__pyx_t_6) {

    /* "mars/actors/pool/gevent_pool.pyx":897
 * 
 *         if wait:
 *             self.pipe.put(message)             # <<<<<<<<<<<<<<
 *             return self.submit(message_id)
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->pipe, __pyx_n_s_put); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 897, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_cur_scope->__pyx_v_message) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_cur_scope->__pyx_v_message);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 897, __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;

    /* "mars/actors/pool/gevent_pool.pyx":898
 *         if wait:
 *             self.pipe.put(message)
 *             return self.submit(message_id)             # <<<<<<<<<<<<<<
 * 
 *         future = gevent.event.AsyncResult()
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __pyx_cur_scope->__pyx_v_message_id;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_3 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.submit(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_1), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 898, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":896
 *         message_id, message = pack_has_actor_message(self.index, to_index, actor_ref)
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             return self.submit(message_id)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":900
 *             return self.submit(message_id)
 * 
 *         future = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 * 
 *         def check():
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 900, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_event); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 900, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_AsyncResult); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 900, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 900, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_future = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":902
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             self.future(message_id, future, callback=callback)
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_12Communicator_18_has_process_actor_1check, 0, __pyx_n_s_has_process_actor_locals_check, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 902, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_check = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":906
 *             self.future(message_id, future, callback=callback)
 * 
 *         gevent.spawn(check)             # <<<<<<<<<<<<<<
 *         return future
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 906, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_spawn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 906, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_v_check) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_check);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 906, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":907
 * 
 *         gevent.spawn(check)
 *         return future             # <<<<<<<<<<<<<<
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, callback=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_future);
  __pyx_r = __pyx_cur_scope->__pyx_v_future;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":888
 *         return future
 * 
 *     def _has_process_actor(self, int to_index, ActorRef actor_ref,             # <<<<<<<<<<<<<<
 *                            bint wait=True, object callback=None):
 *         cdef bytes message_id
 */

  /* 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("mars.actors.pool.gevent_pool.Communicator._has_process_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_check);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":909
 *         return future
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, callback=None):             # <<<<<<<<<<<<<<
 *         return self._dispatch(self._has_local_actor, self._has_process_actor,
 *                               self.remote_handler.has_actor, actor_ref,
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_35has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator_has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_has_actor *__pyx_optional_args) {
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  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;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("has_actor", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_wait = __pyx_optional_args->wait;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_callback = __pyx_optional_args->callback;
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_has_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 909, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_35has_actor)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 909, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        __pyx_t_6 = 0;
        if (CYTHON_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 909, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 909, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 909, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 909, __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_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":910
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, callback=None):
 *         return self._dispatch(self._has_local_actor, self._has_process_actor,             # <<<<<<<<<<<<<<
 *                               self.remote_handler.has_actor, actor_ref,
 *                               (actor_ref,), dict(wait=wait, callback=callback))
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_has_local_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_has_process_actor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "mars/actors/pool/gevent_pool.pyx":911
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, callback=None):
 *         return self._dispatch(self._has_local_actor, self._has_process_actor,
 *                               self.remote_handler.has_actor, actor_ref,             # <<<<<<<<<<<<<<
 *                               (actor_ref,), dict(wait=wait, callback=callback))
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->remote_handler, __pyx_n_s_has_actor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 911, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "mars/actors/pool/gevent_pool.pyx":912
 *         return self._dispatch(self._has_local_actor, self._has_process_actor,
 *                               self.remote_handler.has_actor, actor_ref,
 *                               (actor_ref,), dict(wait=wait, callback=callback))             # <<<<<<<<<<<<<<
 * 
 *     cpdef _on_receive_send(self, bytes binary, object callback):
 */
  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 912, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
  PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_actor_ref));
  __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 912, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 912, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_wait, __pyx_t_5) < 0) __PYX_ERR(0, 912, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 912, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":910
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, callback=None):
 *         return self._dispatch(self._has_local_actor, self._has_process_actor,             # <<<<<<<<<<<<<<
 *                               self.remote_handler.has_actor, actor_ref,
 *                               (actor_ref,), dict(wait=wait, callback=callback))
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self->__pyx_base.__pyx_vtab)->_dispatch(__pyx_v_self, __pyx_t_1, __pyx_t_2, __pyx_t_4, __pyx_v_actor_ref, __pyx_t_7, __pyx_t_3, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":909
 *         return future
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, callback=None):             # <<<<<<<<<<<<<<
 *         return self._dispatch(self._has_local_actor, self._has_process_actor,
 *                               self.remote_handler.has_actor, actor_ref,
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_35has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_35has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("has_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "has_actor") < 0)) __PYX_ERR(0, 909, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    if (values[1]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 909, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("has_actor", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 909, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 909, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_34has_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_34has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_has_actor __pyx_t_2;
  __Pyx_RefNannySetupContext("has_actor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Communicator->has_actor(__pyx_v_self, __pyx_v_actor_ref, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 909, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":914
 *                               (actor_ref,), dict(wait=wait, callback=callback))
 * 
 *     cpdef _on_receive_send(self, bytes binary, object callback):             # <<<<<<<<<<<<<<
 *         cdef object message
 *         cdef MessageContext message_ctx
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_37_on_receive_send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_message = 0;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v_message_ctx = 0;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_actor_ctx = 0;
  PyObject *__pyx_v_result_binary = 0;
  PyObject *__pyx_v_t = 0;
  PyObject *__pyx_v_ex = 0;
  PyObject *__pyx_v_tb = 0;
  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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  __pyx_t_4mars_6actors_4pool_8messages_INT32_t __pyx_t_14;
  __Pyx_RefNannySetupContext("_on_receive_send", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_send); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 914, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_37_on_receive_send)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && 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);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_binary, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 914, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_binary, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 914, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 914, __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_binary);
          __Pyx_GIVEREF(__pyx_v_binary);
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_binary);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_callback);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 914, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":923
 *         cdef object tb
 * 
 *         message = unpack_send_message(binary)             # <<<<<<<<<<<<<<
 *         try:
 *             message_ctx = MessageContext(message.message)
 */
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_unpack_send_message(__pyx_v_binary, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 923, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_message = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":924
 * 
 *         message = unpack_send_message(binary)
 *         try:             # <<<<<<<<<<<<<<
 *             message_ctx = MessageContext(message.message)
 *             actor_ctx = self.pool.get_actor_execution_ctx(message.actor_ref.uid)
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
    __Pyx_XGOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_9);
    /*try:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":925
 *         message = unpack_send_message(binary)
 *         try:
 *             message_ctx = MessageContext(message.message)             # <<<<<<<<<<<<<<
 *             actor_ctx = self.pool.get_actor_execution_ctx(message.actor_ref.uid)
 *             actor_ctx.receive(message_ctx)
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_message); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 925, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_MessageContext), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 925, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_message_ctx = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)__pyx_t_2);
      __pyx_t_2 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":926
 *         try:
 *             message_ctx = MessageContext(message.message)
 *             actor_ctx = self.pool.get_actor_execution_ctx(message.actor_ref.uid)             # <<<<<<<<<<<<<<
 *             actor_ctx.receive(message_ctx)
 *             gevent.spawn(actor_ctx.fire_run)
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pool, __pyx_n_s_get_actor_execution_ctx); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 926, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_actor_ref); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 926, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_uid); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 926, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && 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);
        }
      }
      __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_6);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 926, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext))))) __PYX_ERR(0, 926, __pyx_L3_error)
      __pyx_v_actor_ctx = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_t_2);
      __pyx_t_2 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":927
 *             message_ctx = MessageContext(message.message)
 *             actor_ctx = self.pool.get_actor_execution_ctx(message.actor_ref.uid)
 *             actor_ctx.receive(message_ctx)             # <<<<<<<<<<<<<<
 *             gevent.spawn(actor_ctx.fire_run)
 * 
 */
      ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_actor_ctx->__pyx_vtab)->receive(__pyx_v_actor_ctx, __pyx_v_message_ctx, 0);

      /* "mars/actors/pool/gevent_pool.pyx":928
 *             actor_ctx = self.pool.get_actor_execution_ctx(message.actor_ref.uid)
 *             actor_ctx.receive(message_ctx)
 *             gevent.spawn(actor_ctx.fire_run)             # <<<<<<<<<<<<<<
 * 
 *             _, result_binary = pack_result_message(
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 928, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_spawn); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 928, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_actor_ctx), __pyx_n_s_fire_run); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 928, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(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);
        }
      }
      __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_3, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 928, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":931
 * 
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index, message_ctx.result())             # <<<<<<<<<<<<<<
 *         except:
 *             t, ex, tb = sys.exc_info()
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_message_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 931, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 931, __pyx_L3_error)
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_from_index); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 931, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_6); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 931, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_MessageContext *)__pyx_v_message_ctx->__pyx_vtab)->result(__pyx_v_message_ctx, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 931, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);

      /* "mars/actors/pool/gevent_pool.pyx":930
 *             gevent.spawn(actor_ctx.fire_run)
 * 
 *             _, result_binary = pack_result_message(             # <<<<<<<<<<<<<<
 *                 message.message_id, self.index, message.from_index, message_ctx.result())
 *         except:
 */
      __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_pack_result_message(((PyObject*)__pyx_t_2), __pyx_v_self->index, __pyx_t_5, __pyx_t_6, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 930, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 930, __pyx_L3_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_2);
        #else
        __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 930, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 930, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 930, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_3)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_10(__pyx_t_3); if (unlikely(!__pyx_t_6)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_2 = __pyx_t_10(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_3), 2) < 0) __PYX_ERR(0, 930, __pyx_L3_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L10_unpacking_done;
        __pyx_L9_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 930, __pyx_L3_error)
        __pyx_L10_unpacking_done:;
      }
      if (!(likely(PyByteArray_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 930, __pyx_L3_error)
      __pyx_v__ = __pyx_t_6;
      __pyx_t_6 = 0;
      __pyx_v_result_binary = ((PyObject*)__pyx_t_2);
      __pyx_t_2 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":924
 * 
 *         message = unpack_send_message(binary)
 *         try:             # <<<<<<<<<<<<<<
 *             message_ctx = MessageContext(message.message)
 *             actor_ctx = self.pool.get_actor_execution_ctx(message.actor_ref.uid)
 */
    }
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 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;

    /* "mars/actors/pool/gevent_pool.pyx":932
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index, message_ctx.result())
 *         except:             # <<<<<<<<<<<<<<
 *             t, ex, tb = sys.exc_info()
 *             _, result_binary = pack_error_message(
 */
    /*except:*/ {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_send", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_6) < 0) __PYX_ERR(0, 932, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_6);

      /* "mars/actors/pool/gevent_pool.pyx":933
 *                 message.message_id, self.index, message.from_index, message_ctx.result())
 *         except:
 *             t, ex, tb = sys.exc_info()             # <<<<<<<<<<<<<<
 *             _, result_binary = pack_error_message(
 *                 message.message_id, self.index, message.from_index, t, ex, tb)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_sys); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 933, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 933, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_11);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 933, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
        PyObject* sequence = __pyx_t_3;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 933, __pyx_L5_except_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_11 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_12);
        #else
        __pyx_t_11 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 933, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 933, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_12 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 933, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        #endif
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_13 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 933, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_13)->tp_iternext;
        index = 0; __pyx_t_11 = __pyx_t_10(__pyx_t_13); if (unlikely(!__pyx_t_11)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_11);
        index = 1; __pyx_t_4 = __pyx_t_10(__pyx_t_13); if (unlikely(!__pyx_t_4)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 2; __pyx_t_12 = __pyx_t_10(__pyx_t_13); if (unlikely(!__pyx_t_12)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_12);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_13), 3) < 0) __PYX_ERR(0, 933, __pyx_L5_except_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L14_unpacking_done;
        __pyx_L13_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 933, __pyx_L5_except_error)
        __pyx_L14_unpacking_done:;
      }
      __pyx_v_t = __pyx_t_11;
      __pyx_t_11 = 0;
      __pyx_v_ex = __pyx_t_4;
      __pyx_t_4 = 0;
      __pyx_v_tb = __pyx_t_12;
      __pyx_t_12 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":935
 *             t, ex, tb = sys.exc_info()
 *             _, result_binary = pack_error_message(
 *                 message.message_id, self.index, message.from_index, t, ex, tb)             # <<<<<<<<<<<<<<
 * 
 *         return callback(result_binary)
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_message_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 935, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 935, __pyx_L5_except_error)
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_from_index); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 935, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_14 = __Pyx_PyInt_As_npy_int32(__pyx_t_12); if (unlikely((__pyx_t_14 == ((npy_int32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 935, __pyx_L5_except_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":934
 *         except:
 *             t, ex, tb = sys.exc_info()
 *             _, result_binary = pack_error_message(             # <<<<<<<<<<<<<<
 *                 message.message_id, self.index, message.from_index, t, ex, tb)
 * 
 */
      __pyx_t_12 = __pyx_f_4mars_6actors_4pool_8messages_pack_error_message(((PyObject*)__pyx_t_3), __pyx_v_self->index, __pyx_t_14, __pyx_v_t, __pyx_v_ex, __pyx_v_tb, 0, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 934, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_12))) || (PyList_CheckExact(__pyx_t_12))) {
        PyObject* sequence = __pyx_t_12;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 934, __pyx_L5_except_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        #else
        __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 934, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 934, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 934, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_3 = __pyx_t_10(__pyx_t_11); if (unlikely(!__pyx_t_3)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        index = 1; __pyx_t_4 = __pyx_t_10(__pyx_t_11); if (unlikely(!__pyx_t_4)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_11), 2) < 0) __PYX_ERR(0, 934, __pyx_L5_except_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L16_unpacking_done;
        __pyx_L15_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 934, __pyx_L5_except_error)
        __pyx_L16_unpacking_done:;
      }
      if (!(likely(PyByteArray_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 934, __pyx_L5_except_error)
      __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_result_binary, ((PyObject*)__pyx_t_4));
      __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":924
 * 
 *         message = unpack_send_message(binary)
 *         try:             # <<<<<<<<<<<<<<
 *             message_ctx = MessageContext(message.message)
 *             actor_ctx = self.pool.get_actor_execution_ctx(message.actor_ref.uid)
 */
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    __pyx_L8_try_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":937
 *                 message.message_id, self.index, message.from_index, t, ex, tb)
 * 
 *         return callback(result_binary)             # <<<<<<<<<<<<<<
 * 
 *     cpdef _on_receive_tell(self, bytes binary, object callback):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_callback);
  __pyx_t_2 = __pyx_v_callback; __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_6 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_v_result_binary) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_result_binary);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 937, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":914
 *                               (actor_ref,), dict(wait=wait, callback=callback))
 * 
 *     cpdef _on_receive_send(self, bytes binary, object callback):             # <<<<<<<<<<<<<<
 *         cdef object message
 *         cdef MessageContext message_ctx
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_message);
  __Pyx_XDECREF((PyObject *)__pyx_v_message_ctx);
  __Pyx_XDECREF((PyObject *)__pyx_v_actor_ctx);
  __Pyx_XDECREF(__pyx_v_result_binary);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_ex);
  __Pyx_XDECREF(__pyx_v_tb);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_37_on_receive_send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_37_on_receive_send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_binary = 0;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_on_receive_send (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_binary,&__pyx_n_s_callback,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_binary)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_on_receive_send", 1, 2, 2, 1); __PYX_ERR(0, 914, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_on_receive_send") < 0)) __PYX_ERR(0, 914, __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_binary = ((PyObject*)values[0]);
    __pyx_v_callback = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_on_receive_send", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 914, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_binary), (&PyBytes_Type), 1, "binary", 1))) __PYX_ERR(0, 914, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_36_on_receive_send(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_binary, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_36_on_receive_send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_on_receive_send", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_send(__pyx_v_self, __pyx_v_binary, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 914, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":939
 *         return callback(result_binary)
 * 
 *     cpdef _on_receive_tell(self, bytes binary, object callback):             # <<<<<<<<<<<<<<
 *         cdef object message
 *         cdef ActorExecutionContext actor_ctx
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_39_on_receive_tell(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_message = 0;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v_actor_ctx = 0;
  PyObject *__pyx_v_result_binary = 0;
  PyObject *__pyx_v_t = 0;
  PyObject *__pyx_v_ex = 0;
  PyObject *__pyx_v_tb = 0;
  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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  __pyx_t_4mars_6actors_4pool_8messages_INT32_t __pyx_t_14;
  __Pyx_RefNannySetupContext("_on_receive_tell", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_tell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 939, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_39_on_receive_tell)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && 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);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_binary, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 939, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_binary, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 939, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 939, __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_binary);
          __Pyx_GIVEREF(__pyx_v_binary);
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_binary);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_callback);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 939, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":947
 *         cdef object tb
 * 
 *         message = unpack_tell_message(binary)             # <<<<<<<<<<<<<<
 *         try:
 *             actor_ctx = self.pool.get_actor_execution_ctx(message.actor_ref.uid)
 */
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_unpack_tell_message(__pyx_v_binary, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 947, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_message = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":948
 * 
 *         message = unpack_tell_message(binary)
 *         try:             # <<<<<<<<<<<<<<
 *             actor_ctx = self.pool.get_actor_execution_ctx(message.actor_ref.uid)
 *             actor_ctx.receive(MessageContext(message.message))
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
    __Pyx_XGOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_9);
    /*try:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":949
 *         message = unpack_tell_message(binary)
 *         try:
 *             actor_ctx = self.pool.get_actor_execution_ctx(message.actor_ref.uid)             # <<<<<<<<<<<<<<
 *             actor_ctx.receive(MessageContext(message.message))
 *             # do not wait for the completion of greenlet
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pool, __pyx_n_s_get_actor_execution_ctx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 949, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_actor_ref); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 949, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_uid); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 949, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 949, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext))))) __PYX_ERR(0, 949, __pyx_L3_error)
      __pyx_v_actor_ctx = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":950
 *         try:
 *             actor_ctx = self.pool.get_actor_execution_ctx(message.actor_ref.uid)
 *             actor_ctx.receive(MessageContext(message.message))             # <<<<<<<<<<<<<<
 *             # do not wait for the completion of greenlet
 *             gevent.spawn(actor_ctx.fire_run)
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_message); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 950, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_MessageContext), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 950, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v_actor_ctx->__pyx_vtab)->receive(__pyx_v_actor_ctx, ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)__pyx_t_2), 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":952
 *             actor_ctx.receive(MessageContext(message.message))
 *             # do not wait for the completion of greenlet
 *             gevent.spawn(actor_ctx.fire_run)             # <<<<<<<<<<<<<<
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index, None)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 952, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_spawn); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 952, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_actor_ctx), __pyx_n_s_fire_run); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 952, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(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);
        }
      }
      __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_3, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 952, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":954
 *             gevent.spawn(actor_ctx.fire_run)
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index, None)             # <<<<<<<<<<<<<<
 *         except:
 *             t, ex, tb = sys.exc_info()
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_message_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 954, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 954, __pyx_L3_error)
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_from_index); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 954, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_6); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 954, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":953
 *             # do not wait for the completion of greenlet
 *             gevent.spawn(actor_ctx.fire_run)
 *             _, result_binary = pack_result_message(             # <<<<<<<<<<<<<<
 *                 message.message_id, self.index, message.from_index, None)
 *         except:
 */
      __pyx_t_6 = __pyx_f_4mars_6actors_4pool_8messages_pack_result_message(((PyObject*)__pyx_t_2), __pyx_v_self->index, __pyx_t_5, Py_None, 0, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 953, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
        PyObject* sequence = __pyx_t_6;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 953, __pyx_L3_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_1);
        #else
        __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 953, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 953, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_3 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 953, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_3)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_10(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_1 = __pyx_t_10(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_3), 2) < 0) __PYX_ERR(0, 953, __pyx_L3_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L10_unpacking_done;
        __pyx_L9_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 953, __pyx_L3_error)
        __pyx_L10_unpacking_done:;
      }
      if (!(likely(PyByteArray_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 953, __pyx_L3_error)
      __pyx_v__ = __pyx_t_2;
      __pyx_t_2 = 0;
      __pyx_v_result_binary = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":948
 * 
 *         message = unpack_tell_message(binary)
 *         try:             # <<<<<<<<<<<<<<
 *             actor_ctx = self.pool.get_actor_execution_ctx(message.actor_ref.uid)
 *             actor_ctx.receive(MessageContext(message.message))
 */
    }
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":955
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index, None)
 *         except:             # <<<<<<<<<<<<<<
 *             t, ex, tb = sys.exc_info()
 *             _, result_binary = pack_error_message(
 */
    /*except:*/ {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_tell", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 955, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);

      /* "mars/actors/pool/gevent_pool.pyx":956
 *                 message.message_id, self.index, message.from_index, None)
 *         except:
 *             t, ex, tb = sys.exc_info()             # <<<<<<<<<<<<<<
 *             _, result_binary = pack_error_message(
 *                 message.message_id, self.index, message.from_index, t, ex, tb)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_sys); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 956, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 956, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_11);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 956, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
        PyObject* sequence = __pyx_t_3;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 956, __pyx_L5_except_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_11 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_12);
        #else
        __pyx_t_11 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 956, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 956, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_12 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 956, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        #endif
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_13 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 956, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_13)->tp_iternext;
        index = 0; __pyx_t_11 = __pyx_t_10(__pyx_t_13); if (unlikely(!__pyx_t_11)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_11);
        index = 1; __pyx_t_4 = __pyx_t_10(__pyx_t_13); if (unlikely(!__pyx_t_4)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 2; __pyx_t_12 = __pyx_t_10(__pyx_t_13); if (unlikely(!__pyx_t_12)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_12);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_13), 3) < 0) __PYX_ERR(0, 956, __pyx_L5_except_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L14_unpacking_done;
        __pyx_L13_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 956, __pyx_L5_except_error)
        __pyx_L14_unpacking_done:;
      }
      __pyx_v_t = __pyx_t_11;
      __pyx_t_11 = 0;
      __pyx_v_ex = __pyx_t_4;
      __pyx_t_4 = 0;
      __pyx_v_tb = __pyx_t_12;
      __pyx_t_12 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":958
 *             t, ex, tb = sys.exc_info()
 *             _, result_binary = pack_error_message(
 *                 message.message_id, self.index, message.from_index, t, ex, tb)             # <<<<<<<<<<<<<<
 * 
 *         return callback(result_binary)
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_message_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 958, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 958, __pyx_L5_except_error)
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_from_index); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 958, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_14 = __Pyx_PyInt_As_npy_int32(__pyx_t_12); if (unlikely((__pyx_t_14 == ((npy_int32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 958, __pyx_L5_except_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":957
 *         except:
 *             t, ex, tb = sys.exc_info()
 *             _, result_binary = pack_error_message(             # <<<<<<<<<<<<<<
 *                 message.message_id, self.index, message.from_index, t, ex, tb)
 * 
 */
      __pyx_t_12 = __pyx_f_4mars_6actors_4pool_8messages_pack_error_message(((PyObject*)__pyx_t_3), __pyx_v_self->index, __pyx_t_14, __pyx_v_t, __pyx_v_ex, __pyx_v_tb, 0, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 957, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_12))) || (PyList_CheckExact(__pyx_t_12))) {
        PyObject* sequence = __pyx_t_12;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 957, __pyx_L5_except_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        #else
        __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 957, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 957, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 957, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_3 = __pyx_t_10(__pyx_t_11); if (unlikely(!__pyx_t_3)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        index = 1; __pyx_t_4 = __pyx_t_10(__pyx_t_11); if (unlikely(!__pyx_t_4)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_11), 2) < 0) __PYX_ERR(0, 957, __pyx_L5_except_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L16_unpacking_done;
        __pyx_L15_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 957, __pyx_L5_except_error)
        __pyx_L16_unpacking_done:;
      }
      if (!(likely(PyByteArray_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 957, __pyx_L5_except_error)
      __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_result_binary, ((PyObject*)__pyx_t_4));
      __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":948
 * 
 *         message = unpack_tell_message(binary)
 *         try:             # <<<<<<<<<<<<<<
 *             actor_ctx = self.pool.get_actor_execution_ctx(message.actor_ref.uid)
 *             actor_ctx.receive(MessageContext(message.message))
 */
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    __pyx_L8_try_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":960
 *                 message.message_id, self.index, message.from_index, t, ex, tb)
 * 
 *         return callback(result_binary)             # <<<<<<<<<<<<<<
 * 
 *     cpdef _on_receive_create_actor(self, bytes binary, object callback):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_callback);
  __pyx_t_1 = __pyx_v_callback; __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_v_result_binary) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_result_binary);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 960, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":939
 *         return callback(result_binary)
 * 
 *     cpdef _on_receive_tell(self, bytes binary, object callback):             # <<<<<<<<<<<<<<
 *         cdef object message
 *         cdef ActorExecutionContext actor_ctx
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_tell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_message);
  __Pyx_XDECREF((PyObject *)__pyx_v_actor_ctx);
  __Pyx_XDECREF(__pyx_v_result_binary);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_ex);
  __Pyx_XDECREF(__pyx_v_tb);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_39_on_receive_tell(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_39_on_receive_tell(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_binary = 0;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_on_receive_tell (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_binary,&__pyx_n_s_callback,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_binary)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_on_receive_tell", 1, 2, 2, 1); __PYX_ERR(0, 939, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_on_receive_tell") < 0)) __PYX_ERR(0, 939, __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_binary = ((PyObject*)values[0]);
    __pyx_v_callback = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_on_receive_tell", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 939, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_tell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_binary), (&PyBytes_Type), 1, "binary", 1))) __PYX_ERR(0, 939, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_38_on_receive_tell(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_binary, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_38_on_receive_tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_on_receive_tell", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_tell(__pyx_v_self, __pyx_v_binary, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 939, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_tell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":962
 *         return callback(result_binary)
 * 
 *     cpdef _on_receive_create_actor(self, bytes binary, object callback):             # <<<<<<<<<<<<<<
 *         cdef object message
 *         cdef ActorExecutionContext actor_ctx
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_41_on_receive_create_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_message = 0;
  PyObject *__pyx_v_result_binary = 0;
  PyObject *__pyx_v_t = 0;
  PyObject *__pyx_v_ex = 0;
  PyObject *__pyx_v_tb = 0;
  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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  __pyx_t_4mars_6actors_4pool_8messages_INT32_t __pyx_t_14;
  __Pyx_RefNannySetupContext("_on_receive_create_actor", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_create_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 962, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_41_on_receive_create_actor)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && 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);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_binary, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 962, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_binary, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 962, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 962, __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_binary);
          __Pyx_GIVEREF(__pyx_v_binary);
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_binary);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_callback);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 962, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":970
 *         cdef object tb
 * 
 *         message = unpack_create_actor_message(binary)             # <<<<<<<<<<<<<<
 *         try:
 *             _, result_binary = pack_result_message(
 */
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_unpack_create_actor_message(__pyx_v_binary, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 970, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_message = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":971
 * 
 *         message = unpack_create_actor_message(binary)
 *         try:             # <<<<<<<<<<<<<<
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index,
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
    __Pyx_XGOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_9);
    /*try:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":973
 *         try:
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index,             # <<<<<<<<<<<<<<
 *                 self.pool.create_actor(message.actor_cls, message.actor_ref.uid,
 *                                        *message.args, **message.kwargs))
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_message_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 973, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 973, __pyx_L3_error)
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_from_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 973, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 973, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":974
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index,
 *                 self.pool.create_actor(message.actor_cls, message.actor_ref.uid,             # <<<<<<<<<<<<<<
 *                                        *message.args, **message.kwargs))
 *         except:
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pool, __pyx_n_s_create_actor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 974, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_actor_cls); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 974, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_actor_ref); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 974, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uid); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 974, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 974, __pyx_L3_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_t_3 = 0;
      __pyx_t_4 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":975
 *                 message.message_id, self.index, message.from_index,
 *                 self.pool.create_actor(message.actor_cls, message.actor_ref.uid,
 *                                        *message.args, **message.kwargs))             # <<<<<<<<<<<<<<
 *         except:
 *             t, ex, tb = sys.exc_info()
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 975, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);

      /* "mars/actors/pool/gevent_pool.pyx":974
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index,
 *                 self.pool.create_actor(message.actor_cls, message.actor_ref.uid,             # <<<<<<<<<<<<<<
 *                                        *message.args, **message.kwargs))
 *         except:
 */
      __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 974, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyNumber_Add(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 974, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":975
 *                 message.message_id, self.index, message.from_index,
 *                 self.pool.create_actor(message.actor_cls, message.actor_ref.uid,
 *                                        *message.args, **message.kwargs))             # <<<<<<<<<<<<<<
 *         except:
 *             t, ex, tb = sys.exc_info()
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_kwargs); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 975, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (unlikely(__pyx_t_6 == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
        __PYX_ERR(0, 975, __pyx_L3_error)
      }
      if (likely(PyDict_CheckExact(__pyx_t_6))) {
        __pyx_t_3 = PyDict_Copy(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 975, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else {
        __pyx_t_3 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 974, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }

      /* "mars/actors/pool/gevent_pool.pyx":974
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index,
 *                 self.pool.create_actor(message.actor_cls, message.actor_ref.uid,             # <<<<<<<<<<<<<<
 *                                        *message.args, **message.kwargs))
 *         except:
 */
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 974, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":972
 *         message = unpack_create_actor_message(binary)
 *         try:
 *             _, result_binary = pack_result_message(             # <<<<<<<<<<<<<<
 *                 message.message_id, self.index, message.from_index,
 *                 self.pool.create_actor(message.actor_cls, message.actor_ref.uid,
 */
      __pyx_t_3 = __pyx_f_4mars_6actors_4pool_8messages_pack_result_message(((PyObject*)__pyx_t_1), __pyx_v_self->index, __pyx_t_5, __pyx_t_6, 0, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 972, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
        PyObject* sequence = __pyx_t_3;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 972, __pyx_L3_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_1);
        #else
        __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 972, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 972, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 972, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_10(__pyx_t_4); if (unlikely(!__pyx_t_6)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_1 = __pyx_t_10(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_4), 2) < 0) __PYX_ERR(0, 972, __pyx_L3_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L10_unpacking_done;
        __pyx_L9_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 972, __pyx_L3_error)
        __pyx_L10_unpacking_done:;
      }
      if (!(likely(PyByteArray_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 972, __pyx_L3_error)
      __pyx_v__ = __pyx_t_6;
      __pyx_t_6 = 0;
      __pyx_v_result_binary = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":971
 * 
 *         message = unpack_create_actor_message(binary)
 *         try:             # <<<<<<<<<<<<<<
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index,
 */
    }
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":976
 *                 self.pool.create_actor(message.actor_cls, message.actor_ref.uid,
 *                                        *message.args, **message.kwargs))
 *         except:             # <<<<<<<<<<<<<<
 *             t, ex, tb = sys.exc_info()
 *             _, result_binary = pack_error_message(
 */
    /*except:*/ {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_6) < 0) __PYX_ERR(0, 976, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_6);

      /* "mars/actors/pool/gevent_pool.pyx":977
 *                                        *message.args, **message.kwargs))
 *         except:
 *             t, ex, tb = sys.exc_info()             # <<<<<<<<<<<<<<
 *             _, result_binary = pack_error_message(
 *                 message.message_id, self.index, message.from_index, t, ex, tb)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_sys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 977, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 977, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      __pyx_t_4 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_11);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 977, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
        PyObject* sequence = __pyx_t_4;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 977, __pyx_L5_except_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_11 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_12);
        #else
        __pyx_t_11 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 977, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 977, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_12 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 977, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        #endif
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_13 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 977, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_13)->tp_iternext;
        index = 0; __pyx_t_11 = __pyx_t_10(__pyx_t_13); if (unlikely(!__pyx_t_11)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_11);
        index = 1; __pyx_t_2 = __pyx_t_10(__pyx_t_13); if (unlikely(!__pyx_t_2)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 2; __pyx_t_12 = __pyx_t_10(__pyx_t_13); if (unlikely(!__pyx_t_12)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_12);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_13), 3) < 0) __PYX_ERR(0, 977, __pyx_L5_except_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L14_unpacking_done;
        __pyx_L13_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 977, __pyx_L5_except_error)
        __pyx_L14_unpacking_done:;
      }
      __pyx_v_t = __pyx_t_11;
      __pyx_t_11 = 0;
      __pyx_v_ex = __pyx_t_2;
      __pyx_t_2 = 0;
      __pyx_v_tb = __pyx_t_12;
      __pyx_t_12 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":979
 *             t, ex, tb = sys.exc_info()
 *             _, result_binary = pack_error_message(
 *                 message.message_id, self.index, message.from_index, t, ex, tb)             # <<<<<<<<<<<<<<
 * 
 *         return callback(result_binary)
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_message_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 979, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 979, __pyx_L5_except_error)
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_from_index); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 979, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_14 = __Pyx_PyInt_As_npy_int32(__pyx_t_12); if (unlikely((__pyx_t_14 == ((npy_int32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 979, __pyx_L5_except_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":978
 *         except:
 *             t, ex, tb = sys.exc_info()
 *             _, result_binary = pack_error_message(             # <<<<<<<<<<<<<<
 *                 message.message_id, self.index, message.from_index, t, ex, tb)
 * 
 */
      __pyx_t_12 = __pyx_f_4mars_6actors_4pool_8messages_pack_error_message(((PyObject*)__pyx_t_4), __pyx_v_self->index, __pyx_t_14, __pyx_v_t, __pyx_v_ex, __pyx_v_tb, 0, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 978, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_12))) || (PyList_CheckExact(__pyx_t_12))) {
        PyObject* sequence = __pyx_t_12;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 978, __pyx_L5_except_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        #else
        __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 978, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 978, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 978, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_4 = __pyx_t_10(__pyx_t_11); if (unlikely(!__pyx_t_4)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 1; __pyx_t_2 = __pyx_t_10(__pyx_t_11); if (unlikely(!__pyx_t_2)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_11), 2) < 0) __PYX_ERR(0, 978, __pyx_L5_except_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L16_unpacking_done;
        __pyx_L15_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 978, __pyx_L5_except_error)
        __pyx_L16_unpacking_done:;
      }
      if (!(likely(PyByteArray_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 978, __pyx_L5_except_error)
      __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_result_binary, ((PyObject*)__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_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":971
 * 
 *         message = unpack_create_actor_message(binary)
 *         try:             # <<<<<<<<<<<<<<
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index,
 */
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    __pyx_L8_try_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":981
 *                 message.message_id, self.index, message.from_index, t, ex, tb)
 * 
 *         return callback(result_binary)             # <<<<<<<<<<<<<<
 * 
 *     cpdef _on_receive_destroy_actor(self, bytes binary, object callback):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_callback);
  __pyx_t_1 = __pyx_v_callback; __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_6 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_v_result_binary) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_result_binary);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 981, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":962
 *         return callback(result_binary)
 * 
 *     cpdef _on_receive_create_actor(self, bytes binary, object callback):             # <<<<<<<<<<<<<<
 *         cdef object message
 *         cdef ActorExecutionContext actor_ctx
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_message);
  __Pyx_XDECREF(__pyx_v_result_binary);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_ex);
  __Pyx_XDECREF(__pyx_v_tb);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_41_on_receive_create_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_41_on_receive_create_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_binary = 0;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_on_receive_create_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_binary,&__pyx_n_s_callback,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_binary)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_on_receive_create_actor", 1, 2, 2, 1); __PYX_ERR(0, 962, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_on_receive_create_actor") < 0)) __PYX_ERR(0, 962, __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_binary = ((PyObject*)values[0]);
    __pyx_v_callback = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_on_receive_create_actor", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 962, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_binary), (&PyBytes_Type), 1, "binary", 1))) __PYX_ERR(0, 962, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_40_on_receive_create_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_binary, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_40_on_receive_create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_on_receive_create_actor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_create_actor(__pyx_v_self, __pyx_v_binary, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 962, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":983
 *         return callback(result_binary)
 * 
 *     cpdef _on_receive_destroy_actor(self, bytes binary, object callback):             # <<<<<<<<<<<<<<
 *         cdef object message
 *         cdef bytearray result_binary
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_43_on_receive_destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_message = 0;
  PyObject *__pyx_v_result_binary = 0;
  PyObject *__pyx_v_t = 0;
  PyObject *__pyx_v_ex = 0;
  PyObject *__pyx_v_tb = 0;
  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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  __pyx_t_4mars_6actors_4pool_8messages_INT32_t __pyx_t_14;
  __Pyx_RefNannySetupContext("_on_receive_destroy_actor", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_destroy_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 983, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_43_on_receive_destroy_actor)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && 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);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_binary, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 983, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_binary, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 983, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 983, __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_binary);
          __Pyx_GIVEREF(__pyx_v_binary);
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_binary);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_callback);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 983, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":990
 *         cdef object tb
 * 
 *         message = unpack_destroy_actor_message(binary)             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_unpack_destroy_actor_message(__pyx_v_binary, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 990, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_message = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":992
 *         message = unpack_destroy_actor_message(binary)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index,
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
    __Pyx_XGOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_9);
    /*try:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":994
 *         try:
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index,             # <<<<<<<<<<<<<<
 *                 self.pool.destroy_actor(message.actor_ref.uid))
 *         except:
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_message_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 994, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 994, __pyx_L3_error)
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_from_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 994, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 994, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":995
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index,
 *                 self.pool.destroy_actor(message.actor_ref.uid))             # <<<<<<<<<<<<<<
 *         except:
 *             t, ex, tb = sys.exc_info()
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pool, __pyx_n_s_destroy_actor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 995, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_actor_ref); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 995, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uid); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 995, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(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);
        }
      }
      __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_6, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 995, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":993
 * 
 *         try:
 *             _, result_binary = pack_result_message(             # <<<<<<<<<<<<<<
 *                 message.message_id, self.index, message.from_index,
 *                 self.pool.destroy_actor(message.actor_ref.uid))
 */
      __pyx_t_3 = __pyx_f_4mars_6actors_4pool_8messages_pack_result_message(((PyObject*)__pyx_t_1), __pyx_v_self->index, __pyx_t_5, __pyx_t_2, 0, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 993, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
        PyObject* sequence = __pyx_t_3;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 993, __pyx_L3_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_1);
        #else
        __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 993, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 993, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 993, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_10(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_1 = __pyx_t_10(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_4), 2) < 0) __PYX_ERR(0, 993, __pyx_L3_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L10_unpacking_done;
        __pyx_L9_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 993, __pyx_L3_error)
        __pyx_L10_unpacking_done:;
      }
      if (!(likely(PyByteArray_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 993, __pyx_L3_error)
      __pyx_v__ = __pyx_t_2;
      __pyx_t_2 = 0;
      __pyx_v_result_binary = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":992
 *         message = unpack_destroy_actor_message(binary)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index,
 */
    }
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 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;

    /* "mars/actors/pool/gevent_pool.pyx":996
 *                 message.message_id, self.index, message.from_index,
 *                 self.pool.destroy_actor(message.actor_ref.uid))
 *         except:             # <<<<<<<<<<<<<<
 *             t, ex, tb = sys.exc_info()
 *             _, result_binary = pack_error_message(
 */
    /*except:*/ {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 996, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);

      /* "mars/actors/pool/gevent_pool.pyx":997
 *                 self.pool.destroy_actor(message.actor_ref.uid))
 *         except:
 *             t, ex, tb = sys.exc_info()             # <<<<<<<<<<<<<<
 *             _, result_binary = pack_error_message(
 *                 message.message_id, self.index, message.from_index, t, ex, tb)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_sys); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 997, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 997, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_11);
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 997, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
        PyObject* sequence = __pyx_t_4;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 997, __pyx_L5_except_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_11 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_12);
        #else
        __pyx_t_11 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 997, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 997, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_12 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 997, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        #endif
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_13 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 997, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_13)->tp_iternext;
        index = 0; __pyx_t_11 = __pyx_t_10(__pyx_t_13); if (unlikely(!__pyx_t_11)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_11);
        index = 1; __pyx_t_6 = __pyx_t_10(__pyx_t_13); if (unlikely(!__pyx_t_6)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 2; __pyx_t_12 = __pyx_t_10(__pyx_t_13); if (unlikely(!__pyx_t_12)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_12);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_13), 3) < 0) __PYX_ERR(0, 997, __pyx_L5_except_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L14_unpacking_done;
        __pyx_L13_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 997, __pyx_L5_except_error)
        __pyx_L14_unpacking_done:;
      }
      __pyx_v_t = __pyx_t_11;
      __pyx_t_11 = 0;
      __pyx_v_ex = __pyx_t_6;
      __pyx_t_6 = 0;
      __pyx_v_tb = __pyx_t_12;
      __pyx_t_12 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":999
 *             t, ex, tb = sys.exc_info()
 *             _, result_binary = pack_error_message(
 *                 message.message_id, self.index, message.from_index, t, ex, tb)             # <<<<<<<<<<<<<<
 * 
 *         return callback(result_binary)
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_message_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 999, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 999, __pyx_L5_except_error)
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_from_index); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 999, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_14 = __Pyx_PyInt_As_npy_int32(__pyx_t_12); if (unlikely((__pyx_t_14 == ((npy_int32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 999, __pyx_L5_except_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":998
 *         except:
 *             t, ex, tb = sys.exc_info()
 *             _, result_binary = pack_error_message(             # <<<<<<<<<<<<<<
 *                 message.message_id, self.index, message.from_index, t, ex, tb)
 * 
 */
      __pyx_t_12 = __pyx_f_4mars_6actors_4pool_8messages_pack_error_message(((PyObject*)__pyx_t_4), __pyx_v_self->index, __pyx_t_14, __pyx_v_t, __pyx_v_ex, __pyx_v_tb, 0, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 998, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_12))) || (PyList_CheckExact(__pyx_t_12))) {
        PyObject* sequence = __pyx_t_12;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 998, __pyx_L5_except_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        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_ERR(0, 998, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 998, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 998, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_4 = __pyx_t_10(__pyx_t_11); if (unlikely(!__pyx_t_4)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 1; __pyx_t_6 = __pyx_t_10(__pyx_t_11); if (unlikely(!__pyx_t_6)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_11), 2) < 0) __PYX_ERR(0, 998, __pyx_L5_except_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L16_unpacking_done;
        __pyx_L15_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 998, __pyx_L5_except_error)
        __pyx_L16_unpacking_done:;
      }
      if (!(likely(PyByteArray_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_6)->tp_name), 0))) __PYX_ERR(0, 998, __pyx_L5_except_error)
      __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_result_binary, ((PyObject*)__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_2); __pyx_t_2 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":992
 *         message = unpack_destroy_actor_message(binary)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index,
 */
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    __pyx_L8_try_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":1001
 *                 message.message_id, self.index, message.from_index, t, ex, tb)
 * 
 *         return callback(result_binary)             # <<<<<<<<<<<<<<
 * 
 *     cpdef _on_receive_has_actor(self, bytes binary, object callback):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_callback);
  __pyx_t_1 = __pyx_v_callback; __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_v_result_binary) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_result_binary);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":983
 *         return callback(result_binary)
 * 
 *     cpdef _on_receive_destroy_actor(self, bytes binary, object callback):             # <<<<<<<<<<<<<<
 *         cdef object message
 *         cdef bytearray result_binary
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_message);
  __Pyx_XDECREF(__pyx_v_result_binary);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_ex);
  __Pyx_XDECREF(__pyx_v_tb);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_43_on_receive_destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_43_on_receive_destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_binary = 0;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_on_receive_destroy_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_binary,&__pyx_n_s_callback,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_binary)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_on_receive_destroy_actor", 1, 2, 2, 1); __PYX_ERR(0, 983, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_on_receive_destroy_actor") < 0)) __PYX_ERR(0, 983, __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_binary = ((PyObject*)values[0]);
    __pyx_v_callback = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_on_receive_destroy_actor", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 983, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_binary), (&PyBytes_Type), 1, "binary", 1))) __PYX_ERR(0, 983, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_42_on_receive_destroy_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_binary, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_42_on_receive_destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_on_receive_destroy_actor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_destroy_actor(__pyx_v_self, __pyx_v_binary, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 983, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1003
 *         return callback(result_binary)
 * 
 *     cpdef _on_receive_has_actor(self, bytes binary, object callback):             # <<<<<<<<<<<<<<
 *         cdef object message
 *         cdef bytearray result_binary
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_45_on_receive_has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_message = 0;
  PyObject *__pyx_v_result_binary = 0;
  PyObject *__pyx_v_t = 0;
  PyObject *__pyx_v_ex = 0;
  PyObject *__pyx_v_tb = 0;
  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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  __pyx_t_4mars_6actors_4pool_8messages_INT32_t __pyx_t_14;
  __Pyx_RefNannySetupContext("_on_receive_has_actor", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_has_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1003, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_45_on_receive_has_actor)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && 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);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_binary, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1003, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_binary, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1003, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1003, __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_binary);
          __Pyx_GIVEREF(__pyx_v_binary);
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_binary);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_callback);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1003, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":1010
 *         cdef object tb
 * 
 *         message = unpack_has_actor_message(binary)             # <<<<<<<<<<<<<<
 * 
 *         try:
 */
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_unpack_has_actor_message(__pyx_v_binary, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1010, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_message = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1012
 *         message = unpack_has_actor_message(binary)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index,
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
    __Pyx_XGOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_9);
    /*try:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":1014
 *         try:
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index,             # <<<<<<<<<<<<<<
 *                 self.pool.has_actor(message.actor_ref.uid))
 *         except:
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_message_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1014, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 1014, __pyx_L3_error)
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_from_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1014, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1014, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":1015
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index,
 *                 self.pool.has_actor(message.actor_ref.uid))             # <<<<<<<<<<<<<<
 *         except:
 *             t, ex, tb = sys.exc_info()
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pool, __pyx_n_s_has_actor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1015, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_actor_ref); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1015, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uid); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1015, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(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);
        }
      }
      __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_6, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1015, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":1013
 * 
 *         try:
 *             _, result_binary = pack_result_message(             # <<<<<<<<<<<<<<
 *                 message.message_id, self.index, message.from_index,
 *                 self.pool.has_actor(message.actor_ref.uid))
 */
      __pyx_t_3 = __pyx_f_4mars_6actors_4pool_8messages_pack_result_message(((PyObject*)__pyx_t_1), __pyx_v_self->index, __pyx_t_5, __pyx_t_2, 0, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1013, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
        PyObject* sequence = __pyx_t_3;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 1013, __pyx_L3_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_1);
        #else
        __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1013, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1013, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1013, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_10(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_1 = __pyx_t_10(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L9_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_4), 2) < 0) __PYX_ERR(0, 1013, __pyx_L3_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L10_unpacking_done;
        __pyx_L9_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 1013, __pyx_L3_error)
        __pyx_L10_unpacking_done:;
      }
      if (!(likely(PyByteArray_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 1013, __pyx_L3_error)
      __pyx_v__ = __pyx_t_2;
      __pyx_t_2 = 0;
      __pyx_v_result_binary = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":1012
 *         message = unpack_has_actor_message(binary)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index,
 */
    }
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 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;

    /* "mars/actors/pool/gevent_pool.pyx":1016
 *                 message.message_id, self.index, message.from_index,
 *                 self.pool.has_actor(message.actor_ref.uid))
 *         except:             # <<<<<<<<<<<<<<
 *             t, ex, tb = sys.exc_info()
 *             _, result_binary = pack_error_message(
 */
    /*except:*/ {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 1016, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);

      /* "mars/actors/pool/gevent_pool.pyx":1017
 *                 self.pool.has_actor(message.actor_ref.uid))
 *         except:
 *             t, ex, tb = sys.exc_info()             # <<<<<<<<<<<<<<
 *             _, result_binary = pack_error_message(
 *                 message.message_id, self.index, message.from_index, t, ex, tb)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_sys); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1017, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1017, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_11);
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1017, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
        PyObject* sequence = __pyx_t_4;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 1017, __pyx_L5_except_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          __pyx_t_11 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_12 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_12);
        #else
        __pyx_t_11 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1017, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1017, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_12 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1017, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        #endif
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_13 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1017, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_13)->tp_iternext;
        index = 0; __pyx_t_11 = __pyx_t_10(__pyx_t_13); if (unlikely(!__pyx_t_11)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_11);
        index = 1; __pyx_t_6 = __pyx_t_10(__pyx_t_13); if (unlikely(!__pyx_t_6)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 2; __pyx_t_12 = __pyx_t_10(__pyx_t_13); if (unlikely(!__pyx_t_12)) goto __pyx_L13_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_12);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_13), 3) < 0) __PYX_ERR(0, 1017, __pyx_L5_except_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L14_unpacking_done;
        __pyx_L13_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 1017, __pyx_L5_except_error)
        __pyx_L14_unpacking_done:;
      }
      __pyx_v_t = __pyx_t_11;
      __pyx_t_11 = 0;
      __pyx_v_ex = __pyx_t_6;
      __pyx_t_6 = 0;
      __pyx_v_tb = __pyx_t_12;
      __pyx_t_12 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":1019
 *             t, ex, tb = sys.exc_info()
 *             _, result_binary = pack_error_message(
 *                 message.message_id, self.index, message.from_index, t, ex, tb)             # <<<<<<<<<<<<<<
 * 
 *         return callback(result_binary)
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_message_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1019, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 1019, __pyx_L5_except_error)
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_from_index); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1019, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_14 = __Pyx_PyInt_As_npy_int32(__pyx_t_12); if (unlikely((__pyx_t_14 == ((npy_int32)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1019, __pyx_L5_except_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":1018
 *         except:
 *             t, ex, tb = sys.exc_info()
 *             _, result_binary = pack_error_message(             # <<<<<<<<<<<<<<
 *                 message.message_id, self.index, message.from_index, t, ex, tb)
 * 
 */
      __pyx_t_12 = __pyx_f_4mars_6actors_4pool_8messages_pack_error_message(((PyObject*)__pyx_t_4), __pyx_v_self->index, __pyx_t_14, __pyx_v_t, __pyx_v_ex, __pyx_v_tb, 0, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1018, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_12))) || (PyList_CheckExact(__pyx_t_12))) {
        PyObject* sequence = __pyx_t_12;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 1018, __pyx_L5_except_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        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_ERR(0, 1018, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1018, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_11 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1018, __pyx_L5_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_11)->tp_iternext;
        index = 0; __pyx_t_4 = __pyx_t_10(__pyx_t_11); if (unlikely(!__pyx_t_4)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 1; __pyx_t_6 = __pyx_t_10(__pyx_t_11); if (unlikely(!__pyx_t_6)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_11), 2) < 0) __PYX_ERR(0, 1018, __pyx_L5_except_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L16_unpacking_done;
        __pyx_L15_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 1018, __pyx_L5_except_error)
        __pyx_L16_unpacking_done:;
      }
      if (!(likely(PyByteArray_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_6)->tp_name), 0))) __PYX_ERR(0, 1018, __pyx_L5_except_error)
      __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_result_binary, ((PyObject*)__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_2); __pyx_t_2 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":1012
 *         message = unpack_has_actor_message(binary)
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             _, result_binary = pack_result_message(
 *                 message.message_id, self.index, message.from_index,
 */
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    __pyx_L8_try_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":1021
 *                 message.message_id, self.index, message.from_index, t, ex, tb)
 * 
 *         return callback(result_binary)             # <<<<<<<<<<<<<<
 * 
 *     cpdef _on_receive_result(self, bytes binary, object callback):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_callback);
  __pyx_t_1 = __pyx_v_callback; __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_v_result_binary) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_result_binary);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1021, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1003
 *         return callback(result_binary)
 * 
 *     cpdef _on_receive_has_actor(self, bytes binary, object callback):             # <<<<<<<<<<<<<<
 *         cdef object message
 *         cdef bytearray result_binary
 */

  /* 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_6);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_message);
  __Pyx_XDECREF(__pyx_v_result_binary);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_ex);
  __Pyx_XDECREF(__pyx_v_tb);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_45_on_receive_has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_45_on_receive_has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_binary = 0;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_on_receive_has_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_binary,&__pyx_n_s_callback,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_binary)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_on_receive_has_actor", 1, 2, 2, 1); __PYX_ERR(0, 1003, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_on_receive_has_actor") < 0)) __PYX_ERR(0, 1003, __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_binary = ((PyObject*)values[0]);
    __pyx_v_callback = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_on_receive_has_actor", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1003, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_binary), (&PyBytes_Type), 1, "binary", 1))) __PYX_ERR(0, 1003, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_44_on_receive_has_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_binary, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_44_on_receive_has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_on_receive_has_actor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_has_actor(__pyx_v_self, __pyx_v_binary, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1003, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1023
 *         return callback(result_binary)
 * 
 *     cpdef _on_receive_result(self, bytes binary, object callback):             # <<<<<<<<<<<<<<
 *         cdef object message
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_47_on_receive_result(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_result(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, CYTHON_UNUSED PyObject *__pyx_v_callback, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_message = 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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("_on_receive_result", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1023, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_47_on_receive_result)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && 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);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_binary, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1023, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_binary, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1023, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1023, __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_binary);
          __Pyx_GIVEREF(__pyx_v_binary);
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_binary);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_callback);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1023, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":1026
 *         cdef object message
 * 
 *         message = unpack_result_message(binary)             # <<<<<<<<<<<<<<
 *         self.got(message.message_id, message.result)
 * 
 */
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_unpack_result_message(__pyx_v_binary, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1026, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_message = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1027
 * 
 *         message = unpack_result_message(binary)
 *         self.got(message.message_id, message.result)             # <<<<<<<<<<<<<<
 * 
 *     cpdef _on_receive_error(self, bytes binary, object callback):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_message_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1027, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 1027, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1027, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.got(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_v_self), ((PyObject*)__pyx_t_1), __pyx_t_2, 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1023
 *         return callback(result_binary)
 * 
 *     cpdef _on_receive_result(self, bytes binary, object callback):             # <<<<<<<<<<<<<<
 *         cdef object message
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.Communicator._on_receive_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_message);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_47_on_receive_result(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_47_on_receive_result(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_binary = 0;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_on_receive_result (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_binary,&__pyx_n_s_callback,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_binary)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_on_receive_result", 1, 2, 2, 1); __PYX_ERR(0, 1023, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_on_receive_result") < 0)) __PYX_ERR(0, 1023, __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_binary = ((PyObject*)values[0]);
    __pyx_v_callback = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_on_receive_result", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1023, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_binary), (&PyBytes_Type), 1, "binary", 1))) __PYX_ERR(0, 1023, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_46_on_receive_result(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_binary, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_46_on_receive_result(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_on_receive_result", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_result(__pyx_v_self, __pyx_v_binary, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1023, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1029
 *         self.got(message.message_id, message.result)
 * 
 *     cpdef _on_receive_error(self, bytes binary, object callback):             # <<<<<<<<<<<<<<
 *         cdef object message
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_49_on_receive_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_error(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, CYTHON_UNUSED PyObject *__pyx_v_callback, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_message = 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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("_on_receive_error", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1029, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_49_on_receive_error)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && 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);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_binary, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1029, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_binary, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1029, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1029, __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_binary);
          __Pyx_GIVEREF(__pyx_v_binary);
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_binary);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_callback);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1029, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":1032
 *         cdef object message
 * 
 *         message = unpack_error_message(binary)             # <<<<<<<<<<<<<<
 *         self.err(message.message_id, message.error_type, message.error, message.traceback)
 * 
 */
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_unpack_error_message(__pyx_v_binary, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1032, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_message = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1033
 * 
 *         message = unpack_error_message(binary)
 *         self.err(message.message_id, message.error_type, message.error, message.traceback)             # <<<<<<<<<<<<<<
 * 
 *     cpdef on_receive(self, bytes binary, object callback=None):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_message_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1033, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 1033, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_error_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1033, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_error); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1033, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_message, __pyx_n_s_traceback); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1033, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.err(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_v_self), ((PyObject*)__pyx_t_1), __pyx_t_2, __pyx_t_3, __pyx_t_6, 0);
  __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_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1029
 *         self.got(message.message_id, message.result)
 * 
 *     cpdef _on_receive_error(self, bytes binary, object callback):             # <<<<<<<<<<<<<<
 *         cdef object message
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.Communicator._on_receive_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_message);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_49_on_receive_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_49_on_receive_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_binary = 0;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_on_receive_error (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_binary,&__pyx_n_s_callback,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_binary)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_on_receive_error", 1, 2, 2, 1); __PYX_ERR(0, 1029, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_on_receive_error") < 0)) __PYX_ERR(0, 1029, __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_binary = ((PyObject*)values[0]);
    __pyx_v_callback = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_on_receive_error", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1029, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_binary), (&PyBytes_Type), 1, "binary", 1))) __PYX_ERR(0, 1029, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_48_on_receive_error(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_binary, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_48_on_receive_error(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_on_receive_error", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_error(__pyx_v_self, __pyx_v_binary, __pyx_v_callback, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1029, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator._on_receive_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1035
 *         self.err(message.message_id, message.error_type, message.error, message.traceback)
 * 
 *     cpdef on_receive(self, bytes binary, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef int message_type
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_51on_receive(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator_on_receive(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_on_receive *__pyx_optional_args) {
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  int __pyx_v_message_type;
  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;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("on_receive", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_callback = __pyx_optional_args->callback;
    }
  }
  __Pyx_INCREF(__pyx_v_callback);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1035, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_51on_receive)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && 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);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_binary, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1035, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_binary, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1035, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1035, __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_binary);
          __Pyx_GIVEREF(__pyx_v_binary);
          PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_binary);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_callback);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1035, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":1038
 *         cdef int message_type
 * 
 *         if callback is None:             # <<<<<<<<<<<<<<
 *             callback = self.pipe.put
 * 
 */
  __pyx_t_7 = (__pyx_v_callback == Py_None);
  __pyx_t_8 = (__pyx_t_7 != 0);
  if (__pyx_t_8) {

    /* "mars/actors/pool/gevent_pool.pyx":1039
 * 
 *         if callback is None:
 *             callback = self.pipe.put             # <<<<<<<<<<<<<<
 * 
 *         message_type = unpack_message_type_value(binary)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pipe, __pyx_n_s_put); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1039, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_callback, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1038
 *         cdef int message_type
 * 
 *         if callback is None:             # <<<<<<<<<<<<<<
 *             callback = self.pipe.put
 * 
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1041
 *             callback = self.pipe.put
 * 
 *         message_type = unpack_message_type_value(binary)             # <<<<<<<<<<<<<<
 *         return self._handlers[message_type](binary, callback)
 * 
 */
  __pyx_v_message_type = __pyx_f_4mars_6actors_4pool_8messages_unpack_message_type_value(__pyx_v_binary, 0);

  /* "mars/actors/pool/gevent_pool.pyx":1042
 * 
 *         message_type = unpack_message_type_value(binary)
 *         return self._handlers[message_type](binary, callback)             # <<<<<<<<<<<<<<
 * 
 *     def run(self):
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_self->_handlers == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1042, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_message_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1042, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_self->_handlers, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1042, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && 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_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_binary, __pyx_v_callback};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1042, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_binary, __pyx_v_callback};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1042, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1042, __pyx_L1_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_binary);
    __Pyx_GIVEREF(__pyx_v_binary);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_binary);
    __Pyx_INCREF(__pyx_v_callback);
    __Pyx_GIVEREF(__pyx_v_callback);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_callback);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1042, __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_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1035
 *         self.err(message.message_id, message.error_type, message.error, message.traceback)
 * 
 *     cpdef on_receive(self, bytes binary, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef int message_type
 * 
 */

  /* 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_6);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.on_receive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_callback);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_51on_receive(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_51on_receive(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_binary = 0;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("on_receive (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_binary,&__pyx_n_s_callback,0};
    PyObject* values[2] = {0,0};
    values[1] = ((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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_binary)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "on_receive") < 0)) __PYX_ERR(0, 1035, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_binary = ((PyObject*)values[0]);
    __pyx_v_callback = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("on_receive", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1035, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.on_receive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_binary), (&PyBytes_Type), 1, "binary", 1))) __PYX_ERR(0, 1035, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_50on_receive(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), __pyx_v_binary, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_50on_receive(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_binary, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_on_receive __pyx_t_2;
  __Pyx_RefNannySetupContext("on_receive", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 1;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Communicator->on_receive(__pyx_v_self, __pyx_v_binary, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1035, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.on_receive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1044
 *         return self._handlers[message_type](binary, callback)
 * 
 *     def run(self):             # <<<<<<<<<<<<<<
 *         cdef bytes message
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_53run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_53run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("run (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_52run(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_52run(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self) {
  PyObject *__pyx_v_message = 0;
  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_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("run", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1047
 *         cdef bytes message
 * 
 *         self.running.clear()             # <<<<<<<<<<<<<<
 *         if self.pipe is not None:
 *             while True:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->running, __pyx_n_s_clear); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1047, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1047, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1048
 * 
 *         self.running.clear()
 *         if self.pipe is not None:             # <<<<<<<<<<<<<<
 *             while True:
 *                 message = self.pipe.get()
 */
  __pyx_t_4 = (__pyx_v_self->pipe != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "mars/actors/pool/gevent_pool.pyx":1049
 *         self.running.clear()
 *         if self.pipe is not None:
 *             while True:             # <<<<<<<<<<<<<<
 *                 message = self.pipe.get()
 *                 gevent.spawn(self.on_receive, message)
 */
    while (1) {

      /* "mars/actors/pool/gevent_pool.pyx":1050
 *         if self.pipe is not None:
 *             while True:
 *                 message = self.pipe.get()             # <<<<<<<<<<<<<<
 *                 gevent.spawn(self.on_receive, message)
 * 
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->pipe, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1050, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1050, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 1050, __pyx_L1_error)
      __Pyx_XDECREF_SET(__pyx_v_message, ((PyObject*)__pyx_t_1));
      __pyx_t_1 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":1051
 *             while True:
 *                 message = self.pipe.get()
 *                 gevent.spawn(self.on_receive, message)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1051, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_spawn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1051, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1051, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_UNPACK_METHODS && 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);
          __pyx_t_7 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_2, __pyx_v_message};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1051, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_2, __pyx_v_message};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1051, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else
      #endif
      {
        __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1051, __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_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_2);
        __Pyx_INCREF(__pyx_v_message);
        __Pyx_GIVEREF(__pyx_v_message);
        PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_message);
        __pyx_t_2 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1051, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }

    /* "mars/actors/pool/gevent_pool.pyx":1048
 * 
 *         self.running.clear()
 *         if self.pipe is not None:             # <<<<<<<<<<<<<<
 *             while True:
 *                 message = self.pipe.get()
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1044
 *         return self._handlers[message_type](binary, callback)
 * 
 *     def run(self):             # <<<<<<<<<<<<<<
 *         cdef bytes message
 * 
 */

  /* 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_8);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.run", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_message);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":600
 *     """
 * 
 *     cdef public int index             # <<<<<<<<<<<<<<
 *     cdef public Distributor distributor
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_5index_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_5index_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_5index___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_5index___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 600, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.index.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_5index_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_5index_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_5index_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_5index_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__set__", 0);
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 600, __pyx_L1_error)
  __pyx_v_self->index = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.index.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":601
 * 
 *     cdef public int index
 *     cdef public Distributor distributor             # <<<<<<<<<<<<<<
 * 
 *     cdef object pool
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->distributor));
  __pyx_r = ((PyObject *)__pyx_v_self->distributor);
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_4mars_6actors_11distributor_Distributor))))) __PYX_ERR(0, 601, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->distributor);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->distributor));
  __pyx_v_self->distributor = ((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.distributor.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor_4__del__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->distributor);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->distributor));
  __pyx_v_self->distributor = ((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)Py_None);

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

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_55__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_55__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_54__reduce_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_54__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self._handlers, self.async_results, self.cluster_info, self.distributor, self.index, self.pipe, self.pool, self.remote_handler, self.running)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->index); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(9); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->_handlers);
  __Pyx_GIVEREF(__pyx_v_self->_handlers);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->_handlers);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.async_results);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.async_results);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->__pyx_base.async_results);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->cluster_info));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->cluster_info));
  PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_self->cluster_info));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->distributor));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->distributor));
  PyTuple_SET_ITEM(__pyx_t_2, 3, ((PyObject *)__pyx_v_self->distributor));
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->pipe);
  __Pyx_GIVEREF(__pyx_v_self->pipe);
  PyTuple_SET_ITEM(__pyx_t_2, 5, __pyx_v_self->pipe);
  __Pyx_INCREF(__pyx_v_self->pool);
  __Pyx_GIVEREF(__pyx_v_self->pool);
  PyTuple_SET_ITEM(__pyx_t_2, 6, __pyx_v_self->pool);
  __Pyx_INCREF(__pyx_v_self->remote_handler);
  __Pyx_GIVEREF(__pyx_v_self->remote_handler);
  PyTuple_SET_ITEM(__pyx_t_2, 7, __pyx_v_self->remote_handler);
  __Pyx_INCREF(__pyx_v_self->running);
  __Pyx_GIVEREF(__pyx_v_self->running);
  PyTuple_SET_ITEM(__pyx_t_2, 8, __pyx_v_self->running);
  __pyx_t_1 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self._handlers, self.async_results, self.cluster_info, self.distributor, self.index, self.pipe, self.pool, self.remote_handler, self.running)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_2 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v__dict = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "(tree fragment)":7
 *     state = (self._handlers, self.async_results, self.cluster_info, self.distributor, self.index, self.pipe, self.pool, self.remote_handler, self.running)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_3 = (__pyx_v__dict != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__dict);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self._handlers is not None or self.async_results is not None or self.cluster_info is not None or self.distributor is not None or self.pipe is not None or self.pool is not None or self.remote_handler is not None or self.running is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self._handlers, self.async_results, self.cluster_info, self.distributor, self.index, self.pipe, self.pool, self.remote_handler, self.running)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self._handlers is not None or self.async_results is not None or self.cluster_info is not None or self.distributor is not None or self.pipe is not None or self.pool is not None or self.remote_handler is not None or self.running is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Communicator, (type(self), 0xd3b2268, None), state
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_self->_handlers != ((PyObject*)Py_None));
    __pyx_t_5 = (__pyx_t_3 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->__pyx_base.async_results != ((PyObject*)Py_None));
    __pyx_t_3 = (__pyx_t_5 != 0);
    if (!__pyx_t_3) {
    } else {
      __pyx_t_4 = __pyx_t_3;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_3 = (((PyObject *)__pyx_v_self->cluster_info) != Py_None);
    __pyx_t_5 = (__pyx_t_3 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (((PyObject *)__pyx_v_self->distributor) != Py_None);
    __pyx_t_3 = (__pyx_t_5 != 0);
    if (!__pyx_t_3) {
    } else {
      __pyx_t_4 = __pyx_t_3;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_3 = (__pyx_v_self->pipe != Py_None);
    __pyx_t_5 = (__pyx_t_3 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->pool != Py_None);
    __pyx_t_3 = (__pyx_t_5 != 0);
    if (!__pyx_t_3) {
    } else {
      __pyx_t_4 = __pyx_t_3;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_3 = (__pyx_v_self->remote_handler != Py_None);
    __pyx_t_5 = (__pyx_t_3 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->running != Py_None);
    __pyx_t_3 = (__pyx_t_5 != 0);
    __pyx_t_4 = __pyx_t_3;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_4;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._handlers is not None or self.async_results is not None or self.cluster_info is not None or self.distributor is not None or self.pipe is not None or self.pool is not None or self.remote_handler is not None or self.running is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Communicator, (type(self), 0xd3b2268, None), state
 *     else:
 */
  __pyx_t_4 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":13
 *         use_setstate = self._handlers is not None or self.async_results is not None or self.cluster_info is not None or self.distributor is not None or self.pipe is not None or self.pool is not None or self.remote_handler is not None or self.running is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Communicator, (type(self), 0xd3b2268, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Communicator, (type(self), 0xd3b2268, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle_Communicator); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_221979240);
    __Pyx_GIVEREF(__pyx_int_221979240);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_221979240);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._handlers is not None or self.async_results is not None or self.cluster_info is not None or self.distributor is not None or self.pipe is not None or self.pool is not None or self.remote_handler is not None or self.running is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Communicator, (type(self), 0xd3b2268, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Communicator, (type(self), 0xd3b2268, None), state
 *     else:
 *         return __pyx_unpickle_Communicator, (type(self), 0xd3b2268, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Communicator__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_Communicator); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_221979240);
    __Pyx_GIVEREF(__pyx_int_221979240);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_221979240);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_6 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Communicator, (type(self), 0xd3b2268, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Communicator__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_57__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_57__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_56__setstate_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12Communicator_56__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Communicator, (type(self), 0xd3b2268, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Communicator__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_Communicator__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Communicator, (type(self), 0xd3b2268, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Communicator__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Communicator.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1071
 *     cdef dict handlers
 * 
 *     def __init__(self, ClusterInfo cluster_info, list pipes, Distributor distributor=None, parallel=None):             # <<<<<<<<<<<<<<
 *         super(Dispatcher, self).__init__()
 *         AsyncHandler.__init__(self)
 */

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *__pyx_v_cluster_info = 0;
  PyObject *__pyx_v_pipes = 0;
  struct __pyx_obj_4mars_6actors_11distributor_Distributor *__pyx_v_distributor = 0;
  PyObject *__pyx_v_parallel = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cluster_info,&__pyx_n_s_pipes,&__pyx_n_s_distributor,&__pyx_n_s_parallel,0};
    PyObject* values[4] = {0,0,0,0};
    values[2] = (PyObject *)((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)Py_None);
    values[3] = ((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);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cluster_info)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pipes)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, 1); __PYX_ERR(0, 1071, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_distributor);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_parallel);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1071, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_cluster_info = ((struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *)values[0]);
    __pyx_v_pipes = ((PyObject*)values[1]);
    __pyx_v_distributor = ((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)values[2]);
    __pyx_v_parallel = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1071, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cluster_info), __pyx_ptype_4mars_6actors_7cluster_ClusterInfo, 1, "cluster_info", 0))) __PYX_ERR(0, 1071, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pipes), (&PyList_Type), 1, "pipes", 1))) __PYX_ERR(0, 1071, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distributor), __pyx_ptype_4mars_6actors_11distributor_Distributor, 1, "distributor", 0))) __PYX_ERR(0, 1071, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher___init__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self), __pyx_v_cluster_info, __pyx_v_pipes, __pyx_v_distributor, __pyx_v_parallel);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *__pyx_v_cluster_info, PyObject *__pyx_v_pipes, struct __pyx_obj_4mars_6actors_11distributor_Distributor *__pyx_v_distributor, PyObject *__pyx_v_parallel) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1072
 * 
 *     def __init__(self, ClusterInfo cluster_info, list pipes, Distributor distributor=None, parallel=None):
 *         super(Dispatcher, self).__init__()             # <<<<<<<<<<<<<<
 *         AsyncHandler.__init__(self)
 * 
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1072, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_Dispatcher));
  __Pyx_GIVEREF(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_Dispatcher));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_Dispatcher));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1072, __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_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1072, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1072, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1073
 *     def __init__(self, ClusterInfo cluster_info, list pipes, Distributor distributor=None, parallel=None):
 *         super(Dispatcher, self).__init__()
 *         AsyncHandler.__init__(self)             # <<<<<<<<<<<<<<
 * 
 *         self.cluster_info = cluster_info
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_AsyncHandler), __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1073, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_v_self)) : __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self));
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1073, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1075
 *         AsyncHandler.__init__(self)
 * 
 *         self.cluster_info = cluster_info             # <<<<<<<<<<<<<<
 *         self.index = -1
 *         self.pipes = pipes  # type: list
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_cluster_info));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_cluster_info));
  __Pyx_GOTREF(__pyx_v_self->cluster_info);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->cluster_info));
  __pyx_v_self->cluster_info = __pyx_v_cluster_info;

  /* "mars/actors/pool/gevent_pool.pyx":1076
 * 
 *         self.cluster_info = cluster_info
 *         self.index = -1             # <<<<<<<<<<<<<<
 *         self.pipes = pipes  # type: list
 *         self.pipe_checkers = []
 */
  __pyx_v_self->index = -1;

  /* "mars/actors/pool/gevent_pool.pyx":1077
 *         self.cluster_info = cluster_info
 *         self.index = -1
 *         self.pipes = pipes  # type: list             # <<<<<<<<<<<<<<
 *         self.pipe_checkers = []
 *         self.checker_group = None
 */
  __Pyx_INCREF(__pyx_v_pipes);
  __Pyx_GIVEREF(__pyx_v_pipes);
  __Pyx_GOTREF(__pyx_v_self->pipes);
  __Pyx_DECREF(__pyx_v_self->pipes);
  __pyx_v_self->pipes = __pyx_v_pipes;

  /* "mars/actors/pool/gevent_pool.pyx":1078
 *         self.index = -1
 *         self.pipes = pipes  # type: list
 *         self.pipe_checkers = []             # <<<<<<<<<<<<<<
 *         self.checker_group = None
 *         if distributor is None:
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1078, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->pipe_checkers);
  __Pyx_DECREF(__pyx_v_self->pipe_checkers);
  __pyx_v_self->pipe_checkers = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1079
 *         self.pipes = pipes  # type: list
 *         self.pipe_checkers = []
 *         self.checker_group = None             # <<<<<<<<<<<<<<
 *         if distributor is None:
 *             self.distributor = Distributor(self.cluster_info.n_process)
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->checker_group);
  __Pyx_DECREF(__pyx_v_self->checker_group);
  __pyx_v_self->checker_group = Py_None;

  /* "mars/actors/pool/gevent_pool.pyx":1080
 *         self.pipe_checkers = []
 *         self.checker_group = None
 *         if distributor is None:             # <<<<<<<<<<<<<<
 *             self.distributor = Distributor(self.cluster_info.n_process)
 *         else:
 */
  __pyx_t_4 = (((PyObject *)__pyx_v_distributor) == Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "mars/actors/pool/gevent_pool.pyx":1081
 *         self.checker_group = None
 *         if distributor is None:
 *             self.distributor = Distributor(self.cluster_info.n_process)             # <<<<<<<<<<<<<<
 *         else:
 *             self.distributor = distributor
 */
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->cluster_info->n_process); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1081, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4mars_6actors_11distributor_Distributor), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1081, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->distributor);
    __Pyx_DECREF(__pyx_v_self->distributor);
    __pyx_v_self->distributor = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1080
 *         self.pipe_checkers = []
 *         self.checker_group = None
 *         if distributor is None:             # <<<<<<<<<<<<<<
 *             self.distributor = Distributor(self.cluster_info.n_process)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "mars/actors/pool/gevent_pool.pyx":1083
 *             self.distributor = Distributor(self.cluster_info.n_process)
 *         else:
 *             self.distributor = distributor             # <<<<<<<<<<<<<<
 *         self.remote_handler = ActorRemoteHelper(parallel=parallel)
 * 
 */
  /*else*/ {
    __Pyx_INCREF(((PyObject *)__pyx_v_distributor));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_distributor));
    __Pyx_GOTREF(__pyx_v_self->distributor);
    __Pyx_DECREF(__pyx_v_self->distributor);
    __pyx_v_self->distributor = ((PyObject *)__pyx_v_distributor);
  }
  __pyx_L3:;

  /* "mars/actors/pool/gevent_pool.pyx":1084
 *         else:
 *             self.distributor = distributor
 *         self.remote_handler = ActorRemoteHelper(parallel=parallel)             # <<<<<<<<<<<<<<
 * 
 *         self.handlers = {
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1084, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_parallel, __pyx_v_parallel) < 0) __PYX_ERR(0, 1084, __pyx_L1_error)
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper), __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1084, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->remote_handler);
  __Pyx_DECREF(__pyx_v_self->remote_handler);
  __pyx_v_self->remote_handler = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1087
 * 
 *         self.handlers = {
 *             MessageType.send_all: self._on_receive_action,             # <<<<<<<<<<<<<<
 *             MessageType.tell_all: self._on_receive_action,
 *             MessageType.create_actor: self._on_receive_action,
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1087, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(__pyx_e_4mars_6actors_4pool_8messages_send_all); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1087, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_action); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1087, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_t_3) < 0) __PYX_ERR(0, 1087, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1088
 *         self.handlers = {
 *             MessageType.send_all: self._on_receive_action,
 *             MessageType.tell_all: self._on_receive_action,             # <<<<<<<<<<<<<<
 *             MessageType.create_actor: self._on_receive_action,
 *             MessageType.destroy_actor: self._on_receive_action,
 */
  __pyx_t_3 = __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(__pyx_e_4mars_6actors_4pool_8messages_tell_all); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1088, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_action); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1088, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_2) < 0) __PYX_ERR(0, 1087, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1089
 *             MessageType.send_all: self._on_receive_action,
 *             MessageType.tell_all: self._on_receive_action,
 *             MessageType.create_actor: self._on_receive_action,             # <<<<<<<<<<<<<<
 *             MessageType.destroy_actor: self._on_receive_action,
 *             MessageType.has_actor: self._on_receive_action,
 */
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(__pyx_e_4mars_6actors_4pool_8messages_create_actor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1089, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_action); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1089, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_t_3) < 0) __PYX_ERR(0, 1087, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1090
 *             MessageType.tell_all: self._on_receive_action,
 *             MessageType.create_actor: self._on_receive_action,
 *             MessageType.destroy_actor: self._on_receive_action,             # <<<<<<<<<<<<<<
 *             MessageType.has_actor: self._on_receive_action,
 *             MessageType.result: self._on_receive_result,
 */
  __pyx_t_3 = __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(__pyx_e_4mars_6actors_4pool_8messages_destroy_actor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1090, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_action); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1090, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_2) < 0) __PYX_ERR(0, 1087, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1091
 *             MessageType.create_actor: self._on_receive_action,
 *             MessageType.destroy_actor: self._on_receive_action,
 *             MessageType.has_actor: self._on_receive_action,             # <<<<<<<<<<<<<<
 *             MessageType.result: self._on_receive_result,
 *             MessageType.error: self._on_receive_error,
 */
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(__pyx_e_4mars_6actors_4pool_8messages_has_actor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1091, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_action); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1091, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_t_3) < 0) __PYX_ERR(0, 1087, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1092
 *             MessageType.destroy_actor: self._on_receive_action,
 *             MessageType.has_actor: self._on_receive_action,
 *             MessageType.result: self._on_receive_result,             # <<<<<<<<<<<<<<
 *             MessageType.error: self._on_receive_error,
 *         }
 */
  __pyx_t_3 = __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(__pyx_e_4mars_6actors_4pool_8messages_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1092, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1092, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_3, __pyx_t_2) < 0) __PYX_ERR(0, 1087, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1093
 *             MessageType.has_actor: self._on_receive_action,
 *             MessageType.result: self._on_receive_result,
 *             MessageType.error: self._on_receive_error,             # <<<<<<<<<<<<<<
 *         }
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(__pyx_e_4mars_6actors_4pool_8messages_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1093, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_error); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1093, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_t_3) < 0) __PYX_ERR(0, 1087, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1086
 *         self.remote_handler = ActorRemoteHelper(parallel=parallel)
 * 
 *         self.handlers = {             # <<<<<<<<<<<<<<
 *             MessageType.send_all: self._on_receive_action,
 *             MessageType.tell_all: self._on_receive_action,
 */
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->handlers);
  __Pyx_DECREF(__pyx_v_self->handlers);
  __pyx_v_self->handlers = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1071
 *     cdef dict handlers
 * 
 *     def __init__(self, ClusterInfo cluster_info, list pipes, Distributor distributor=None, parallel=None):             # <<<<<<<<<<<<<<
 *         super(Dispatcher, self).__init__()
 *         AsyncHandler.__init__(self)
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1096
 *         }
 * 
 *     cdef inline bint _is_remote(self, ActorRef actor_ref):             # <<<<<<<<<<<<<<
 *         if actor_ref.address is None or actor_ref.address == self.cluster_info.address:
 *             return False
 */

static CYTHON_INLINE int __pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__is_remote(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("_is_remote", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1097
 * 
 *     cdef inline bint _is_remote(self, ActorRef actor_ref):
 *         if actor_ref.address is None or actor_ref.address == self.cluster_info.address:             # <<<<<<<<<<<<<<
 *             return False
 *         return True
 */
  __pyx_t_2 = (__pyx_v_actor_ref->address == ((PyObject*)Py_None));
  __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_3 = (__Pyx_PyString_Equals(__pyx_v_actor_ref->address, __pyx_v_self->cluster_info->address, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 1097, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_3 != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "mars/actors/pool/gevent_pool.pyx":1098
 *     cdef inline bint _is_remote(self, ActorRef actor_ref):
 *         if actor_ref.address is None or actor_ref.address == self.cluster_info.address:
 *             return False             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":1097
 * 
 *     cdef inline bint _is_remote(self, ActorRef actor_ref):
 *         if actor_ref.address is None or actor_ref.address == self.cluster_info.address:             # <<<<<<<<<<<<<<
 *             return False
 *         return True
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1099
 *         if actor_ref.address is None or actor_ref.address == self.cluster_info.address:
 *             return False
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     def _send(self, ActorRef actor_ref, object message, bint wait_response=True,
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1096
 *         }
 * 
 *     cdef inline bint _is_remote(self, ActorRef actor_ref):             # <<<<<<<<<<<<<<
 *         if actor_ref.address is None or actor_ref.address == self.cluster_info.address:
 *             return False
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("mars.actors.pool.gevent_pool.Dispatcher._is_remote", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1101
 *         return True
 * 
 *     def _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         cdef int to_index
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_3_send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_3_send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_message = 0;
  int __pyx_v_wait_response;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_send (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_message,&__pyx_n_s_wait_response,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[5] = {0,0,0,0,0};

    /* "mars/actors/pool/gevent_pool.pyx":1102
 * 
 *     def _send(self, ActorRef actor_ref, object message, bint wait_response=True,
 *                       bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef int to_index
 *         cdef object func
 */
    values[4] = ((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  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_send", 0, 2, 5, 1); __PYX_ERR(0, 1101, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait_response);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_send") < 0)) __PYX_ERR(0, 1101, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    __pyx_v_message = values[1];
    if (values[2]) {
      __pyx_v_wait_response = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_wait_response == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1101, __pyx_L3_error)
    } else {

      /* "mars/actors/pool/gevent_pool.pyx":1101
 *         return True
 * 
 *     def _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         cdef int to_index
 */
      __pyx_v_wait_response = ((int)1);
    }
    if (values[3]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1102, __pyx_L3_error)
    } else {

      /* "mars/actors/pool/gevent_pool.pyx":1102
 * 
 *     def _send(self, ActorRef actor_ref, object message, bint wait_response=True,
 *                       bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef int to_index
 *         cdef object func
 */
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_send", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1101, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher._send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 1101, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_2_send(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_message, __pyx_v_wait_response, __pyx_v_wait, __pyx_v_callback);

  /* "mars/actors/pool/gevent_pool.pyx":1101
 *         return True
 * 
 *     def _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         cdef int to_index
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1133
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(*messages)
 *             self.future(message_id, future, callback=callback)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_5_send_1check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_10Dispatcher_5_send_1check = {"check", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_5_send_1check, METH_NOARGS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_5_send_1check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_5_send_check(__pyx_self);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_5_send_check(PyObject *__pyx_self) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send *__pyx_outer_scope;
  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;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future __pyx_t_5;
  __Pyx_RefNannySetupContext("check", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":1134
 * 
 *         def check():
 *             self.pipes[to_index].put(*messages)             # <<<<<<<<<<<<<<
 *             self.future(message_id, future, callback=callback)
 * 
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1134, __pyx_L1_error) }
  if (unlikely(__pyx_cur_scope->__pyx_v_self->pipes == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1134, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_cur_scope->__pyx_v_self->pipes, __pyx_cur_scope->__pyx_v_to_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_put); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_cur_scope->__pyx_v_messages)) { __Pyx_RaiseClosureNameError("messages"); __PYX_ERR(0, 1134, __pyx_L1_error) }
  __pyx_t_1 = PySequence_Tuple(__pyx_cur_scope->__pyx_v_messages); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __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;

  /* "mars/actors/pool/gevent_pool.pyx":1135
 *         def check():
 *             self.pipes[to_index].put(*messages)
 *             self.future(message_id, future, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *         gevent.spawn(check)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1135, __pyx_L1_error) }
  if (unlikely(!__pyx_cur_scope->__pyx_v_message_id)) { __Pyx_RaiseClosureNameError("message_id"); __PYX_ERR(0, 1135, __pyx_L1_error) }
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_message_id;
  __Pyx_INCREF(__pyx_t_3);
  if (unlikely(!__pyx_cur_scope->__pyx_v_future)) { __Pyx_RaiseClosureNameError("future"); __PYX_ERR(0, 1135, __pyx_L1_error) }
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_future;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(!__pyx_cur_scope->__pyx_v_callback)) { __Pyx_RaiseClosureNameError("callback"); __PYX_ERR(0, 1135, __pyx_L1_error) }
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_callback;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_5.__pyx_n = 1;
  __pyx_t_5.callback = __pyx_t_2;
  __pyx_t_4 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.future(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_3), __pyx_t_1, 0, &__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1135, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1133
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(*messages)
 *             self.future(message_id, future, 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_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher._send.check", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1101
 *         return True
 * 
 *     def _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         cdef int to_index
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_2_send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait_response, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send *__pyx_cur_scope;
  PyObject *__pyx_v_msg = 0;
  PyObject *__pyx_v_check = 0;
  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_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;
  PyObject *__pyx_t_13 = NULL;
  __Pyx_RefNannySetupContext("_send", 0);
  __pyx_cur_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send *)__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send(__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1101, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __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);

  /* "mars/actors/pool/gevent_pool.pyx":1110
 *         cdef object future
 * 
 *         if self._is_remote(actor_ref):             # <<<<<<<<<<<<<<
 *             if wait_response:
 *                 return self.remote_handler.send(actor_ref, message, wait=wait, callback=callback)
 */
  __pyx_t_1 = (__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__is_remote(__pyx_cur_scope->__pyx_v_self, __pyx_v_actor_ref) != 0);
  if (__pyx_t_1) {

    /* "mars/actors/pool/gevent_pool.pyx":1111
 * 
 *         if self._is_remote(actor_ref):
 *             if wait_response:             # <<<<<<<<<<<<<<
 *                 return self.remote_handler.send(actor_ref, message, wait=wait, callback=callback)
 *             else:
 */
    __pyx_t_1 = (__pyx_v_wait_response != 0);
    if (__pyx_t_1) {

      /* "mars/actors/pool/gevent_pool.pyx":1112
 *         if self._is_remote(actor_ref):
 *             if wait_response:
 *                 return self.remote_handler.send(actor_ref, message, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 *             else:
 *                 return self.remote_handler.tell(actor_ref, message, wait=wait, callback=callback)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->remote_handler, __pyx_n_s_send); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_actor_ref));
      __Pyx_INCREF(__pyx_v_message);
      __Pyx_GIVEREF(__pyx_v_message);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_message);
      __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_wait, __pyx_t_5) < 0) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_callback, __pyx_cur_scope->__pyx_v_callback) < 0) __PYX_ERR(0, 1112, __pyx_L1_error)
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_5;
      __pyx_t_5 = 0;
      goto __pyx_L0;

      /* "mars/actors/pool/gevent_pool.pyx":1111
 * 
 *         if self._is_remote(actor_ref):
 *             if wait_response:             # <<<<<<<<<<<<<<
 *                 return self.remote_handler.send(actor_ref, message, wait=wait, callback=callback)
 *             else:
 */
    }

    /* "mars/actors/pool/gevent_pool.pyx":1114
 *                 return self.remote_handler.send(actor_ref, message, wait=wait, callback=callback)
 *             else:
 *                 return self.remote_handler.tell(actor_ref, message, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *         to_index = self.distributor.distribute(actor_ref.uid)
 */
    /*else*/ {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->remote_handler, __pyx_n_s_tell); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1114, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1114, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_actor_ref));
      __Pyx_INCREF(__pyx_v_message);
      __Pyx_GIVEREF(__pyx_v_message);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_message);
      __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1114, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1114, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_wait, __pyx_t_2) < 0) __PYX_ERR(0, 1114, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_callback, __pyx_cur_scope->__pyx_v_callback) < 0) __PYX_ERR(0, 1114, __pyx_L1_error)
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1114, __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_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }

    /* "mars/actors/pool/gevent_pool.pyx":1110
 *         cdef object future
 * 
 *         if self._is_remote(actor_ref):             # <<<<<<<<<<<<<<
 *             if wait_response:
 *                 return self.remote_handler.send(actor_ref, message, wait=wait, callback=callback)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1116
 *                 return self.remote_handler.tell(actor_ref, message, wait=wait, callback=callback)
 * 
 *         to_index = self.distributor.distribute(actor_ref.uid)             # <<<<<<<<<<<<<<
 *         try:
 *             if wait_response:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->distributor, __pyx_n_s_distribute); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_actor_ref->uid) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_actor_ref->uid);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1116, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_cur_scope->__pyx_v_to_index = __pyx_t_6;

  /* "mars/actors/pool/gevent_pool.pyx":1117
 * 
 *         to_index = self.distributor.distribute(actor_ref.uid)
 *         try:             # <<<<<<<<<<<<<<
 *             if wait_response:
 *                 msg = pack_send_message(self.index, to_index, actor_ref, message)
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
    __Pyx_XGOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_9);
    /*try:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":1118
 *         to_index = self.distributor.distribute(actor_ref.uid)
 *         try:
 *             if wait_response:             # <<<<<<<<<<<<<<
 *                 msg = pack_send_message(self.index, to_index, actor_ref, message)
 *             else:
 */
      __pyx_t_1 = (__pyx_v_wait_response != 0);
      if (__pyx_t_1) {

        /* "mars/actors/pool/gevent_pool.pyx":1119
 *         try:
 *             if wait_response:
 *                 msg = pack_send_message(self.index, to_index, actor_ref, message)             # <<<<<<<<<<<<<<
 *             else:
 *                 msg = pack_tell_message(self.index, to_index, actor_ref, message)
 */
        __pyx_t_2 = __pyx_f_4mars_6actors_4pool_8messages_pack_send_message(__pyx_cur_scope->__pyx_v_self->index, __pyx_cur_scope->__pyx_v_to_index, __pyx_v_actor_ref, __pyx_v_message, 0, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1119, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_2);
        if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 1119, __pyx_L5_error)
        __pyx_v_msg = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;

        /* "mars/actors/pool/gevent_pool.pyx":1118
 *         to_index = self.distributor.distribute(actor_ref.uid)
 *         try:
 *             if wait_response:             # <<<<<<<<<<<<<<
 *                 msg = pack_send_message(self.index, to_index, actor_ref, message)
 *             else:
 */
        goto __pyx_L11;
      }

      /* "mars/actors/pool/gevent_pool.pyx":1121
 *                 msg = pack_send_message(self.index, to_index, actor_ref, message)
 *             else:
 *                 msg = pack_tell_message(self.index, to_index, actor_ref, message)             # <<<<<<<<<<<<<<
 *             message_id, messages = msg[0], msg[1:]
 *         except (AttributeError, pickle.PickleError):
 */
      /*else*/ {
        __pyx_t_2 = __pyx_f_4mars_6actors_4pool_8messages_pack_tell_message(__pyx_cur_scope->__pyx_v_self->index, __pyx_cur_scope->__pyx_v_to_index, __pyx_v_actor_ref, __pyx_v_message, 0, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1121, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_2);
        if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 1121, __pyx_L5_error)
        __pyx_v_msg = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
      }
      __pyx_L11:;

      /* "mars/actors/pool/gevent_pool.pyx":1122
 *             else:
 *                 msg = pack_tell_message(self.index, to_index, actor_ref, message)
 *             message_id, messages = msg[0], msg[1:]             # <<<<<<<<<<<<<<
 *         except (AttributeError, pickle.PickleError):
 *             raise pickle.PicklingError('Unable to pickle message: {0}'.format(message))
 */
      if (unlikely(__pyx_v_msg == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 1122, __pyx_L5_error)
      }
      __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_msg, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1122, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 1122, __pyx_L5_error)
      if (unlikely(__pyx_v_msg == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 1122, __pyx_L5_error)
      }
      __pyx_t_3 = __Pyx_PyList_GetSlice(__pyx_v_msg, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1122, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_cur_scope->__pyx_v_message_id = ((PyObject*)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_cur_scope->__pyx_v_messages = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":1117
 * 
 *         to_index = self.distributor.distribute(actor_ref.uid)
 *         try:             # <<<<<<<<<<<<<<
 *             if wait_response:
 *                 msg = pack_send_message(self.index, to_index, actor_ref, message)
 */
    }
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L10_try_end;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1123
 *                 msg = pack_tell_message(self.index, to_index, actor_ref, message)
 *             message_id, messages = msg[0], msg[1:]
 *         except (AttributeError, pickle.PickleError):             # <<<<<<<<<<<<<<
 *             raise pickle.PicklingError('Unable to pickle message: {0}'.format(message))
 * 
 */
    __Pyx_ErrFetch(&__pyx_t_3, &__pyx_t_2, &__pyx_t_4);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pickle); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1123, __pyx_L7_except_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1123, __pyx_L7_except_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_3, __pyx_builtin_AttributeError) || __Pyx_PyErr_GivenExceptionMatches(__pyx_t_3, __pyx_t_10);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_ErrRestore(__pyx_t_3, __pyx_t_2, __pyx_t_4);
    __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_4 = 0;
    if (__pyx_t_6) {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher._send", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 1123, __pyx_L7_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_3);

      /* "mars/actors/pool/gevent_pool.pyx":1124
 *             message_id, messages = msg[0], msg[1:]
 *         except (AttributeError, pickle.PickleError):
 *             raise pickle.PicklingError('Unable to pickle message: {0}'.format(message))             # <<<<<<<<<<<<<<
 * 
 *         if wait:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pickle); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1124, __pyx_L7_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_PicklingError); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1124, __pyx_L7_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Unable_to_pickle_message_0_2, __pyx_n_s_format); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1124, __pyx_L7_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = NULL;
      if (CYTHON_UNPACK_METHODS && 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);
        }
      }
      __pyx_t_5 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_13, __pyx_v_message) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_message);
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1124, __pyx_L7_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      __pyx_t_10 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_11, __pyx_t_12, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_5);
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1124, __pyx_L7_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_Raise(__pyx_t_10, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __PYX_ERR(0, 1124, __pyx_L7_except_error)
    }
    goto __pyx_L7_except_error;
    __pyx_L7_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":1117
 * 
 *         to_index = self.distributor.distribute(actor_ref.uid)
 *         try:             # <<<<<<<<<<<<<<
 *             if wait_response:
 *                 msg = pack_send_message(self.index, to_index, actor_ref, message)
 */
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    goto __pyx_L1_error;
    __pyx_L10_try_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":1126
 *             raise pickle.PicklingError('Unable to pickle message: {0}'.format(message))
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(*messages)
 *             return self.submit(message_id)
 */
  __pyx_t_1 = (__pyx_v_wait != 0);
  if (__pyx_t_1) {

    /* "mars/actors/pool/gevent_pool.pyx":1127
 * 
 *         if wait:
 *             self.pipes[to_index].put(*messages)             # <<<<<<<<<<<<<<
 *             return self.submit(message_id)
 * 
 */
    if (unlikely(__pyx_cur_scope->__pyx_v_self->pipes == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1127, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_cur_scope->__pyx_v_self->pipes, __pyx_cur_scope->__pyx_v_to_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1127, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_put); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1127, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PySequence_Tuple(__pyx_cur_scope->__pyx_v_messages); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1127, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1127, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1128
 *         if wait:
 *             self.pipes[to_index].put(*messages)
 *             return self.submit(message_id)             # <<<<<<<<<<<<<<
 * 
 *         # return future
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __pyx_cur_scope->__pyx_v_message_id;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_3 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.submit(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_4), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1128, __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;

    /* "mars/actors/pool/gevent_pool.pyx":1126
 *             raise pickle.PicklingError('Unable to pickle message: {0}'.format(message))
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(*messages)
 *             return self.submit(message_id)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1131
 * 
 *         # return future
 *         future = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 * 
 *         def check():
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_gevent); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_event); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_AsyncResult); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_future = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1133
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(*messages)
 *             self.future(message_id, future, callback=callback)
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_10Dispatcher_5_send_1check, 0, __pyx_n_s_send_locals_check, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__28)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_check = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1137
 *             self.future(message_id, future, callback=callback)
 * 
 *         gevent.spawn(check)             # <<<<<<<<<<<<<<
 *         return future
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_gevent); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1137, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_spawn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1137, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v_check) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_check);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1137, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1138
 * 
 *         gevent.spawn(check)
 *         return future             # <<<<<<<<<<<<<<
 * 
 *     cpdef object send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_future);
  __pyx_r = __pyx_cur_scope->__pyx_v_future;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1101
 *         return True
 * 
 *     def _send(self, ActorRef actor_ref, object message, bint wait_response=True,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         cdef int to_index
 */

  /* 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_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher._send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XDECREF(__pyx_v_check);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1140
 *         return future
 * 
 *     cpdef object send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_5send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher_send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_10Dispatcher_send *__pyx_optional_args) {
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  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;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("send", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_wait = __pyx_optional_args->wait;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_callback = __pyx_optional_args->callback;
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1140, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_5send)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1140, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        __pyx_t_6 = 0;
        if (CYTHON_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[5] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 4+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1140, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[5] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 4+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1140, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(4+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1140, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_INCREF(__pyx_v_message);
          __Pyx_GIVEREF(__pyx_v_message);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_message);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_6, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1140, __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_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":1141
 * 
 *     cpdef object send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *     cpdef object tell(self, ActorRef actor_ref, object message, object delay=None,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_actor_ref));
  __Pyx_INCREF(__pyx_v_message);
  __Pyx_GIVEREF(__pyx_v_message);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_message);
  __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_wait_response, Py_True) < 0) __PYX_ERR(0, 1141, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_wait, __pyx_t_7) < 0) __PYX_ERR(0, 1141, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1141, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1141, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1140
 *         return future
 * 
 *     cpdef object send(self, ActorRef actor_ref, object message, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_5send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_5send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_message = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("send (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_message,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[4] = {0,0,0,0};
    values[3] = ((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);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("send", 0, 2, 4, 1); __PYX_ERR(0, 1140, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "send") < 0)) __PYX_ERR(0, 1140, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    __pyx_v_message = values[1];
    if (values[2]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1140, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("send", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1140, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 1140, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_4send(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_message, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_4send(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_10Dispatcher_send __pyx_t_2;
  __Pyx_RefNannySetupContext("send", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Dispatcher->send(__pyx_v_self, __pyx_v_actor_ref, __pyx_v_message, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1143
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 *     cpdef object tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         if delay is not None:
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_7tell(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher_tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_10Dispatcher_tell *__pyx_optional_args) {
  PyObject *__pyx_v_delay = ((PyObject *)Py_None);

  /* "mars/actors/pool/gevent_pool.pyx":1144
 * 
 *     cpdef object tell(self, ActorRef actor_ref, object message, object delay=None,
 *                       bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         if delay is not None:
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 */
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  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;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  __Pyx_RefNannySetupContext("tell", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_delay = __pyx_optional_args->delay;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_wait = __pyx_optional_args->wait;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_callback = __pyx_optional_args->callback;
        }
      }
    }
  }

  /* "mars/actors/pool/gevent_pool.pyx":1143
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 *     cpdef object tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         if delay is not None:
 */
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tell); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1143, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_7tell)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1143, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        __pyx_t_6 = 0;
        if (CYTHON_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[6] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_v_delay, __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1143, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[6] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_v_message, __pyx_v_delay, __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 5+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1143, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(5+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1143, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_INCREF(__pyx_v_message);
          __Pyx_GIVEREF(__pyx_v_message);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_message);
          __Pyx_INCREF(__pyx_v_delay);
          __Pyx_GIVEREF(__pyx_v_delay);
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_delay);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_7, 4+__pyx_t_6, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1143, __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_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":1145
 *     cpdef object tell(self, ActorRef actor_ref, object message, object delay=None,
 *                       bint wait=True, object callback=None):
 *         if delay is not None:             # <<<<<<<<<<<<<<
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 *                                wait=wait, callback=callback)
 */
  __pyx_t_8 = (__pyx_v_delay != Py_None);
  __pyx_t_9 = (__pyx_t_8 != 0);
  if (__pyx_t_9) {

    /* "mars/actors/pool/gevent_pool.pyx":1146
 *                       bint wait=True, object callback=None):
 *         if delay is not None:
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,             # <<<<<<<<<<<<<<
 *                                wait=wait, callback=callback)
 *             return
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_spawn_later); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_delay);
    __Pyx_GIVEREF(__pyx_v_delay);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_delay);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
    PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_v_actor_ref));
    __Pyx_INCREF(__pyx_v_message);
    __Pyx_GIVEREF(__pyx_v_message);
    PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_message);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_wait_response, Py_False) < 0) __PYX_ERR(0, 1146, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":1147
 *         if delay is not None:
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 *                                wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_wait, __pyx_t_7) < 0) __PYX_ERR(0, 1146, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1146, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":1146
 *                       bint wait=True, object callback=None):
 *         if delay is not None:
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,             # <<<<<<<<<<<<<<
 *                                wait=wait, callback=callback)
 *             return
 */
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __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;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1148
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 *                                wait=wait, callback=callback)
 *             return             # <<<<<<<<<<<<<<
 * 
 *         return self._send(actor_ref, message, wait_response=False, wait=wait, callback=callback)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":1145
 *     cpdef object tell(self, ActorRef actor_ref, object message, object delay=None,
 *                       bint wait=True, object callback=None):
 *         if delay is not None:             # <<<<<<<<<<<<<<
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 *                                wait=wait, callback=callback)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1150
 *             return
 * 
 *         return self._send(actor_ref, message, wait_response=False, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *     def create_actor(self, str address, object uid, object actor_cls, *args, **kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_send_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_actor_ref));
  __Pyx_INCREF(__pyx_v_message);
  __Pyx_GIVEREF(__pyx_v_message);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_message);
  __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_wait_response, Py_False) < 0) __PYX_ERR(0, 1150, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_wait, __pyx_t_2) < 0) __PYX_ERR(0, 1150, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1150, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __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;

  /* "mars/actors/pool/gevent_pool.pyx":1143
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 *     cpdef object tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         if delay is not None:
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.tell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_7tell(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_7tell(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_message = 0;
  PyObject *__pyx_v_delay = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tell (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_message,&__pyx_n_s_delay,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[5] = {0,0,0,0,0};
    values[2] = ((PyObject *)Py_None);

    /* "mars/actors/pool/gevent_pool.pyx":1144
 * 
 *     cpdef object tell(self, ActorRef actor_ref, object message, object delay=None,
 *                       bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         if delay is not None:
 *             gevent.spawn_later(delay, self._send, actor_ref, message, wait_response=False,
 */
    values[4] = ((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  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_message)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tell", 0, 2, 5, 1); __PYX_ERR(0, 1143, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_delay);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tell") < 0)) __PYX_ERR(0, 1143, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    __pyx_v_message = values[1];
    __pyx_v_delay = values[2];
    if (values[3]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1144, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("tell", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1143, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.tell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 1143, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_6tell(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_message, __pyx_v_delay, __pyx_v_wait, __pyx_v_callback);

  /* "mars/actors/pool/gevent_pool.pyx":1143
 *         return self._send(actor_ref, message, wait_response=True, wait=wait, callback=callback)
 * 
 *     cpdef object tell(self, ActorRef actor_ref, object message, object delay=None,             # <<<<<<<<<<<<<<
 *                       bint wait=True, object callback=None):
 *         if delay is not None:
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_6tell(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, PyObject *__pyx_v_message, PyObject *__pyx_v_delay, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_10Dispatcher_tell __pyx_t_2;
  __Pyx_RefNannySetupContext("tell", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.delay = __pyx_v_delay;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Dispatcher->tell(__pyx_v_self, __pyx_v_actor_ref, __pyx_v_message, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.tell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1152
 *         return self._send(actor_ref, message, wait_response=False, wait=wait, callback=callback)
 * 
 *     def create_actor(self, str address, object uid, object actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef object actor_id
 *         cdef ActorRef actor_ref
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_9create_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_9create_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_address = 0;
  PyObject *__pyx_v_uid = 0;
  PyObject *__pyx_v_actor_cls = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_actor (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_address,&__pyx_n_s_uid,&__pyx_n_s_actor_cls,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_address)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_uid)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_actor", 0, 3, 3, 1); __PYX_ERR(0, 1152, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_cls)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_actor", 0, 3, 3, 2); __PYX_ERR(0, 1152, __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, "create_actor") < 0)) __PYX_ERR(0, 1152, __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_address = ((PyObject*)values[0]);
    __pyx_v_uid = values[1];
    __pyx_v_actor_cls = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_actor", 0, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1152, __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("mars.actors.pool.gevent_pool.Dispatcher.create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_address), (&PyString_Type), 1, "address", 1))) __PYX_ERR(0, 1152, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_8create_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self), __pyx_v_address, __pyx_v_uid, __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1187
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             self.future(message_id, future, callback=callback)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_12create_actor_1check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_10Dispatcher_12create_actor_1check = {"check", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_12create_actor_1check, METH_NOARGS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_12create_actor_1check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_12create_actor_check(__pyx_self);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_12create_actor_check(PyObject *__pyx_self) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor *__pyx_outer_scope;
  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;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future __pyx_t_5;
  __Pyx_RefNannySetupContext("check", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":1188
 * 
 *         def check():
 *             self.pipes[to_index].put(message)             # <<<<<<<<<<<<<<
 *             self.future(message_id, future, callback=callback)
 * 
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1188, __pyx_L1_error) }
  if (unlikely(__pyx_cur_scope->__pyx_v_self->pipes == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1188, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_cur_scope->__pyx_v_self->pipes, __pyx_cur_scope->__pyx_v_to_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_put); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_cur_scope->__pyx_v_message)) { __Pyx_RaiseClosureNameError("message"); __PYX_ERR(0, 1188, __pyx_L1_error) }
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_cur_scope->__pyx_v_message) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_cur_scope->__pyx_v_message);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1188, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1189
 *         def check():
 *             self.pipes[to_index].put(message)
 *             self.future(message_id, future, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *         gevent.spawn(check)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1189, __pyx_L1_error) }
  if (unlikely(!__pyx_cur_scope->__pyx_v_message_id)) { __Pyx_RaiseClosureNameError("message_id"); __PYX_ERR(0, 1189, __pyx_L1_error) }
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_message_id;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(!__pyx_cur_scope->__pyx_v_future)) { __Pyx_RaiseClosureNameError("future"); __PYX_ERR(0, 1189, __pyx_L1_error) }
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_future;
  __Pyx_INCREF(__pyx_t_3);
  if (unlikely(!__pyx_cur_scope->__pyx_v_callback)) { __Pyx_RaiseClosureNameError("callback"); __PYX_ERR(0, 1189, __pyx_L1_error) }
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_callback;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_5.__pyx_n = 1;
  __pyx_t_5.callback = __pyx_t_2;
  __pyx_t_4 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.future(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_1), __pyx_t_3, 0, &__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __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;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1187
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             self.future(message_id, future, 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_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.create_actor.check", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1152
 *         return self._send(actor_ref, message, wait_response=False, wait=wait, callback=callback)
 * 
 *     def create_actor(self, str address, object uid, object actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef object actor_id
 *         cdef ActorRef actor_ref
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_8create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_address, PyObject *__pyx_v_uid, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor *__pyx_cur_scope;
  PyObject *__pyx_v_actor_id = 0;
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_check = 0;
  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_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  __Pyx_RefNannySetupContext("create_actor", 0);
  __pyx_cur_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor *)__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor(__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1152, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);

  /* "mars/actors/pool/gevent_pool.pyx":1162
 *         cdef object future
 * 
 *         actor_id = uid or new_actor_id()             # <<<<<<<<<<<<<<
 *         actor_ref = ActorRef(address, actor_id)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_uid); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1162, __pyx_L1_error)
  if (!__pyx_t_2) {
  } else {
    __Pyx_INCREF(__pyx_v_uid);
    __pyx_t_1 = __pyx_v_uid;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_3 = __pyx_f_4mars_6actors_4pool_5utils_new_actor_id(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_1 = __pyx_t_3;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_L3_bool_binop_done:;
  __pyx_v_actor_id = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1163
 * 
 *         actor_id = uid or new_actor_id()
 *         actor_ref = ActorRef(address, actor_id)             # <<<<<<<<<<<<<<
 * 
 *         if self._is_remote(actor_ref):
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_address);
  __Pyx_GIVEREF(__pyx_v_address);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_address);
  __Pyx_INCREF(__pyx_v_actor_id);
  __Pyx_GIVEREF(__pyx_v_actor_id);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_actor_id);
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4mars_6actors_4core_ActorRef), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1165
 *         actor_ref = ActorRef(address, actor_id)
 * 
 *         if self._is_remote(actor_ref):             # <<<<<<<<<<<<<<
 *             kwargs['address'] = address
 *             kwargs['uid'] = uid
 */
  __pyx_t_2 = (__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__is_remote(__pyx_cur_scope->__pyx_v_self, __pyx_v_actor_ref) != 0);
  if (__pyx_t_2) {

    /* "mars/actors/pool/gevent_pool.pyx":1166
 * 
 *         if self._is_remote(actor_ref):
 *             kwargs['address'] = address             # <<<<<<<<<<<<<<
 *             kwargs['uid'] = uid
 *             return self.remote_handler.create_actor(actor_cls, *args, **kwargs)
 */
    if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_n_s_address, __pyx_v_address) < 0)) __PYX_ERR(0, 1166, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":1167
 *         if self._is_remote(actor_ref):
 *             kwargs['address'] = address
 *             kwargs['uid'] = uid             # <<<<<<<<<<<<<<
 *             return self.remote_handler.create_actor(actor_cls, *args, **kwargs)
 * 
 */
    if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_n_s_uid, __pyx_v_uid) < 0)) __PYX_ERR(0, 1167, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":1168
 *             kwargs['address'] = address
 *             kwargs['uid'] = uid
 *             return self.remote_handler.create_actor(actor_cls, *args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *         wait = kwargs.pop('wait', True)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->remote_handler, __pyx_n_s_create_actor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1168, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1168, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_actor_cls);
    __Pyx_GIVEREF(__pyx_v_actor_cls);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_actor_cls);
    __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_v_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1168, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_v_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1168, __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_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":1165
 *         actor_ref = ActorRef(address, actor_id)
 * 
 *         if self._is_remote(actor_ref):             # <<<<<<<<<<<<<<
 *             kwargs['address'] = address
 *             kwargs['uid'] = uid
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1170
 *             return self.remote_handler.create_actor(actor_cls, *args, **kwargs)
 * 
 *         wait = kwargs.pop('wait', True)             # <<<<<<<<<<<<<<
 *         callback = kwargs.pop('callback', None)
 * 
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_wait, Py_True); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1170, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_wait = __pyx_t_2;

  /* "mars/actors/pool/gevent_pool.pyx":1171
 * 
 *         wait = kwargs.pop('wait', True)
 *         callback = kwargs.pop('callback', None)             # <<<<<<<<<<<<<<
 * 
 *         to_index = self.distributor.distribute(actor_id)
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_callback, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1171, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_callback = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1173
 *         callback = kwargs.pop('callback', None)
 * 
 *         to_index = self.distributor.distribute(actor_id)             # <<<<<<<<<<<<<<
 *         try:
 *             message_id, message = pack_create_actor_message(
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->distributor, __pyx_n_s_distribute); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_v_actor_id) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_actor_id);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1173, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_cur_scope->__pyx_v_to_index = __pyx_t_5;

  /* "mars/actors/pool/gevent_pool.pyx":1174
 * 
 *         to_index = self.distributor.distribute(actor_id)
 *         try:             # <<<<<<<<<<<<<<
 *             message_id, message = pack_create_actor_message(
 *                 self.index, to_index, actor_ref, actor_cls, args, kwargs)
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __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:*/ {

      /* "mars/actors/pool/gevent_pool.pyx":1175
 *         to_index = self.distributor.distribute(actor_id)
 *         try:
 *             message_id, message = pack_create_actor_message(             # <<<<<<<<<<<<<<
 *                 self.index, to_index, actor_ref, actor_cls, args, kwargs)
 *         except (AttributeError, pickle.PickleError):
 */
      __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_pack_create_actor_message(__pyx_cur_scope->__pyx_v_self->index, __pyx_cur_scope->__pyx_v_to_index, __pyx_v_actor_ref, __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs, 0, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1175, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_1);
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 1175, __pyx_L6_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        #else
        __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1175, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1175, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1175, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
        index = 0; __pyx_t_4 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_4)) goto __pyx_L12_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 1; __pyx_t_3 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_3)) goto __pyx_L12_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 1175, __pyx_L6_error)
        __pyx_t_10 = NULL;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L13_unpacking_done;
        __pyx_L12_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_10 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 1175, __pyx_L6_error)
        __pyx_L13_unpacking_done:;
      }
      if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 1175, __pyx_L6_error)
      if (!(likely(PyByteArray_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 1175, __pyx_L6_error)
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_message_id = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_cur_scope->__pyx_v_message = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":1174
 * 
 *         to_index = self.distributor.distribute(actor_id)
 *         try:             # <<<<<<<<<<<<<<
 *             message_id, message = pack_create_actor_message(
 *                 self.index, to_index, actor_ref, actor_cls, args, kwargs)
 */
    }
    __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_L11_try_end;
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 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;

    /* "mars/actors/pool/gevent_pool.pyx":1177
 *             message_id, message = pack_create_actor_message(
 *                 self.index, to_index, actor_ref, actor_cls, args, kwargs)
 *         except (AttributeError, pickle.PickleError):             # <<<<<<<<<<<<<<
 *             raise pickle.PicklingError('Unable to pickle {0}(*{1}, **{2})'.format(actor_cls, args, kwargs))
 * 
 */
    __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_3, &__pyx_t_4);
    __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_pickle); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1177, __pyx_L8_except_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1177, __pyx_L8_except_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_5 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_builtin_AttributeError) || __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_11);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_ErrRestore(__pyx_t_1, __pyx_t_3, __pyx_t_4);
    __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_4 = 0;
    if (__pyx_t_5) {
      __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_3, &__pyx_t_1) < 0) __PYX_ERR(0, 1177, __pyx_L8_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_1);

      /* "mars/actors/pool/gevent_pool.pyx":1178
 *                 self.index, to_index, actor_ref, actor_cls, args, kwargs)
 *         except (AttributeError, pickle.PickleError):
 *             raise pickle.PicklingError('Unable to pickle {0}(*{1}, **{2})'.format(actor_cls, args, kwargs))             # <<<<<<<<<<<<<<
 * 
 *         if wait:
 */
      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_pickle); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1178, __pyx_L8_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_PicklingError); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1178, __pyx_L8_except_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Unable_to_pickle_0_1_2, __pyx_n_s_format); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1178, __pyx_L8_except_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
        __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
        if (likely(__pyx_t_14)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_13, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[4] = {__pyx_t_14, __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1178, __pyx_L8_except_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
        PyObject *__pyx_temp[4] = {__pyx_t_14, __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1178, __pyx_L8_except_error)
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      {
        __pyx_t_15 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1178, __pyx_L8_except_error)
        __Pyx_GOTREF(__pyx_t_15);
        if (__pyx_t_14) {
          __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_14); __pyx_t_14 = NULL;
        }
        __Pyx_INCREF(__pyx_v_actor_cls);
        __Pyx_GIVEREF(__pyx_v_actor_cls);
        PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_5, __pyx_v_actor_cls);
        __Pyx_INCREF(__pyx_v_args);
        __Pyx_GIVEREF(__pyx_v_args);
        PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_5, __pyx_v_args);
        __Pyx_INCREF(__pyx_v_kwargs);
        __Pyx_GIVEREF(__pyx_v_kwargs);
        PyTuple_SET_ITEM(__pyx_t_15, 2+__pyx_t_5, __pyx_v_kwargs);
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_15, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1178, __pyx_L8_except_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_13 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(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);
        }
      }
      __pyx_t_11 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_13, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_9);
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1178, __pyx_L8_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_Raise(__pyx_t_11, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __PYX_ERR(0, 1178, __pyx_L8_except_error)
    }
    goto __pyx_L8_except_error;
    __pyx_L8_except_error:;

    /* "mars/actors/pool/gevent_pool.pyx":1174
 * 
 *         to_index = self.distributor.distribute(actor_id)
 *         try:             # <<<<<<<<<<<<<<
 *             message_id, message = pack_create_actor_message(
 *                 self.index, to_index, actor_ref, actor_cls, args, kwargs)
 */
    __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_end:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":1180
 *             raise pickle.PicklingError('Unable to pickle {0}(*{1}, **{2})'.format(actor_cls, args, kwargs))
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             return self.submit(message_id)
 */
  __pyx_t_2 = (__pyx_v_wait != 0);
  if (__pyx_t_2) {

    /* "mars/actors/pool/gevent_pool.pyx":1181
 * 
 *         if wait:
 *             self.pipes[to_index].put(message)             # <<<<<<<<<<<<<<
 *             return self.submit(message_id)
 * 
 */
    if (unlikely(__pyx_cur_scope->__pyx_v_self->pipes == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1181, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_cur_scope->__pyx_v_self->pipes, __pyx_cur_scope->__pyx_v_to_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1181, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_put); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1181, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_cur_scope->__pyx_v_message) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_cur_scope->__pyx_v_message);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1181, __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;

    /* "mars/actors/pool/gevent_pool.pyx":1182
 *         if wait:
 *             self.pipes[to_index].put(message)
 *             return self.submit(message_id)             # <<<<<<<<<<<<<<
 * 
 *         # return future
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __pyx_cur_scope->__pyx_v_message_id;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_4 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.submit(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_1), 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1182, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":1180
 *             raise pickle.PicklingError('Unable to pickle {0}(*{1}, **{2})'.format(actor_cls, args, kwargs))
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             return self.submit(message_id)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1185
 * 
 *         # return future
 *         future = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 * 
 *         def check():
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_event); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_AsyncResult); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_cur_scope->__pyx_v_future = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1187
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             self.future(message_id, future, callback=callback)
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_10Dispatcher_12create_actor_1check, 0, __pyx_n_s_create_actor_locals_check, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__29)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_check = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1191
 *             self.future(message_id, future, callback=callback)
 * 
 *         gevent.spawn(check)             # <<<<<<<<<<<<<<
 *         return future
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_spawn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_v_check) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_check);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1191, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1192
 * 
 *         gevent.spawn(check)
 *         return future             # <<<<<<<<<<<<<<
 * 
 *     def destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_future);
  __pyx_r = __pyx_cur_scope->__pyx_v_future;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1152
 *         return self._send(actor_ref, message, wait_response=False, wait=wait, callback=callback)
 * 
 *     def create_actor(self, str address, object uid, object actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef object actor_id
 *         cdef ActorRef actor_ref
 */

  /* 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_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_actor_id);
  __Pyx_XDECREF((PyObject *)__pyx_v_actor_ref);
  __Pyx_XDECREF(__pyx_v_check);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1194
 *         return future
 * 
 *     def destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef int to_index
 *         cdef bytes message_id
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_11destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_11destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("destroy_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "destroy_actor") < 0)) __PYX_ERR(0, 1194, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    if (values[1]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1194, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("destroy_actor", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1194, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 1194, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_10destroy_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1215
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             self.future(message_id, future, callback=callback)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_13destroy_actor_1check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_10Dispatcher_13destroy_actor_1check = {"check", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_13destroy_actor_1check, METH_NOARGS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_13destroy_actor_1check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_13destroy_actor_check(__pyx_self);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_13destroy_actor_check(PyObject *__pyx_self) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor *__pyx_outer_scope;
  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;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future __pyx_t_5;
  __Pyx_RefNannySetupContext("check", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":1216
 * 
 *         def check():
 *             self.pipes[to_index].put(message)             # <<<<<<<<<<<<<<
 *             self.future(message_id, future, callback=callback)
 * 
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1216, __pyx_L1_error) }
  if (unlikely(__pyx_cur_scope->__pyx_v_self->pipes == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1216, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_cur_scope->__pyx_v_self->pipes, __pyx_cur_scope->__pyx_v_to_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1216, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_put); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1216, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_cur_scope->__pyx_v_message)) { __Pyx_RaiseClosureNameError("message"); __PYX_ERR(0, 1216, __pyx_L1_error) }
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_cur_scope->__pyx_v_message) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_cur_scope->__pyx_v_message);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1216, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1217
 *         def check():
 *             self.pipes[to_index].put(message)
 *             self.future(message_id, future, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *         gevent.spawn(check)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1217, __pyx_L1_error) }
  if (unlikely(!__pyx_cur_scope->__pyx_v_message_id)) { __Pyx_RaiseClosureNameError("message_id"); __PYX_ERR(0, 1217, __pyx_L1_error) }
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_message_id;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(!__pyx_cur_scope->__pyx_v_future)) { __Pyx_RaiseClosureNameError("future"); __PYX_ERR(0, 1217, __pyx_L1_error) }
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_future;
  __Pyx_INCREF(__pyx_t_3);
  if (unlikely(!__pyx_cur_scope->__pyx_v_callback)) { __Pyx_RaiseClosureNameError("callback"); __PYX_ERR(0, 1217, __pyx_L1_error) }
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_callback;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_5.__pyx_n = 1;
  __pyx_t_5.callback = __pyx_t_2;
  __pyx_t_4 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.future(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_1), __pyx_t_3, 0, &__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __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;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1215
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             self.future(message_id, future, 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_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.destroy_actor.check", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1194
 *         return future
 * 
 *     def destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef int to_index
 *         cdef bytes message_id
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_10destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor *__pyx_cur_scope;
  PyObject *__pyx_v_check = 0;
  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_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  __Pyx_RefNannySetupContext("destroy_actor", 0);
  __pyx_cur_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor *)__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor(__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1194, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __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);

  /* "mars/actors/pool/gevent_pool.pyx":1200
 *         cdef object future
 * 
 *         if self._is_remote(actor_ref):             # <<<<<<<<<<<<<<
 *             return self.remote_handler.destroy_actor(actor_ref, wait=wait, callback=callback)
 * 
 */
  __pyx_t_1 = (__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__is_remote(__pyx_cur_scope->__pyx_v_self, __pyx_v_actor_ref) != 0);
  if (__pyx_t_1) {

    /* "mars/actors/pool/gevent_pool.pyx":1201
 * 
 *         if self._is_remote(actor_ref):
 *             return self.remote_handler.destroy_actor(actor_ref, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *         to_index = self.distributor.distribute(actor_ref.uid)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->remote_handler, __pyx_n_s_destroy_actor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1201, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1201, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_actor_ref));
    __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1201, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1201, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_wait, __pyx_t_5) < 0) __PYX_ERR(0, 1201, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_callback, __pyx_cur_scope->__pyx_v_callback) < 0) __PYX_ERR(0, 1201, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1201, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":1200
 *         cdef object future
 * 
 *         if self._is_remote(actor_ref):             # <<<<<<<<<<<<<<
 *             return self.remote_handler.destroy_actor(actor_ref, wait=wait, callback=callback)
 * 
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1203
 *             return self.remote_handler.destroy_actor(actor_ref, wait=wait, callback=callback)
 * 
 *         to_index = self.distributor.distribute(actor_ref.uid)             # <<<<<<<<<<<<<<
 * 
 *         message_id, message = pack_destroy_actor_message(
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->distributor, __pyx_n_s_distribute); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_5 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_v_actor_ref->uid) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_actor_ref->uid);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1203, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_cur_scope->__pyx_v_to_index = __pyx_t_6;

  /* "mars/actors/pool/gevent_pool.pyx":1205
 *         to_index = self.distributor.distribute(actor_ref.uid)
 * 
 *         message_id, message = pack_destroy_actor_message(             # <<<<<<<<<<<<<<
 *             self.index, to_index, actor_ref)
 * 
 */
  __pyx_t_5 = __pyx_f_4mars_6actors_4pool_8messages_pack_destroy_actor_message(__pyx_cur_scope->__pyx_v_self->index, __pyx_cur_scope->__pyx_v_to_index, __pyx_v_actor_ref, 0, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1205, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
    PyObject* sequence = __pyx_t_5;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 1205, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1205, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1205, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_2 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1205, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext;
    index = 0; __pyx_t_4 = __pyx_t_7(__pyx_t_2); if (unlikely(!__pyx_t_4)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    index = 1; __pyx_t_3 = __pyx_t_7(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_2), 2) < 0) __PYX_ERR(0, 1205, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L5_unpacking_done;
    __pyx_L4_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 1205, __pyx_L1_error)
    __pyx_L5_unpacking_done:;
  }
  if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 1205, __pyx_L1_error)
  if (!(likely(PyByteArray_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 1205, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_cur_scope->__pyx_v_message_id = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_message = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1208
 *             self.index, to_index, actor_ref)
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             return self.submit(message_id)
 */
  __pyx_t_1 = (__pyx_v_wait != 0);
  if (__pyx_t_1) {

    /* "mars/actors/pool/gevent_pool.pyx":1209
 * 
 *         if wait:
 *             self.pipes[to_index].put(message)             # <<<<<<<<<<<<<<
 *             return self.submit(message_id)
 * 
 */
    if (unlikely(__pyx_cur_scope->__pyx_v_self->pipes == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1209, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_cur_scope->__pyx_v_self->pipes, __pyx_cur_scope->__pyx_v_to_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1209, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_put); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1209, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_5 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_cur_scope->__pyx_v_message) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_cur_scope->__pyx_v_message);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1209, __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;

    /* "mars/actors/pool/gevent_pool.pyx":1210
 *         if wait:
 *             self.pipes[to_index].put(message)
 *             return self.submit(message_id)             # <<<<<<<<<<<<<<
 * 
 *         # return future
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __pyx_cur_scope->__pyx_v_message_id;
    __Pyx_INCREF(__pyx_t_5);
    __pyx_t_4 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.submit(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_5), 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1210, __pyx_L1_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_L0;

    /* "mars/actors/pool/gevent_pool.pyx":1208
 *             self.index, to_index, actor_ref)
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             return self.submit(message_id)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1213
 * 
 *         # return future
 *         future = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 * 
 *         def check():
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_gevent); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_event); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_AsyncResult); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_cur_scope->__pyx_v_future = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1215
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             self.future(message_id, future, callback=callback)
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_10Dispatcher_13destroy_actor_1check, 0, __pyx_n_s_destroy_actor_locals_check, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__30)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1215, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_check = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1219
 *             self.future(message_id, future, callback=callback)
 * 
 *         gevent.spawn(check)             # <<<<<<<<<<<<<<
 *         return future
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_gevent); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_spawn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_v_check) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_check);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1219, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1220
 * 
 *         gevent.spawn(check)
 *         return future             # <<<<<<<<<<<<<<
 * 
 *     def has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_future);
  __pyx_r = __pyx_cur_scope->__pyx_v_future;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1194
 *         return future
 * 
 *     def destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef int to_index
 *         cdef bytes message_id
 */

  /* 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("mars.actors.pool.gevent_pool.Dispatcher.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_check);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1222
 *         return future
 * 
 *     def has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef int to_index
 *         cdef bytes message_id
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_13has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_13has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("has_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "has_actor") < 0)) __PYX_ERR(0, 1222, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    if (values[1]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1222, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("has_actor", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1222, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 1222, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_12has_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1243
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             self.future(message_id, future, callback=callback)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_9has_actor_1check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_10Dispatcher_9has_actor_1check = {"check", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_9has_actor_1check, METH_NOARGS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_9has_actor_1check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_9has_actor_check(__pyx_self);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_9has_actor_check(PyObject *__pyx_self) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor *__pyx_outer_scope;
  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;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future __pyx_t_5;
  __Pyx_RefNannySetupContext("check", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":1244
 * 
 *         def check():
 *             self.pipes[to_index].put(message)             # <<<<<<<<<<<<<<
 *             self.future(message_id, future, callback=callback)
 * 
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1244, __pyx_L1_error) }
  if (unlikely(__pyx_cur_scope->__pyx_v_self->pipes == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1244, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_cur_scope->__pyx_v_self->pipes, __pyx_cur_scope->__pyx_v_to_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_put); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_cur_scope->__pyx_v_message)) { __Pyx_RaiseClosureNameError("message"); __PYX_ERR(0, 1244, __pyx_L1_error) }
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_cur_scope->__pyx_v_message) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_cur_scope->__pyx_v_message);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1244, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1245
 *         def check():
 *             self.pipes[to_index].put(message)
 *             self.future(message_id, future, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *         gevent.spawn(check)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1245, __pyx_L1_error) }
  if (unlikely(!__pyx_cur_scope->__pyx_v_message_id)) { __Pyx_RaiseClosureNameError("message_id"); __PYX_ERR(0, 1245, __pyx_L1_error) }
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_message_id;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(!__pyx_cur_scope->__pyx_v_future)) { __Pyx_RaiseClosureNameError("future"); __PYX_ERR(0, 1245, __pyx_L1_error) }
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_future;
  __Pyx_INCREF(__pyx_t_3);
  if (unlikely(!__pyx_cur_scope->__pyx_v_callback)) { __Pyx_RaiseClosureNameError("callback"); __PYX_ERR(0, 1245, __pyx_L1_error) }
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_callback;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_5.__pyx_n = 1;
  __pyx_t_5.callback = __pyx_t_2;
  __pyx_t_4 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.future(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_1), __pyx_t_3, 0, &__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1245, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __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;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1243
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             self.future(message_id, future, 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_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.has_actor.check", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1222
 *         return future
 * 
 *     def has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef int to_index
 *         cdef bytes message_id
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_12has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor *__pyx_cur_scope;
  PyObject *__pyx_v_check = 0;
  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_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  __Pyx_RefNannySetupContext("has_actor", 0);
  __pyx_cur_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor *)__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor(__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1222, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __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);

  /* "mars/actors/pool/gevent_pool.pyx":1228
 *         cdef object future
 * 
 *         if self._is_remote(actor_ref):             # <<<<<<<<<<<<<<
 *             return self.remote_handler.has_actor(actor_ref, wait=wait, callback=callback)
 * 
 */
  __pyx_t_1 = (__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__is_remote(__pyx_cur_scope->__pyx_v_self, __pyx_v_actor_ref) != 0);
  if (__pyx_t_1) {

    /* "mars/actors/pool/gevent_pool.pyx":1229
 * 
 *         if self._is_remote(actor_ref):
 *             return self.remote_handler.has_actor(actor_ref, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *         to_index = self.distributor.distribute(actor_ref.uid)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->remote_handler, __pyx_n_s_has_actor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1229, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1229, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_actor_ref));
    __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1229, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1229, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_wait, __pyx_t_5) < 0) __PYX_ERR(0, 1229, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_callback, __pyx_cur_scope->__pyx_v_callback) < 0) __PYX_ERR(0, 1229, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1229, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":1228
 *         cdef object future
 * 
 *         if self._is_remote(actor_ref):             # <<<<<<<<<<<<<<
 *             return self.remote_handler.has_actor(actor_ref, wait=wait, callback=callback)
 * 
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1231
 *             return self.remote_handler.has_actor(actor_ref, wait=wait, callback=callback)
 * 
 *         to_index = self.distributor.distribute(actor_ref.uid)             # <<<<<<<<<<<<<<
 * 
 *         message_id, message = pack_has_actor_message(
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->distributor, __pyx_n_s_distribute); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_5 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_v_actor_ref->uid) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_actor_ref->uid);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1231, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_cur_scope->__pyx_v_to_index = __pyx_t_6;

  /* "mars/actors/pool/gevent_pool.pyx":1233
 *         to_index = self.distributor.distribute(actor_ref.uid)
 * 
 *         message_id, message = pack_has_actor_message(             # <<<<<<<<<<<<<<
 *             self.index, to_index, actor_ref)
 * 
 */
  __pyx_t_5 = __pyx_f_4mars_6actors_4pool_8messages_pack_has_actor_message(__pyx_cur_scope->__pyx_v_self->index, __pyx_cur_scope->__pyx_v_to_index, __pyx_v_actor_ref, 0, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1233, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
    PyObject* sequence = __pyx_t_5;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 1233, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1233, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1233, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_2 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1233, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext;
    index = 0; __pyx_t_4 = __pyx_t_7(__pyx_t_2); if (unlikely(!__pyx_t_4)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    index = 1; __pyx_t_3 = __pyx_t_7(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_2), 2) < 0) __PYX_ERR(0, 1233, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L5_unpacking_done;
    __pyx_L4_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 1233, __pyx_L1_error)
    __pyx_L5_unpacking_done:;
  }
  if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 1233, __pyx_L1_error)
  if (!(likely(PyByteArray_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 1233, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_cur_scope->__pyx_v_message_id = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_message = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1236
 *             self.index, to_index, actor_ref)
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             return self.submit(message_id)
 */
  __pyx_t_1 = (__pyx_v_wait != 0);
  if (__pyx_t_1) {

    /* "mars/actors/pool/gevent_pool.pyx":1237
 * 
 *         if wait:
 *             self.pipes[to_index].put(message)             # <<<<<<<<<<<<<<
 *             return self.submit(message_id)
 * 
 */
    if (unlikely(__pyx_cur_scope->__pyx_v_self->pipes == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1237, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_cur_scope->__pyx_v_self->pipes, __pyx_cur_scope->__pyx_v_to_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_put); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_5 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_cur_scope->__pyx_v_message) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_cur_scope->__pyx_v_message);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1237, __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;

    /* "mars/actors/pool/gevent_pool.pyx":1238
 *         if wait:
 *             self.pipes[to_index].put(message)
 *             return self.submit(message_id)             # <<<<<<<<<<<<<<
 * 
 *         # return future
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __pyx_cur_scope->__pyx_v_message_id;
    __Pyx_INCREF(__pyx_t_5);
    __pyx_t_4 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_cur_scope->__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.submit(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_cur_scope->__pyx_v_self), ((PyObject*)__pyx_t_5), 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1238, __pyx_L1_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_L0;

    /* "mars/actors/pool/gevent_pool.pyx":1236
 *             self.index, to_index, actor_ref)
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             return self.submit(message_id)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1241
 * 
 *         # return future
 *         future = gevent.event.AsyncResult()             # <<<<<<<<<<<<<<
 * 
 *         def check():
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_gevent); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1241, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_event); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1241, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_AsyncResult); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1241, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1241, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_cur_scope->__pyx_v_future = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1243
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             self.future(message_id, future, callback=callback)
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_10Dispatcher_9has_actor_1check, 0, __pyx_n_s_has_actor_locals_check, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__31)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1243, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_check = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1247
 *             self.future(message_id, future, callback=callback)
 * 
 *         gevent.spawn(check)             # <<<<<<<<<<<<<<
 *         return future
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_gevent); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_spawn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_v_check) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_check);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1247, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1248
 * 
 *         gevent.spawn(check)
 *         return future             # <<<<<<<<<<<<<<
 * 
 *     cpdef _on_receive_action(self, bytes binary):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_future);
  __pyx_r = __pyx_cur_scope->__pyx_v_future;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1222
 *         return future
 * 
 *     def has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         cdef int to_index
 *         cdef bytes message_id
 */

  /* 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("mars.actors.pool.gevent_pool.Dispatcher.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_check);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1250
 *         return future
 * 
 *     cpdef _on_receive_action(self, bytes binary):             # <<<<<<<<<<<<<<
 *         cdef int from_index
 *         cdef int to_index
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_15_on_receive_action(PyObject *__pyx_v_self, PyObject *__pyx_v_binary); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__on_receive_action(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_binary, int __pyx_skip_dispatch) {
  int __pyx_v_from_index;
  int __pyx_v_to_index;
  PyObject *__pyx_v_message_id = 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;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  __Pyx_RefNannySetupContext("_on_receive_action", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_action); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1250, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_15_on_receive_action)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_binary) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_binary);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1250, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":1255
 *         cdef bytes message_id
 * 
 *         from_index, to_index = get_index(binary, self.distributor.distribute)             # <<<<<<<<<<<<<<
 *         message_id = unpack_message_id(binary)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->distributor, __pyx_n_s_distribute); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_f_4mars_6actors_4pool_8messages_get_index(__pyx_v_binary, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_2 != Py_None)) {
    PyObject* sequence = __pyx_t_2;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 1255, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyTuple_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_ERR(0, 1255, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1255, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 1255, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1255, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1255, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_from_index = __pyx_t_5;
  __pyx_v_to_index = __pyx_t_6;

  /* "mars/actors/pool/gevent_pool.pyx":1256
 * 
 *         from_index, to_index = get_index(binary, self.distributor.distribute)
 *         message_id = unpack_message_id(binary)             # <<<<<<<<<<<<<<
 * 
 *         if from_index == REMOTE_FROM_INDEX:
 */
  __pyx_t_2 = __pyx_f_4mars_6actors_4pool_8messages_unpack_message_id(__pyx_v_binary, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_message_id = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1258
 *         message_id = unpack_message_id(binary)
 * 
 *         if from_index == REMOTE_FROM_INDEX:             # <<<<<<<<<<<<<<
 *             # sent from remote, redirect to process, and wait for result
 *             self.pipes[to_index].put(binary)
 */
  __pyx_t_7 = ((__pyx_v_from_index == __pyx_v_4mars_6actors_4pool_11gevent_pool_REMOTE_FROM_INDEX) != 0);
  if (__pyx_t_7) {

    /* "mars/actors/pool/gevent_pool.pyx":1260
 *         if from_index == REMOTE_FROM_INDEX:
 *             # sent from remote, redirect to process, and wait for result
 *             self.pipes[to_index].put(binary)             # <<<<<<<<<<<<<<
 *             return self.wait(message_id)
 *         else:
 */
    if (unlikely(__pyx_v_self->pipes == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1260, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_self->pipes, __pyx_v_to_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1260, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_put); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1260, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_v_binary) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_binary);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1260, __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;

    /* "mars/actors/pool/gevent_pool.pyx":1261
 *             # sent from remote, redirect to process, and wait for result
 *             self.pipes[to_index].put(binary)
 *             return self.wait(message_id)             # <<<<<<<<<<<<<<
 *         else:
 *             # sent from other process, just redirect
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.wait(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_v_self), __pyx_v_message_id, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1261, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":1258
 *         message_id = unpack_message_id(binary)
 * 
 *         if from_index == REMOTE_FROM_INDEX:             # <<<<<<<<<<<<<<
 *             # sent from remote, redirect to process, and wait for result
 *             self.pipes[to_index].put(binary)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1264
 *         else:
 *             # sent from other process, just redirect
 *             self.pipes[to_index].put(binary)             # <<<<<<<<<<<<<<
 * 
 *     cpdef _on_receive_result(self, bytes binary):
 */
  /*else*/ {
    if (unlikely(__pyx_v_self->pipes == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1264, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_self->pipes, __pyx_v_to_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1264, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_put); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1264, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_v_binary) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_binary);
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1264, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  /* "mars/actors/pool/gevent_pool.pyx":1250
 *         return future
 * 
 *     cpdef _on_receive_action(self, bytes binary):             # <<<<<<<<<<<<<<
 *         cdef int from_index
 *         cdef int to_index
 */

  /* 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("mars.actors.pool.gevent_pool.Dispatcher._on_receive_action", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_message_id);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_15_on_receive_action(PyObject *__pyx_v_self, PyObject *__pyx_v_binary); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_15_on_receive_action(PyObject *__pyx_v_self, PyObject *__pyx_v_binary) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_on_receive_action (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_binary), (&PyBytes_Type), 1, "binary", 1))) __PYX_ERR(0, 1250, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_14_on_receive_action(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self), ((PyObject*)__pyx_v_binary));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_14_on_receive_action(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_binary) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_on_receive_action", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__on_receive_action(__pyx_v_self, __pyx_v_binary, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher._on_receive_action", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1266
 *             self.pipes[to_index].put(binary)
 * 
 *     cpdef _on_receive_result(self, bytes binary):             # <<<<<<<<<<<<<<
 *         cdef int from_index
 *         cdef int to_index
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_17_on_receive_result(PyObject *__pyx_v_self, PyObject *__pyx_v_binary); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__on_receive_result(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_binary, int __pyx_skip_dispatch) {
  int __pyx_v_from_index;
  int __pyx_v_to_index;
  PyObject *__pyx_v_message_id = 0;
  PyObject *__pyx_v_result = 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;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  struct __pyx_opt_args_4mars_6actors_4pool_8messages_unpack_result_message __pyx_t_8;
  __Pyx_RefNannySetupContext("_on_receive_result", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1266, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_17_on_receive_result)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_binary) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_binary);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1266, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":1272
 *         cdef object result
 * 
 *         from_index, to_index = get_index(binary, None)             # <<<<<<<<<<<<<<
 *         if to_index == self.index:
 *             # sent from the dispatcher
 */
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_get_index(__pyx_v_binary, Py_None, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 1272, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyTuple_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_ERR(0, 1272, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1272, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 1272, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1272, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1272, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_from_index = __pyx_t_5;
  __pyx_v_to_index = __pyx_t_6;

  /* "mars/actors/pool/gevent_pool.pyx":1273
 * 
 *         from_index, to_index = get_index(binary, None)
 *         if to_index == self.index:             # <<<<<<<<<<<<<<
 *             # sent from the dispatcher
 *             result = unpack_result_message(binary, from_index=from_index, to_index=to_index)
 */
  __pyx_t_7 = ((__pyx_v_to_index == __pyx_v_self->index) != 0);
  if (__pyx_t_7) {

    /* "mars/actors/pool/gevent_pool.pyx":1275
 *         if to_index == self.index:
 *             # sent from the dispatcher
 *             result = unpack_result_message(binary, from_index=from_index, to_index=to_index)             # <<<<<<<<<<<<<<
 *             self.got(result.message_id, result.result)
 *         elif to_index == REMOTE_FROM_INDEX:
 */
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_from_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_to_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8.__pyx_n = 2;
    __pyx_t_8.from_index = __pyx_t_1;
    __pyx_t_8.to_index = __pyx_t_3;
    __pyx_t_2 = __pyx_f_4mars_6actors_4pool_8messages_unpack_result_message(__pyx_v_binary, 0, &__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_result = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1276
 *             # sent from the dispatcher
 *             result = unpack_result_message(binary, from_index=from_index, to_index=to_index)
 *             self.got(result.message_id, result.result)             # <<<<<<<<<<<<<<
 *         elif to_index == REMOTE_FROM_INDEX:
 *             # sent from remote
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_result, __pyx_n_s_message_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 1276, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_result, __pyx_n_s_result); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.got(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_v_self), ((PyObject*)__pyx_t_2), __pyx_t_3, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1273
 * 
 *         from_index, to_index = get_index(binary, None)
 *         if to_index == self.index:             # <<<<<<<<<<<<<<
 *             # sent from the dispatcher
 *             result = unpack_result_message(binary, from_index=from_index, to_index=to_index)
 */
    goto __pyx_L3;
  }

  /* "mars/actors/pool/gevent_pool.pyx":1277
 *             result = unpack_result_message(binary, from_index=from_index, to_index=to_index)
 *             self.got(result.message_id, result.result)
 *         elif to_index == REMOTE_FROM_INDEX:             # <<<<<<<<<<<<<<
 *             # sent from remote
 *             message_id = unpack_message_id(binary)
 */
  __pyx_t_7 = ((__pyx_v_to_index == __pyx_v_4mars_6actors_4pool_11gevent_pool_REMOTE_FROM_INDEX) != 0);
  if (__pyx_t_7) {

    /* "mars/actors/pool/gevent_pool.pyx":1279
 *         elif to_index == REMOTE_FROM_INDEX:
 *             # sent from remote
 *             message_id = unpack_message_id(binary)             # <<<<<<<<<<<<<<
 *             self.got(message_id, binary)
 *         else:
 */
    __pyx_t_3 = __pyx_f_4mars_6actors_4pool_8messages_unpack_message_id(__pyx_v_binary, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1279, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_message_id = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1280
 *             # sent from remote
 *             message_id = unpack_message_id(binary)
 *             self.got(message_id, binary)             # <<<<<<<<<<<<<<
 *         else:
 *             # sent from process
 */
    ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.got(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_v_self), __pyx_v_message_id, __pyx_v_binary, 0);

    /* "mars/actors/pool/gevent_pool.pyx":1277
 *             result = unpack_result_message(binary, from_index=from_index, to_index=to_index)
 *             self.got(result.message_id, result.result)
 *         elif to_index == REMOTE_FROM_INDEX:             # <<<<<<<<<<<<<<
 *             # sent from remote
 *             message_id = unpack_message_id(binary)
 */
    goto __pyx_L3;
  }

  /* "mars/actors/pool/gevent_pool.pyx":1283
 *         else:
 *             # sent from process
 *             self.pipes[to_index].put(binary)             # <<<<<<<<<<<<<<
 * 
 *     cpdef _on_receive_error(self, binary):
 */
  /*else*/ {
    if (unlikely(__pyx_v_self->pipes == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1283, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_self->pipes, __pyx_v_to_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_put); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, __pyx_v_binary) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_binary);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1283, __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;
  }
  __pyx_L3:;

  /* "mars/actors/pool/gevent_pool.pyx":1266
 *             self.pipes[to_index].put(binary)
 * 
 *     cpdef _on_receive_result(self, bytes binary):             # <<<<<<<<<<<<<<
 *         cdef int from_index
 *         cdef int to_index
 */

  /* 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("mars.actors.pool.gevent_pool.Dispatcher._on_receive_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_message_id);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_17_on_receive_result(PyObject *__pyx_v_self, PyObject *__pyx_v_binary); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_17_on_receive_result(PyObject *__pyx_v_self, PyObject *__pyx_v_binary) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_on_receive_result (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_binary), (&PyBytes_Type), 1, "binary", 1))) __PYX_ERR(0, 1266, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_16_on_receive_result(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self), ((PyObject*)__pyx_v_binary));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_16_on_receive_result(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_binary) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_on_receive_result", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__on_receive_result(__pyx_v_self, __pyx_v_binary, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1266, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher._on_receive_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1285
 *             self.pipes[to_index].put(binary)
 * 
 *     cpdef _on_receive_error(self, binary):             # <<<<<<<<<<<<<<
 *         cdef int to_index
 *         cdef object err
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_19_on_receive_error(PyObject *__pyx_v_self, PyObject *__pyx_v_binary); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__on_receive_error(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_binary, int __pyx_skip_dispatch) {
  int __pyx_v_to_index;
  PyObject *__pyx_v_err = 0;
  PyObject *__pyx_v_message_id = 0;
  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;
  int __pyx_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("_on_receive_error", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1285, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_19_on_receive_error)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_binary) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_binary);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1285, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":1290
 *         cdef bytes message_id
 * 
 *         _, to_index = get_index(binary, None)             # <<<<<<<<<<<<<<
 *         if to_index == self.index:
 *             # sent from the dispatcher
 */
  if (!(likely(PyBytes_CheckExact(__pyx_v_binary))||((__pyx_v_binary) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_binary)->tp_name), 0))) __PYX_ERR(0, 1290, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_get_index(((PyObject*)__pyx_v_binary), Py_None, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(__pyx_t_1 != Py_None)) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 1290, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyTuple_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_ERR(0, 1290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 1290, __pyx_L1_error)
  }
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1290, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v__ = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_to_index = __pyx_t_5;

  /* "mars/actors/pool/gevent_pool.pyx":1291
 * 
 *         _, to_index = get_index(binary, None)
 *         if to_index == self.index:             # <<<<<<<<<<<<<<
 *             # sent from the dispatcher
 *             err = unpack_error_message(binary)
 */
  __pyx_t_6 = ((__pyx_v_to_index == __pyx_v_self->index) != 0);
  if (__pyx_t_6) {

    /* "mars/actors/pool/gevent_pool.pyx":1293
 *         if to_index == self.index:
 *             # sent from the dispatcher
 *             err = unpack_error_message(binary)             # <<<<<<<<<<<<<<
 *             self.err(err.message_id, err.error_type, err.error, err.traceback)
 *         elif to_index == REMOTE_FROM_INDEX:
 */
    if (!(likely(PyBytes_CheckExact(__pyx_v_binary))||((__pyx_v_binary) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_binary)->tp_name), 0))) __PYX_ERR(0, 1293, __pyx_L1_error)
    __pyx_t_1 = __pyx_f_4mars_6actors_4pool_8messages_unpack_error_message(((PyObject*)__pyx_v_binary), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1293, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_err = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1294
 *             # sent from the dispatcher
 *             err = unpack_error_message(binary)
 *             self.err(err.message_id, err.error_type, err.error, err.traceback)             # <<<<<<<<<<<<<<
 *         elif to_index == REMOTE_FROM_INDEX:
 *             # sent from remote
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_err, __pyx_n_s_message_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1294, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 1294, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_err, __pyx_n_s_error_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1294, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_err, __pyx_n_s_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1294, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_err, __pyx_n_s_traceback); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1294, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.err(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_v_self), ((PyObject*)__pyx_t_1), __pyx_t_3, __pyx_t_2, __pyx_t_4, 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;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1291
 * 
 *         _, to_index = get_index(binary, None)
 *         if to_index == self.index:             # <<<<<<<<<<<<<<
 *             # sent from the dispatcher
 *             err = unpack_error_message(binary)
 */
    goto __pyx_L3;
  }

  /* "mars/actors/pool/gevent_pool.pyx":1295
 *             err = unpack_error_message(binary)
 *             self.err(err.message_id, err.error_type, err.error, err.traceback)
 *         elif to_index == REMOTE_FROM_INDEX:             # <<<<<<<<<<<<<<
 *             # sent from remote
 *             message_id = unpack_message_id(binary)
 */
  __pyx_t_6 = ((__pyx_v_to_index == __pyx_v_4mars_6actors_4pool_11gevent_pool_REMOTE_FROM_INDEX) != 0);
  if (__pyx_t_6) {

    /* "mars/actors/pool/gevent_pool.pyx":1297
 *         elif to_index == REMOTE_FROM_INDEX:
 *             # sent from remote
 *             message_id = unpack_message_id(binary)             # <<<<<<<<<<<<<<
 *             self.got(message_id, binary)
 *         else:
 */
    if (!(likely(PyBytes_CheckExact(__pyx_v_binary))||((__pyx_v_binary) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_binary)->tp_name), 0))) __PYX_ERR(0, 1297, __pyx_L1_error)
    __pyx_t_4 = __pyx_f_4mars_6actors_4pool_8messages_unpack_message_id(((PyObject*)__pyx_v_binary), 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1297, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_message_id = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1298
 *             # sent from remote
 *             message_id = unpack_message_id(binary)
 *             self.got(message_id, binary)             # <<<<<<<<<<<<<<
 *         else:
 *             # sent from process
 */
    ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.got(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_v_self), __pyx_v_message_id, __pyx_v_binary, 0);

    /* "mars/actors/pool/gevent_pool.pyx":1295
 *             err = unpack_error_message(binary)
 *             self.err(err.message_id, err.error_type, err.error, err.traceback)
 *         elif to_index == REMOTE_FROM_INDEX:             # <<<<<<<<<<<<<<
 *             # sent from remote
 *             message_id = unpack_message_id(binary)
 */
    goto __pyx_L3;
  }

  /* "mars/actors/pool/gevent_pool.pyx":1301
 *         else:
 *             # sent from process
 *             self.pipes[to_index].put(binary)             # <<<<<<<<<<<<<<
 * 
 *     cpdef on_receive(self, bytes binary):
 */
  /*else*/ {
    if (unlikely(__pyx_v_self->pipes == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1301, __pyx_L1_error)
    }
    __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_self->pipes, __pyx_v_to_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1301, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_put); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1301, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_4 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_binary) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_binary);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1301, __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;
  }
  __pyx_L3:;

  /* "mars/actors/pool/gevent_pool.pyx":1285
 *             self.pipes[to_index].put(binary)
 * 
 *     cpdef _on_receive_error(self, binary):             # <<<<<<<<<<<<<<
 *         cdef int to_index
 *         cdef object err
 */

  /* 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("mars.actors.pool.gevent_pool.Dispatcher._on_receive_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_err);
  __Pyx_XDECREF(__pyx_v_message_id);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_19_on_receive_error(PyObject *__pyx_v_self, PyObject *__pyx_v_binary); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_19_on_receive_error(PyObject *__pyx_v_self, PyObject *__pyx_v_binary) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_on_receive_error (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_18_on_receive_error(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self), ((PyObject *)__pyx_v_binary));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_18_on_receive_error(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_binary) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_on_receive_error", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__on_receive_error(__pyx_v_self, __pyx_v_binary, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher._on_receive_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1303
 *             self.pipes[to_index].put(binary)
 * 
 *     cpdef on_receive(self, bytes binary):             # <<<<<<<<<<<<<<
 *         cdef int message_type
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_21on_receive(PyObject *__pyx_v_self, PyObject *__pyx_v_binary); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher_on_receive(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_binary, int __pyx_skip_dispatch) {
  int __pyx_v_message_type;
  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;
  __Pyx_RefNannySetupContext("on_receive", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1303, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_21on_receive)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_binary) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_binary);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1303, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":1306
 *         cdef int message_type
 * 
 *         message_type = unpack_message_type_value(binary)             # <<<<<<<<<<<<<<
 *         return self.handlers[message_type](binary)
 * 
 */
  __pyx_v_message_type = __pyx_f_4mars_6actors_4pool_8messages_unpack_message_type_value(__pyx_v_binary, 0);

  /* "mars/actors/pool/gevent_pool.pyx":1307
 * 
 *         message_type = unpack_message_type_value(binary)
 *         return self.handlers[message_type](binary)             # <<<<<<<<<<<<<<
 * 
 *     def replace_pipe(self, idx):
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(__pyx_v_self->handlers == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1307, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_message_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_self->handlers, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_binary) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_binary);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1307, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1303
 *             self.pipes[to_index].put(binary)
 * 
 *     cpdef on_receive(self, bytes binary):             # <<<<<<<<<<<<<<
 *         cdef int message_type
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.Dispatcher.on_receive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_21on_receive(PyObject *__pyx_v_self, PyObject *__pyx_v_binary); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_21on_receive(PyObject *__pyx_v_self, PyObject *__pyx_v_binary) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("on_receive (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_binary), (&PyBytes_Type), 1, "binary", 1))) __PYX_ERR(0, 1303, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_20on_receive(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self), ((PyObject*)__pyx_v_binary));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_20on_receive(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_binary) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("on_receive", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher_on_receive(__pyx_v_self, __pyx_v_binary, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.on_receive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1309
 *         return self.handlers[message_type](binary)
 * 
 *     def replace_pipe(self, idx):             # <<<<<<<<<<<<<<
 *         new_gl = gevent.spawn(self._check_pipe, self.pipes[idx])
 *         self.checker_group.start(new_gl)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_23replace_pipe(PyObject *__pyx_v_self, PyObject *__pyx_v_idx); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_23replace_pipe(PyObject *__pyx_v_self, PyObject *__pyx_v_idx) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("replace_pipe (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_22replace_pipe(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self), ((PyObject *)__pyx_v_idx));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_22replace_pipe(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_idx) {
  PyObject *__pyx_v_new_gl = 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;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("replace_pipe", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1310
 * 
 *     def replace_pipe(self, idx):
 *         new_gl = gevent.spawn(self._check_pipe, self.pipes[idx])             # <<<<<<<<<<<<<<
 *         self.checker_group.start(new_gl)
 *         self.checker_group.discard(self.pipe_checkers[idx])
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_spawn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_check_pipe); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(__pyx_v_self->pipes == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1310, __pyx_L1_error)
  }
  __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_self->pipes, __pyx_v_idx); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && 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;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_2, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1310, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_2, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1310, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1310, __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_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
    __pyx_t_2 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1310, __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_v_new_gl = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1311
 *     def replace_pipe(self, idx):
 *         new_gl = gevent.spawn(self._check_pipe, self.pipes[idx])
 *         self.checker_group.start(new_gl)             # <<<<<<<<<<<<<<
 *         self.checker_group.discard(self.pipe_checkers[idx])
 *         self.pipe_checkers[idx] = new_gl
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->checker_group, __pyx_n_s_start); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1311, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_7, __pyx_v_new_gl) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_new_gl);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1311, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1312
 *         new_gl = gevent.spawn(self._check_pipe, self.pipes[idx])
 *         self.checker_group.start(new_gl)
 *         self.checker_group.discard(self.pipe_checkers[idx])             # <<<<<<<<<<<<<<
 *         self.pipe_checkers[idx] = new_gl
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->checker_group, __pyx_n_s_discard); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (unlikely(__pyx_v_self->pipe_checkers == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1312, __pyx_L1_error)
  }
  __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_v_self->pipe_checkers, __pyx_v_idx); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1312, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1312, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1313
 *         self.checker_group.start(new_gl)
 *         self.checker_group.discard(self.pipe_checkers[idx])
 *         self.pipe_checkers[idx] = new_gl             # <<<<<<<<<<<<<<
 * 
 *     def _check_pipe(self, pipe):
 */
  if (unlikely(__pyx_v_self->pipe_checkers == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1313, __pyx_L1_error)
  }
  if (unlikely(PyObject_SetItem(__pyx_v_self->pipe_checkers, __pyx_v_idx, __pyx_v_new_gl) < 0)) __PYX_ERR(0, 1313, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1309
 *         return self.handlers[message_type](binary)
 * 
 *     def replace_pipe(self, idx):             # <<<<<<<<<<<<<<
 *         new_gl = gevent.spawn(self._check_pipe, self.pipes[idx])
 *         self.checker_group.start(new_gl)
 */

  /* 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_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.replace_pipe", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_new_gl);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1315
 *         self.pipe_checkers[idx] = new_gl
 * 
 *     def _check_pipe(self, pipe):             # <<<<<<<<<<<<<<
 *         cdef bytes message
 *         while True:
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_25_check_pipe(PyObject *__pyx_v_self, PyObject *__pyx_v_pipe); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_25_check_pipe(PyObject *__pyx_v_self, PyObject *__pyx_v_pipe) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_check_pipe (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_24_check_pipe(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self), ((PyObject *)__pyx_v_pipe));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_24_check_pipe(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v_pipe) {
  PyObject *__pyx_v_message = 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;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("_check_pipe", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1317
 *     def _check_pipe(self, pipe):
 *         cdef bytes message
 *         while True:             # <<<<<<<<<<<<<<
 *             try:
 *                 message = pipe.get()
 */
  while (1) {

    /* "mars/actors/pool/gevent_pool.pyx":1318
 *         cdef bytes message
 *         while True:
 *             try:             # <<<<<<<<<<<<<<
 *                 message = pipe.get()
 *             except EOFError:
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __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:*/ {

        /* "mars/actors/pool/gevent_pool.pyx":1319
 *         while True:
 *             try:
 *                 message = pipe.get()             # <<<<<<<<<<<<<<
 *             except EOFError:
 *                 # broken pipe
 */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_pipe, __pyx_n_s_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1319, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = NULL;
        if (CYTHON_UNPACK_METHODS && 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 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1319, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 1319, __pyx_L5_error)
        __Pyx_XDECREF_SET(__pyx_v_message, ((PyObject*)__pyx_t_4));
        __pyx_t_4 = 0;

        /* "mars/actors/pool/gevent_pool.pyx":1318
 *         cdef bytes message
 *         while True:
 *             try:             # <<<<<<<<<<<<<<
 *                 message = pipe.get()
 *             except EOFError:
 */
      }
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L12_try_end;
      __pyx_L5_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;

      /* "mars/actors/pool/gevent_pool.pyx":1320
 *             try:
 *                 message = pipe.get()
 *             except EOFError:             # <<<<<<<<<<<<<<
 *                 # broken pipe
 *                 return
 */
      __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_EOFError);
      if (__pyx_t_7) {
        __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher._check_pipe", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 1320, __pyx_L7_except_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GOTREF(__pyx_t_6);

        /* "mars/actors/pool/gevent_pool.pyx":1322
 *             except EOFError:
 *                 # broken pipe
 *                 return             # <<<<<<<<<<<<<<
 *             try:
 *                 gevent.spawn(self.on_receive, message)
 */
        __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_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L8_except_return;
      }
      goto __pyx_L7_except_error;
      __pyx_L7_except_error:;

      /* "mars/actors/pool/gevent_pool.pyx":1318
 *         cdef bytes message
 *         while True:
 *             try:             # <<<<<<<<<<<<<<
 *                 message = pipe.get()
 *             except EOFError:
 */
      __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_L8_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;
      __pyx_L12_try_end:;
    }

    /* "mars/actors/pool/gevent_pool.pyx":1323
 *                 # broken pipe
 *                 return
 *             try:             # <<<<<<<<<<<<<<
 *                 gevent.spawn(self.on_receive, message)
 *             except BrokenPipeError:
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_2);
      __Pyx_XGOTREF(__pyx_t_1);
      /*try:*/ {

        /* "mars/actors/pool/gevent_pool.pyx":1324
 *                 return
 *             try:
 *                 gevent.spawn(self.on_receive, message)             # <<<<<<<<<<<<<<
 *             except BrokenPipeError:
 *                 return
 */
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_gevent); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1324, __pyx_L15_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_spawn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1324, __pyx_L15_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1324, __pyx_L15_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_8 = NULL;
        __pyx_t_7 = 0;
        if (CYTHON_UNPACK_METHODS && 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);
            __pyx_t_7 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_5, __pyx_v_message};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1324, __pyx_L15_error)
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_5, __pyx_v_message};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1324, __pyx_L15_error)
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        } else
        #endif
        {
          __pyx_t_9 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1324, __pyx_L15_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_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_7, __pyx_t_5);
          __Pyx_INCREF(__pyx_v_message);
          __Pyx_GIVEREF(__pyx_v_message);
          PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_7, __pyx_v_message);
          __pyx_t_5 = 0;
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1324, __pyx_L15_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "mars/actors/pool/gevent_pool.pyx":1323
 *                 # broken pipe
 *                 return
 *             try:             # <<<<<<<<<<<<<<
 *                 gevent.spawn(self.on_receive, message)
 *             except BrokenPipeError:
 */
      }
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L22_try_end;
      __pyx_L15_error:;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":1325
 *             try:
 *                 gevent.spawn(self.on_receive, message)
 *             except BrokenPipeError:             # <<<<<<<<<<<<<<
 *                 return
 * 
 */
      __Pyx_ErrFetch(&__pyx_t_6, &__pyx_t_4, &__pyx_t_9);
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_BrokenPipeError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1325, __pyx_L17_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_6, __pyx_t_5);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_ErrRestore(__pyx_t_6, __pyx_t_4, __pyx_t_9);
      __pyx_t_6 = 0; __pyx_t_4 = 0; __pyx_t_9 = 0;
      if (__pyx_t_7) {
        __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher._check_pipe", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_4, &__pyx_t_6) < 0) __PYX_ERR(0, 1325, __pyx_L17_except_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_t_6);

        /* "mars/actors/pool/gevent_pool.pyx":1326
 *                 gevent.spawn(self.on_receive, message)
 *             except BrokenPipeError:
 *                 return             # <<<<<<<<<<<<<<
 * 
 *     def run(self):
 */
        __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_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L18_except_return;
      }
      goto __pyx_L17_except_error;
      __pyx_L17_except_error:;

      /* "mars/actors/pool/gevent_pool.pyx":1323
 *                 # broken pipe
 *                 return
 *             try:             # <<<<<<<<<<<<<<
 *                 gevent.spawn(self.on_receive, message)
 *             except BrokenPipeError:
 */
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_2);
      __Pyx_XGIVEREF(__pyx_t_1);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1);
      goto __pyx_L1_error;
      __pyx_L18_except_return:;
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_2);
      __Pyx_XGIVEREF(__pyx_t_1);
      __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1);
      goto __pyx_L0;
      __pyx_L22_try_end:;
    }
  }

  /* "mars/actors/pool/gevent_pool.pyx":1315
 *         self.pipe_checkers[idx] = new_gl
 * 
 *     def _check_pipe(self, pipe):             # <<<<<<<<<<<<<<
 *         cdef bytes message
 *         while True:
 */

  /* 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_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher._check_pipe", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_message);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1328
 *                 return
 * 
 *     def run(self):             # <<<<<<<<<<<<<<
 *         while True:
 *             self.checker_group = gevent.pool.Group()
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_27run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_27run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("run (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_26run(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_4mars_6actors_4pool_11gevent_pool_10Dispatcher_3run_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "mars/actors/pool/gevent_pool.pyx":1337
 *             self.checker_group.join()
 *             gevent.sleep(0.05)
 *             if all(p is None for p in self.pipes):             # <<<<<<<<<<<<<<
 *                 break
 * 
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_3run_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr *)__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr(__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1337, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4mars_6actors_4pool_11gevent_pool_10Dispatcher_3run_2generator, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_run_locals_genexpr, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!gen)) __PYX_ERR(0, 1337, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.run.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_4mars_6actors_4pool_11gevent_pool_10Dispatcher_3run_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr *__pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1337, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1337, __pyx_L1_error) }
  if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->pipes == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 1337, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->pipes; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1337, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1337, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_p);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_p, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_4 = (__pyx_cur_scope->__pyx_v_p == Py_None);
    __pyx_t_5 = ((!(__pyx_t_4 != 0)) != 0);
    if (__pyx_t_5) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
  }
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_True);
    __pyx_r = Py_True;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1328
 *                 return
 * 
 *     def run(self):             # <<<<<<<<<<<<<<
 *         while True:
 *             self.checker_group = gevent.pool.Group()
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_26run(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run *__pyx_cur_scope;
  PyObject *__pyx_v_pipe = NULL;
  PyObject *__pyx_v_gl = 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;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  __Pyx_RefNannySetupContext("run", 0);
  __pyx_cur_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run *)__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run(__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1328, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);

  /* "mars/actors/pool/gevent_pool.pyx":1329
 * 
 *     def run(self):
 *         while True:             # <<<<<<<<<<<<<<
 *             self.checker_group = gevent.pool.Group()
 *             for pipe in self.pipes:
 */
  while (1) {

    /* "mars/actors/pool/gevent_pool.pyx":1330
 *     def run(self):
 *         while True:
 *             self.checker_group = gevent.pool.Group()             # <<<<<<<<<<<<<<
 *             for pipe in self.pipes:
 *                 gl = gevent.spawn(self._check_pipe, pipe)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1330, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_pool); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1330, __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_Group); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1330, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1330, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->checker_group);
    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->checker_group);
    __pyx_cur_scope->__pyx_v_self->checker_group = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1331
 *         while True:
 *             self.checker_group = gevent.pool.Group()
 *             for pipe in self.pipes:             # <<<<<<<<<<<<<<
 *                 gl = gevent.spawn(self._check_pipe, pipe)
 *                 self.pipe_checkers.append(gl)
 */
    if (unlikely(__pyx_cur_scope->__pyx_v_self->pipes == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 1331, __pyx_L1_error)
    }
    __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->pipes; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    for (;;) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 1331, __pyx_L1_error)
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1331, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_pipe, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":1332
 *             self.checker_group = gevent.pool.Group()
 *             for pipe in self.pipes:
 *                 gl = gevent.spawn(self._check_pipe, pipe)             # <<<<<<<<<<<<<<
 *                 self.pipe_checkers.append(gl)
 *                 self.checker_group.start(gl)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_gevent); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1332, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_spawn); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1332, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_check_pipe); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1332, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = NULL;
      __pyx_t_7 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(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_7 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_pipe};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1332, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_pipe};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1332, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      {
        __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1332, __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_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
        __Pyx_INCREF(__pyx_v_pipe);
        __Pyx_GIVEREF(__pyx_v_pipe);
        PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_pipe);
        __pyx_t_3 = 0;
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1332, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF_SET(__pyx_v_gl, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":1333
 *             for pipe in self.pipes:
 *                 gl = gevent.spawn(self._check_pipe, pipe)
 *                 self.pipe_checkers.append(gl)             # <<<<<<<<<<<<<<
 *                 self.checker_group.start(gl)
 *             self.checker_group.join()
 */
      if (unlikely(__pyx_cur_scope->__pyx_v_self->pipe_checkers == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append");
        __PYX_ERR(0, 1333, __pyx_L1_error)
      }
      __pyx_t_9 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_self->pipe_checkers, __pyx_v_gl); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1333, __pyx_L1_error)

      /* "mars/actors/pool/gevent_pool.pyx":1334
 *                 gl = gevent.spawn(self._check_pipe, pipe)
 *                 self.pipe_checkers.append(gl)
 *                 self.checker_group.start(gl)             # <<<<<<<<<<<<<<
 *             self.checker_group.join()
 *             gevent.sleep(0.05)
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->checker_group, __pyx_n_s_start); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && 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_2 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_8, __pyx_v_gl) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_gl);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1334, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":1331
 *         while True:
 *             self.checker_group = gevent.pool.Group()
 *             for pipe in self.pipes:             # <<<<<<<<<<<<<<
 *                 gl = gevent.spawn(self._check_pipe, pipe)
 *                 self.pipe_checkers.append(gl)
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1335
 *                 self.pipe_checkers.append(gl)
 *                 self.checker_group.start(gl)
 *             self.checker_group.join()             # <<<<<<<<<<<<<<
 *             gevent.sleep(0.05)
 *             if all(p is None for p in self.pipes):
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->checker_group, __pyx_n_s_join); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1335, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(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);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1335, __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;

    /* "mars/actors/pool/gevent_pool.pyx":1336
 *                 self.checker_group.start(gl)
 *             self.checker_group.join()
 *             gevent.sleep(0.05)             # <<<<<<<<<<<<<<
 *             if all(p is None for p in self.pipes):
 *                 break
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1336, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_sleep); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1336, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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);
      }
    }
    __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_2, __pyx_float_0_05) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_float_0_05);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1336, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1337
 *             self.checker_group.join()
 *             gevent.sleep(0.05)
 *             if all(p is None for p in self.pipes):             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
    __pyx_t_1 = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_3run_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1337, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_Generator_Next(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1337, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 1337, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_10) {

      /* "mars/actors/pool/gevent_pool.pyx":1338
 *             gevent.sleep(0.05)
 *             if all(p is None for p in self.pipes):
 *                 break             # <<<<<<<<<<<<<<
 * 
 * 
 */
      goto __pyx_L4_break;

      /* "mars/actors/pool/gevent_pool.pyx":1337
 *             self.checker_group.join()
 *             gevent.sleep(0.05)
 *             if all(p is None for p in self.pipes):             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
    }
  }
  __pyx_L4_break:;

  /* "mars/actors/pool/gevent_pool.pyx":1328
 *                 return
 * 
 *     def run(self):             # <<<<<<<<<<<<<<
 *         while True:
 *             self.checker_group = gevent.pool.Group()
 */

  /* 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_8);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.run", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_pipe);
  __Pyx_XDECREF(__pyx_v_gl);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_29__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_29__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_28__reduce_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_28__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.async_results, self.checker_group, self.cluster_info, self.distributor, self.handlers, self.index, self.pipe_checkers, self.pipes, self.remote_handler)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->index); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(9); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.async_results);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.async_results);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->__pyx_base.async_results);
  __Pyx_INCREF(__pyx_v_self->checker_group);
  __Pyx_GIVEREF(__pyx_v_self->checker_group);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->checker_group);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->cluster_info));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->cluster_info));
  PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_self->cluster_info));
  __Pyx_INCREF(__pyx_v_self->distributor);
  __Pyx_GIVEREF(__pyx_v_self->distributor);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_self->distributor);
  __Pyx_INCREF(__pyx_v_self->handlers);
  __Pyx_GIVEREF(__pyx_v_self->handlers);
  PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_v_self->handlers);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 5, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->pipe_checkers);
  __Pyx_GIVEREF(__pyx_v_self->pipe_checkers);
  PyTuple_SET_ITEM(__pyx_t_2, 6, __pyx_v_self->pipe_checkers);
  __Pyx_INCREF(__pyx_v_self->pipes);
  __Pyx_GIVEREF(__pyx_v_self->pipes);
  PyTuple_SET_ITEM(__pyx_t_2, 7, __pyx_v_self->pipes);
  __Pyx_INCREF(__pyx_v_self->remote_handler);
  __Pyx_GIVEREF(__pyx_v_self->remote_handler);
  PyTuple_SET_ITEM(__pyx_t_2, 8, __pyx_v_self->remote_handler);
  __pyx_t_1 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.async_results, self.checker_group, self.cluster_info, self.distributor, self.handlers, self.index, self.pipe_checkers, self.pipes, self.remote_handler)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_2 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v__dict = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "(tree fragment)":7
 *     state = (self.async_results, self.checker_group, self.cluster_info, self.distributor, self.handlers, self.index, self.pipe_checkers, self.pipes, self.remote_handler)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_3 = (__pyx_v__dict != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__dict);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.async_results is not None or self.checker_group is not None or self.cluster_info is not None or self.distributor is not None or self.handlers is not None or self.pipe_checkers is not None or self.pipes is not None or self.remote_handler is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.async_results, self.checker_group, self.cluster_info, self.distributor, self.handlers, self.index, self.pipe_checkers, self.pipes, self.remote_handler)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.async_results is not None or self.checker_group is not None or self.cluster_info is not None or self.distributor is not None or self.handlers is not None or self.pipe_checkers is not None or self.pipes is not None or self.remote_handler is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Dispatcher, (type(self), 0x3781f9c, None), state
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_self->__pyx_base.async_results != ((PyObject*)Py_None));
    __pyx_t_5 = (__pyx_t_3 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->checker_group != Py_None);
    __pyx_t_3 = (__pyx_t_5 != 0);
    if (!__pyx_t_3) {
    } else {
      __pyx_t_4 = __pyx_t_3;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_3 = (((PyObject *)__pyx_v_self->cluster_info) != Py_None);
    __pyx_t_5 = (__pyx_t_3 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->distributor != Py_None);
    __pyx_t_3 = (__pyx_t_5 != 0);
    if (!__pyx_t_3) {
    } else {
      __pyx_t_4 = __pyx_t_3;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_3 = (__pyx_v_self->handlers != ((PyObject*)Py_None));
    __pyx_t_5 = (__pyx_t_3 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->pipe_checkers != ((PyObject*)Py_None));
    __pyx_t_3 = (__pyx_t_5 != 0);
    if (!__pyx_t_3) {
    } else {
      __pyx_t_4 = __pyx_t_3;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_3 = (__pyx_v_self->pipes != ((PyObject*)Py_None));
    __pyx_t_5 = (__pyx_t_3 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->remote_handler != Py_None);
    __pyx_t_3 = (__pyx_t_5 != 0);
    __pyx_t_4 = __pyx_t_3;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_4;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.async_results is not None or self.checker_group is not None or self.cluster_info is not None or self.distributor is not None or self.handlers is not None or self.pipe_checkers is not None or self.pipes is not None or self.remote_handler is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Dispatcher, (type(self), 0x3781f9c, None), state
 *     else:
 */
  __pyx_t_4 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":13
 *         use_setstate = self.async_results is not None or self.checker_group is not None or self.cluster_info is not None or self.distributor is not None or self.handlers is not None or self.pipe_checkers is not None or self.pipes is not None or self.remote_handler is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Dispatcher, (type(self), 0x3781f9c, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Dispatcher, (type(self), 0x3781f9c, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle_Dispatcher); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_58204060);
    __Pyx_GIVEREF(__pyx_int_58204060);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_58204060);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.async_results is not None or self.checker_group is not None or self.cluster_info is not None or self.distributor is not None or self.handlers is not None or self.pipe_checkers is not None or self.pipes is not None or self.remote_handler is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Dispatcher, (type(self), 0x3781f9c, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Dispatcher, (type(self), 0x3781f9c, None), state
 *     else:
 *         return __pyx_unpickle_Dispatcher, (type(self), 0x3781f9c, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Dispatcher__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_Dispatcher); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_58204060);
    __Pyx_GIVEREF(__pyx_int_58204060);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_58204060);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_6 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Dispatcher, (type(self), 0x3781f9c, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Dispatcher__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_31__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_31__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_30__setstate_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10Dispatcher_30__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Dispatcher, (type(self), 0x3781f9c, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Dispatcher__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_Dispatcher__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Dispatcher, (type(self), 0x3781f9c, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Dispatcher__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.Dispatcher.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1346
 *     cdef object server
 * 
 *     def __init__(self, sender, multi_process):             # <<<<<<<<<<<<<<
 *         self.sender = sender
 *         self.multi_process = multi_process
 */

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sender = 0;
  PyObject *__pyx_v_multi_process = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sender,&__pyx_n_s_multi_process,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sender)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_multi_process)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 1346, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1346, __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_sender = values[0];
    __pyx_v_multi_process = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1346, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorServerHandler.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler___init__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *)__pyx_v_self), __pyx_v_sender, __pyx_v_multi_process);

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *__pyx_v_self, PyObject *__pyx_v_sender, PyObject *__pyx_v_multi_process) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1347
 * 
 *     def __init__(self, sender, multi_process):
 *         self.sender = sender             # <<<<<<<<<<<<<<
 *         self.multi_process = multi_process
 *         self.server = None
 */
  __Pyx_INCREF(__pyx_v_sender);
  __Pyx_GIVEREF(__pyx_v_sender);
  __Pyx_GOTREF(__pyx_v_self->sender);
  __Pyx_DECREF(__pyx_v_self->sender);
  __pyx_v_self->sender = __pyx_v_sender;

  /* "mars/actors/pool/gevent_pool.pyx":1348
 *     def __init__(self, sender, multi_process):
 *         self.sender = sender
 *         self.multi_process = multi_process             # <<<<<<<<<<<<<<
 *         self.server = None
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_multi_process); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1348, __pyx_L1_error)
  __pyx_v_self->multi_process = __pyx_t_1;

  /* "mars/actors/pool/gevent_pool.pyx":1349
 *         self.sender = sender
 *         self.multi_process = multi_process
 *         self.server = None             # <<<<<<<<<<<<<<
 * 
 *     def set_server(self, server):
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->server);
  __Pyx_DECREF(__pyx_v_self->server);
  __pyx_v_self->server = Py_None;

  /* "mars/actors/pool/gevent_pool.pyx":1346
 *     cdef object server
 * 
 *     def __init__(self, sender, multi_process):             # <<<<<<<<<<<<<<
 *         self.sender = sender
 *         self.multi_process = multi_process
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorServerHandler.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1351
 *         self.server = None
 * 
 *     def set_server(self, server):             # <<<<<<<<<<<<<<
 *         self.server = weakref.ref(server)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_3set_server(PyObject *__pyx_v_self, PyObject *__pyx_v_server); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_3set_server(PyObject *__pyx_v_self, PyObject *__pyx_v_server) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_server (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_2set_server(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *)__pyx_v_self), ((PyObject *)__pyx_v_server));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_2set_server(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *__pyx_v_self, PyObject *__pyx_v_server) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("set_server", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1352
 * 
 *     def set_server(self, server):
 *         self.server = weakref.ref(server)             # <<<<<<<<<<<<<<
 * 
 *     def on_receive(self, bytes binary):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_weakref); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ref); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_server) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_server);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->server);
  __Pyx_DECREF(__pyx_v_self->server);
  __pyx_v_self->server = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1351
 *         self.server = None
 * 
 *     def set_server(self, server):             # <<<<<<<<<<<<<<
 *         self.server = weakref.ref(server)
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.ActorServerHandler.set_server", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1354
 *         self.server = weakref.ref(server)
 * 
 *     def on_receive(self, bytes binary):             # <<<<<<<<<<<<<<
 *         if not self.multi_process:
 *             return self.sender.on_receive(binary, callback=lambda x: x)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_5on_receive(PyObject *__pyx_v_self, PyObject *__pyx_v_binary); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_5on_receive(PyObject *__pyx_v_self, PyObject *__pyx_v_binary) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("on_receive (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_binary), (&PyBytes_Type), 1, "binary", 1))) __PYX_ERR(0, 1354, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_4on_receive(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *)__pyx_v_self), ((PyObject*)__pyx_v_binary));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1356
 *     def on_receive(self, bytes binary):
 *         if not self.multi_process:
 *             return self.sender.on_receive(binary, callback=lambda x: x)             # <<<<<<<<<<<<<<
 *         else:
 *             return self.sender.on_receive(binary)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_10on_receive_lambda1(PyObject *__pyx_self, PyObject *__pyx_v_x); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_10on_receive_lambda1 = {"lambda1", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_10on_receive_lambda1, METH_O, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_10on_receive_lambda1(PyObject *__pyx_self, PyObject *__pyx_v_x) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lambda1 (wrapper)", 0);
  __pyx_r = __pyx_lambda_funcdef_lambda1(__pyx_self, ((PyObject *)__pyx_v_x));

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

static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lambda1", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_x);
  __pyx_r = __pyx_v_x;
  goto __pyx_L0;

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

/* "mars/actors/pool/gevent_pool.pyx":1354
 *         self.server = weakref.ref(server)
 * 
 *     def on_receive(self, bytes binary):             # <<<<<<<<<<<<<<
 *         if not self.multi_process:
 *             return self.sender.on_receive(binary, callback=lambda x: x)
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_4on_receive(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *__pyx_v_self, PyObject *__pyx_v_binary) {
  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;
  __Pyx_RefNannySetupContext("on_receive", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1355
 * 
 *     def on_receive(self, bytes binary):
 *         if not self.multi_process:             # <<<<<<<<<<<<<<
 *             return self.sender.on_receive(binary, callback=lambda x: x)
 *         else:
 */
  __pyx_t_1 = ((!(__pyx_v_self->multi_process != 0)) != 0);
  if (__pyx_t_1) {

    /* "mars/actors/pool/gevent_pool.pyx":1356
 *     def on_receive(self, bytes binary):
 *         if not self.multi_process:
 *             return self.sender.on_receive(binary, callback=lambda x: x)             # <<<<<<<<<<<<<<
 *         else:
 *             return self.sender.on_receive(binary)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->sender, __pyx_n_s_on_receive); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_binary);
    __Pyx_GIVEREF(__pyx_v_binary);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_binary);
    __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_10on_receive_lambda1, 0, __pyx_n_s_on_receive_locals_lambda, NULL, __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_callback, __pyx_t_5) < 0) __PYX_ERR(0, 1356, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":1355
 * 
 *     def on_receive(self, bytes binary):
 *         if not self.multi_process:             # <<<<<<<<<<<<<<
 *             return self.sender.on_receive(binary, callback=lambda x: x)
 *         else:
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1358
 *             return self.sender.on_receive(binary, callback=lambda x: x)
 *         else:
 *             return self.sender.on_receive(binary)             # <<<<<<<<<<<<<<
 * 
 *     def __call__(self, sock, address):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->sender, __pyx_n_s_on_receive); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1358, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_5 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_v_binary) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_binary);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1358, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;
  }

  /* "mars/actors/pool/gevent_pool.pyx":1354
 *         self.server = weakref.ref(server)
 * 
 *     def on_receive(self, bytes binary):             # <<<<<<<<<<<<<<
 *         if not self.multi_process:
 *             return self.sender.on_receive(binary, callback=lambda x: x)
 */

  /* 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("mars.actors.pool.gevent_pool.ActorServerHandler.on_receive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1360
 *             return self.sender.on_receive(binary)
 * 
 *     def __call__(self, sock, address):             # <<<<<<<<<<<<<<
 *         cdef bytes binary
 *         cdef object p
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_7__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_7__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sock = 0;
  CYTHON_UNUSED PyObject *__pyx_v_address = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sock,&__pyx_n_s_address,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sock)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_address)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); __PYX_ERR(0, 1360, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) __PYX_ERR(0, 1360, __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_sock = values[0];
    __pyx_v_address = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1360, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorServerHandler.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_6__call__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *)__pyx_v_self), __pyx_v_sock, __pyx_v_address);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_6__call__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *__pyx_v_self, PyObject *__pyx_v_sock, CYTHON_UNUSED PyObject *__pyx_v_address) {
  PyObject *__pyx_v_binary = 0;
  PyObject *__pyx_v_p = 0;
  PyObject *__pyx_v_server = 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;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_RefNannySetupContext("__call__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1364
 *         cdef object p
 * 
 *         server = self.server()             # <<<<<<<<<<<<<<
 *         if server:
 *             server.add_sock(sock)
 */
  __Pyx_INCREF(__pyx_v_self->server);
  __pyx_t_2 = __pyx_v_self->server; __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_server = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1365
 * 
 *         server = self.server()
 *         if server:             # <<<<<<<<<<<<<<
 *             server.add_sock(sock)
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_server); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1365, __pyx_L1_error)
  if (__pyx_t_4) {

    /* "mars/actors/pool/gevent_pool.pyx":1366
 *         server = self.server()
 *         if server:
 *             server.add_sock(sock)             # <<<<<<<<<<<<<<
 * 
 *         while True:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_server, __pyx_n_s_add_sock); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_sock) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_sock);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1366, __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;

    /* "mars/actors/pool/gevent_pool.pyx":1365
 * 
 *         server = self.server()
 *         if server:             # <<<<<<<<<<<<<<
 *             server.add_sock(sock)
 * 
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1368
 *             server.add_sock(sock)
 * 
 *         while True:             # <<<<<<<<<<<<<<
 *             try:
 *                 binary = read_remote_message(sock.recv)
 */
  while (1) {

    /* "mars/actors/pool/gevent_pool.pyx":1369
 * 
 *         while True:
 *             try:             # <<<<<<<<<<<<<<
 *                 binary = read_remote_message(sock.recv)
 *                 p = gevent.spawn(self.on_receive, binary)
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      /*try:*/ {

        /* "mars/actors/pool/gevent_pool.pyx":1370
 *         while True:
 *             try:
 *                 binary = read_remote_message(sock.recv)             # <<<<<<<<<<<<<<
 *                 p = gevent.spawn(self.on_receive, binary)
 *                 write_remote_message(sock.sendall, p.get())
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sock, __pyx_n_s_recv); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1370, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_f_4mars_6actors_4pool_8messages_read_remote_message(__pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1370, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF_SET(__pyx_v_binary, ((PyObject*)__pyx_t_2));
        __pyx_t_2 = 0;

        /* "mars/actors/pool/gevent_pool.pyx":1371
 *             try:
 *                 binary = read_remote_message(sock.recv)
 *                 p = gevent.spawn(self.on_receive, binary)             # <<<<<<<<<<<<<<
 *                 write_remote_message(sock.sendall, p.get())
 *             except (gevent.socket.error, struct.error):
 */
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1371, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_spawn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1371, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_receive); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1371, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_8 = NULL;
        __pyx_t_9 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_8)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
            __pyx_t_9 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_1, __pyx_v_binary};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1371, __pyx_L6_error)
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_1, __pyx_v_binary};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1371, __pyx_L6_error)
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        {
          __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1371, __pyx_L6_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_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_1);
          __Pyx_INCREF(__pyx_v_binary);
          __Pyx_GIVEREF(__pyx_v_binary);
          PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_v_binary);
          __pyx_t_1 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1371, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_2);
        __pyx_t_2 = 0;

        /* "mars/actors/pool/gevent_pool.pyx":1372
 *                 binary = read_remote_message(sock.recv)
 *                 p = gevent.spawn(self.on_receive, binary)
 *                 write_remote_message(sock.sendall, p.get())             # <<<<<<<<<<<<<<
 *             except (gevent.socket.error, struct.error):
 *                 break
 */
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_write_remote_message); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1372, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_sock, __pyx_n_s_sendall); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1372, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_get); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1372, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_11 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_11)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_11);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
          }
        }
        __pyx_t_1 = (__pyx_t_11) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_11) : __Pyx_PyObject_CallNoArg(__pyx_t_8);
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1372, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = NULL;
        __pyx_t_9 = 0;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_8)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
            __pyx_t_9 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_10, __pyx_t_1};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1372, __pyx_L6_error)
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_10, __pyx_t_1};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1372, __pyx_L6_error)
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1372, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_11);
          if (__pyx_t_8) {
            __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_8); __pyx_t_8 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_t_1);
          __pyx_t_10 = 0;
          __pyx_t_1 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1372, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "mars/actors/pool/gevent_pool.pyx":1369
 * 
 *         while True:
 *             try:             # <<<<<<<<<<<<<<
 *                 binary = read_remote_message(sock.recv)
 *                 p = gevent.spawn(self.on_receive, binary)
 */
      }
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L13_try_end;
      __pyx_L6_error:;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":1373
 *                 p = gevent.spawn(self.on_receive, binary)
 *                 write_remote_message(sock.sendall, p.get())
 *             except (gevent.socket.error, struct.error):             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
      __Pyx_ErrFetch(&__pyx_t_2, &__pyx_t_3, &__pyx_t_11);
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1373, __pyx_L8_except_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_socket); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1373, __pyx_L8_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1373, __pyx_L8_except_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_struct); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1373, __pyx_L8_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_error); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1373, __pyx_L8_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_9 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_2, __pyx_t_1) || __Pyx_PyErr_GivenExceptionMatches(__pyx_t_2, __pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_ErrRestore(__pyx_t_2, __pyx_t_3, __pyx_t_11);
      __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_11 = 0;
      if (__pyx_t_9) {
        __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorServerHandler.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 1373, __pyx_L8_except_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_2);

        /* "mars/actors/pool/gevent_pool.pyx":1374
 *                 write_remote_message(sock.sendall, p.get())
 *             except (gevent.socket.error, struct.error):
 *                 break             # <<<<<<<<<<<<<<
 * 
 * 
 */
        goto __pyx_L14_except_break;
        __pyx_L14_except_break:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        goto __pyx_L11_try_break;
      }
      goto __pyx_L8_except_error;
      __pyx_L8_except_error:;

      /* "mars/actors/pool/gevent_pool.pyx":1369
 * 
 *         while True:
 *             try:             # <<<<<<<<<<<<<<
 *                 binary = read_remote_message(sock.recv)
 *                 p = gevent.spawn(self.on_receive, binary)
 */
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
      goto __pyx_L1_error;
      __pyx_L11_try_break:;
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
      goto __pyx_L5_break;
      __pyx_L13_try_end:;
    }
  }
  __pyx_L5_break:;

  /* "mars/actors/pool/gevent_pool.pyx":1360
 *             return self.sender.on_receive(binary)
 * 
 *     def __call__(self, sock, address):             # <<<<<<<<<<<<<<
 *         cdef bytes binary
 *         cdef object p
 */

  /* 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_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorServerHandler.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_binary);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_server);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_8__reduce_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_8__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.multi_process, self.sender, self.server)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->multi_process); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __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(__pyx_v_self->sender);
  __Pyx_GIVEREF(__pyx_v_self->sender);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->sender);
  __Pyx_INCREF(__pyx_v_self->server);
  __Pyx_GIVEREF(__pyx_v_self->server);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_self->server);
  __pyx_t_1 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.multi_process, self.sender, self.server)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_2 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v__dict = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "(tree fragment)":7
 *     state = (self.multi_process, self.sender, self.server)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_3 = (__pyx_v__dict != Py_None);
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v__dict);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.sender is not None or self.server is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.multi_process, self.sender, self.server)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.sender is not None or self.server is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_ActorServerHandler, (type(self), 0x061f3cd, None), state
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_self->sender != Py_None);
    __pyx_t_5 = (__pyx_t_3 != 0);
    if (!__pyx_t_5) {
    } else {
      __pyx_t_4 = __pyx_t_5;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_5 = (__pyx_v_self->server != Py_None);
    __pyx_t_3 = (__pyx_t_5 != 0);
    __pyx_t_4 = __pyx_t_3;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_4;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.sender is not None or self.server is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ActorServerHandler, (type(self), 0x061f3cd, None), state
 *     else:
 */
  __pyx_t_4 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_4) {

    /* "(tree fragment)":13
 *         use_setstate = self.sender is not None or self.server is not None
 *     if use_setstate:
 *         return __pyx_unpickle_ActorServerHandler, (type(self), 0x061f3cd, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_ActorServerHandler, (type(self), 0x061f3cd, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle_ActorServerHandle); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_6419405);
    __Pyx_GIVEREF(__pyx_int_6419405);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_6419405);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_2, 2, Py_None);
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_state);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.sender is not None or self.server is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ActorServerHandler, (type(self), 0x061f3cd, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_ActorServerHandler, (type(self), 0x061f3cd, None), state
 *     else:
 *         return __pyx_unpickle_ActorServerHandler, (type(self), 0x061f3cd, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ActorServerHandler__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pyx_unpickle_ActorServerHandle); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_6419405);
    __Pyx_GIVEREF(__pyx_int_6419405);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_6419405);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_state);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __pyx_t_6 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorServerHandler.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ActorServerHandler, (type(self), 0x061f3cd, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ActorServerHandler__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_10__setstate_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_10__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_ActorServerHandler, (type(self), 0x061f3cd, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ActorServerHandler__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorServerHandler__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ActorServerHandler, (type(self), 0x061f3cd, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ActorServerHandler__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorServerHandler.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1378
 * 
 * class ActorStreamServer(gevent.server.StreamServer):
 *     def __init__(self, listener, handler):             # <<<<<<<<<<<<<<
 *         super(ActorStreamServer, self).__init__(listener, handler)
 *         self._socks = []
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_listener = 0;
  PyObject *__pyx_v_handler = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_listener,&__pyx_n_s_handler,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_listener)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); __PYX_ERR(0, 1378, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_handler)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); __PYX_ERR(0, 1378, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1378, __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_listener = values[1];
    __pyx_v_handler = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1378, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorStreamServer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer___init__(__pyx_self, __pyx_v_self, __pyx_v_listener, __pyx_v_handler);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_listener, PyObject *__pyx_v_handler) {
  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;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1379
 * class ActorStreamServer(gevent.server.StreamServer):
 *     def __init__(self, listener, handler):
 *         super(ActorStreamServer, self).__init__(listener, handler)             # <<<<<<<<<<<<<<
 *         self._socks = []
 *         handler.set_server(self)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ActorStreamServer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1379, __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_ERR(0, 1379, __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_ERR(0, 1379, __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_UNPACK_METHODS && 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);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_listener, __pyx_v_handler};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1379, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_listener, __pyx_v_handler};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1379, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1379, __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_v_listener);
    __Pyx_GIVEREF(__pyx_v_listener);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_listener);
    __Pyx_INCREF(__pyx_v_handler);
    __Pyx_GIVEREF(__pyx_v_handler);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_handler);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1379, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1380
 *     def __init__(self, listener, handler):
 *         super(ActorStreamServer, self).__init__(listener, handler)
 *         self._socks = []             # <<<<<<<<<<<<<<
 *         handler.set_server(self)
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_socks, __pyx_t_1) < 0) __PYX_ERR(0, 1380, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1381
 *         super(ActorStreamServer, self).__init__(listener, handler)
 *         self._socks = []
 *         handler.set_server(self)             # <<<<<<<<<<<<<<
 * 
 *     def add_sock(self, sock):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_handler, __pyx_n_s_set_server); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1381, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(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_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_v_self) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1381, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1378
 * 
 * class ActorStreamServer(gevent.server.StreamServer):
 *     def __init__(self, listener, handler):             # <<<<<<<<<<<<<<
 *         super(ActorStreamServer, self).__init__(listener, handler)
 *         self._socks = []
 */

  /* 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("mars.actors.pool.gevent_pool.ActorStreamServer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1383
 *         handler.set_server(self)
 * 
 *     def add_sock(self, sock):             # <<<<<<<<<<<<<<
 *         self._socks.append(sock)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer_3add_sock(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer_3add_sock = {"add_sock", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer_3add_sock, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer_3add_sock(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_sock = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_sock (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_sock,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sock)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_sock", 1, 2, 2, 1); __PYX_ERR(0, 1383, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_sock") < 0)) __PYX_ERR(0, 1383, __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_sock = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_sock", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1383, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorStreamServer.add_sock", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer_2add_sock(__pyx_self, __pyx_v_self, __pyx_v_sock);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer_2add_sock(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_sock) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("add_sock", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1384
 * 
 *     def add_sock(self, sock):
 *         self._socks.append(sock)             # <<<<<<<<<<<<<<
 * 
 *     def close(self):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_socks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_v_sock); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1384, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1383
 *         handler.set_server(self)
 * 
 *     def add_sock(self, sock):             # <<<<<<<<<<<<<<
 *         self._socks.append(sock)
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorStreamServer.add_sock", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1386
 *         self._socks.append(sock)
 * 
 *     def close(self):             # <<<<<<<<<<<<<<
 *         super(ActorStreamServer, self).close()
 *         [sock.close() for sock in self._socks]
 */

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

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer_4close(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_sock = 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;
  __Pyx_RefNannySetupContext("close", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1387
 * 
 *     def close(self):
 *         super(ActorStreamServer, self).close()             # <<<<<<<<<<<<<<
 *         [sock.close() for sock in self._socks]
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ActorStreamServer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1387, __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_ERR(0, 1387, __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_close); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1387, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1387, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1388
 *     def close(self):
 *         super(ActorStreamServer, self).close()
 *         [sock.close() for sock in self._socks]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_socks); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1388, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_2 = __pyx_t_3; __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_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1388, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1388, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 1388, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1388, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 1388, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1388, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 1388, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_sock, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_sock, __pyx_n_s_close); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1388, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1388, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 1388, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1386
 *         self._socks.append(sock)
 * 
 *     def close(self):             # <<<<<<<<<<<<<<
 *         super(ActorStreamServer, self).close()
 *         [sock.close() for sock in self._socks]
 */

  /* 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_AddTraceback("mars.actors.pool.gevent_pool.ActorStreamServer.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_sock);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1391
 * 
 * 
 * cpdef object start_actor_server(ClusterInfo cluster_info, object sender):             # <<<<<<<<<<<<<<
 *     cdef str address
 *     cdef int port
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_1start_actor_server(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_start_actor_server(struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *__pyx_v_cluster_info, PyObject *__pyx_v_sender, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_address = 0;
  int __pyx_v_port;
  int __pyx_v_multi_process;
  PyObject *__pyx_v_s = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  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;
  __Pyx_RefNannySetupContext("start_actor_server", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1397
 *     cdef object s
 * 
 *     address, port = cluster_info.location, cluster_info.port             # <<<<<<<<<<<<<<
 *     if address is None or port is None:
 *         raise ValueError('Both address and port should be provided')
 */
  __pyx_t_1 = __pyx_v_cluster_info->location;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __pyx_v_cluster_info->port;
  __pyx_v_address = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_port = __pyx_t_2;

  /* "mars/actors/pool/gevent_pool.pyx":1398
 * 
 *     address, port = cluster_info.location, cluster_info.port
 *     if address is None or port is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('Both address and port should be provided')
 *     multi_process = cluster_info.n_process > 1
 */
  __pyx_t_4 = (__pyx_v_address == ((PyObject*)Py_None));
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_port); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = (__pyx_t_1 == Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_4;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_3)) {

    /* "mars/actors/pool/gevent_pool.pyx":1399
 *     address, port = cluster_info.location, cluster_info.port
 *     if address is None or port is None:
 *         raise ValueError('Both address and port should be provided')             # <<<<<<<<<<<<<<
 *     multi_process = cluster_info.n_process > 1
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1399, __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_ERR(0, 1399, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":1398
 * 
 *     address, port = cluster_info.location, cluster_info.port
 *     if address is None or port is None:             # <<<<<<<<<<<<<<
 *         raise ValueError('Both address and port should be provided')
 *     multi_process = cluster_info.n_process > 1
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1400
 *     if address is None or port is None:
 *         raise ValueError('Both address and port should be provided')
 *     multi_process = cluster_info.n_process > 1             # <<<<<<<<<<<<<<
 * 
 *     s = ActorStreamServer((address, port), ActorServerHandler(sender, multi_process))
 */
  __pyx_v_multi_process = (__pyx_v_cluster_info->n_process > 1);

  /* "mars/actors/pool/gevent_pool.pyx":1402
 *     multi_process = cluster_info.n_process > 1
 * 
 *     s = ActorStreamServer((address, port), ActorServerHandler(sender, multi_process))             # <<<<<<<<<<<<<<
 *     s.start()
 *     return s
 */
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_ActorStreamServer); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_port); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_v_address);
  __Pyx_GIVEREF(__pyx_v_address);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_address);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_multi_process); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_v_sender);
  __Pyx_GIVEREF(__pyx_v_sender);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_sender);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorServerHandler), __pyx_t_9, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = NULL;
  __pyx_t_2 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_2 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_8, __pyx_t_7};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_2, 2+__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1402, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_8, __pyx_t_7};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_2, 2+__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1402, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(2+__pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1402, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_9) {
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_2, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_2, __pyx_t_7);
    __pyx_t_8 = 0;
    __pyx_t_7 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1402, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_s = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1403
 * 
 *     s = ActorStreamServer((address, port), ActorServerHandler(sender, multi_process))
 *     s.start()             # <<<<<<<<<<<<<<
 *     return s
 * 
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_start); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_1 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1404
 *     s = ActorStreamServer((address, port), ActorServerHandler(sender, multi_process))
 *     s.start()
 *     return s             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_s);
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1391
 * 
 * 
 * cpdef object start_actor_server(ClusterInfo cluster_info, object sender):             # <<<<<<<<<<<<<<
 *     cdef str address
 *     cdef int port
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.start_actor_server", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_address);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_1start_actor_server(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_1start_actor_server(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *__pyx_v_cluster_info = 0;
  PyObject *__pyx_v_sender = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("start_actor_server (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cluster_info,&__pyx_n_s_sender,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);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cluster_info)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sender)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("start_actor_server", 1, 2, 2, 1); __PYX_ERR(0, 1391, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "start_actor_server") < 0)) __PYX_ERR(0, 1391, __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_cluster_info = ((struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *)values[0]);
    __pyx_v_sender = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("start_actor_server", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1391, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.start_actor_server", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cluster_info), __pyx_ptype_4mars_6actors_7cluster_ClusterInfo, 1, "cluster_info", 0))) __PYX_ERR(0, 1391, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_start_actor_server(__pyx_self, __pyx_v_cluster_info, __pyx_v_sender);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_start_actor_server(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *__pyx_v_cluster_info, PyObject *__pyx_v_sender) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("start_actor_server", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_start_actor_server(__pyx_v_cluster_info, __pyx_v_sender, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1391, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.start_actor_server", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1407
 * 
 * 
 * def start_local_pool(int index, ClusterInfo cluster_info,             # <<<<<<<<<<<<<<
 *                      object pipe=None, Distributor distributor=None,
 *                      object parallel=None, bint join=False):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_3start_local_pool(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_3start_local_pool = {"start_local_pool", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_3start_local_pool, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_3start_local_pool(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *__pyx_v_cluster_info = 0;
  PyObject *__pyx_v_pipe = 0;
  struct __pyx_obj_4mars_6actors_11distributor_Distributor *__pyx_v_distributor = 0;
  PyObject *__pyx_v_parallel = 0;
  int __pyx_v_join;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("start_local_pool (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_index,&__pyx_n_s_cluster_info,&__pyx_n_s_pipe,&__pyx_n_s_distributor,&__pyx_n_s_parallel,&__pyx_n_s_join,0};
    PyObject* values[6] = {0,0,0,0,0,0};

    /* "mars/actors/pool/gevent_pool.pyx":1408
 * 
 * def start_local_pool(int index, ClusterInfo cluster_info,
 *                      object pipe=None, Distributor distributor=None,             # <<<<<<<<<<<<<<
 *                      object parallel=None, bint join=False):
 *     # new process will pickle the numpy RandomState, we seed the random one
 */
    values[2] = ((PyObject *)Py_None);
    values[3] = (PyObject *)((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)Py_None);

    /* "mars/actors/pool/gevent_pool.pyx":1409
 * def start_local_pool(int index, ClusterInfo cluster_info,
 *                      object pipe=None, Distributor distributor=None,
 *                      object parallel=None, bint join=False):             # <<<<<<<<<<<<<<
 *     # new process will pickle the numpy RandomState, we seed the random one
 *     import numpy as np
 */
    values[4] = ((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  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_index)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cluster_info)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("start_local_pool", 0, 2, 6, 1); __PYX_ERR(0, 1407, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pipe);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_distributor);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_parallel);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_join);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "start_local_pool") < 0)) __PYX_ERR(0, 1407, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        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_index = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1407, __pyx_L3_error)
    __pyx_v_cluster_info = ((struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *)values[1]);
    __pyx_v_pipe = values[2];
    __pyx_v_distributor = ((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)values[3]);
    __pyx_v_parallel = values[4];
    if (values[5]) {
      __pyx_v_join = __Pyx_PyObject_IsTrue(values[5]); if (unlikely((__pyx_v_join == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1409, __pyx_L3_error)
    } else {
      __pyx_v_join = ((int)0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("start_local_pool", 0, 2, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1407, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.start_local_pool", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cluster_info), __pyx_ptype_4mars_6actors_7cluster_ClusterInfo, 1, "cluster_info", 0))) __PYX_ERR(0, 1407, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distributor), __pyx_ptype_4mars_6actors_11distributor_Distributor, 1, "distributor", 0))) __PYX_ERR(0, 1408, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_2start_local_pool(__pyx_self, __pyx_v_index, __pyx_v_cluster_info, __pyx_v_pipe, __pyx_v_distributor, __pyx_v_parallel, __pyx_v_join);

  /* "mars/actors/pool/gevent_pool.pyx":1407
 * 
 * 
 * def start_local_pool(int index, ClusterInfo cluster_info,             # <<<<<<<<<<<<<<
 *                      object pipe=None, Distributor distributor=None,
 *                      object parallel=None, bint join=False):
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_2start_local_pool(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_index, struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *__pyx_v_cluster_info, PyObject *__pyx_v_pipe, struct __pyx_obj_4mars_6actors_11distributor_Distributor *__pyx_v_distributor, PyObject *__pyx_v_parallel, int __pyx_v_join) {
  PyObject *__pyx_v_np = NULL;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v_local_pool = NULL;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v_comm = NULL;
  PyObject *__pyx_v_p = 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;
  __Pyx_RefNannySetupContext("start_local_pool", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1411
 *                      object parallel=None, bint join=False):
 *     # new process will pickle the numpy RandomState, we seed the random one
 *     import numpy as np             # <<<<<<<<<<<<<<
 *     np.random.seed()
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1411, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_np = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1412
 *     # new process will pickle the numpy RandomState, we seed the random one
 *     import numpy as np
 *     np.random.seed()             # <<<<<<<<<<<<<<
 * 
 *     # gevent.signal(signal.SIGINT, lambda *_: None)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_np, __pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_seed); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1412, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1419
 *     # we start a local pool to handle messages
 *     # and a communicator to do the redirection of messages
 *     local_pool = LocalActorPool(cluster_info.address, index)             # <<<<<<<<<<<<<<
 *     comm = Communicator(local_pool, cluster_info, pipe, distributor, parallel)
 *     local_pool.set_comm(comm)
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_cluster_info->address);
  __Pyx_GIVEREF(__pyx_v_cluster_info->address);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_cluster_info->address);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_LocalActorPool), __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_local_pool = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1420
 *     # and a communicator to do the redirection of messages
 *     local_pool = LocalActorPool(cluster_info.address, index)
 *     comm = Communicator(local_pool, cluster_info, pipe, distributor, parallel)             # <<<<<<<<<<<<<<
 *     local_pool.set_comm(comm)
 *     p = gevent.spawn(comm.run)
 */
  __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_local_pool));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_local_pool));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_local_pool));
  __Pyx_INCREF(((PyObject *)__pyx_v_cluster_info));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_cluster_info));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_cluster_info));
  __Pyx_INCREF(__pyx_v_pipe);
  __Pyx_GIVEREF(__pyx_v_pipe);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_pipe);
  __Pyx_INCREF(((PyObject *)__pyx_v_distributor));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_distributor));
  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_v_distributor));
  __Pyx_INCREF(__pyx_v_parallel);
  __Pyx_GIVEREF(__pyx_v_parallel);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_v_parallel);
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_Communicator), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_comm = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1421
 *     local_pool = LocalActorPool(cluster_info.address, index)
 *     comm = Communicator(local_pool, cluster_info, pipe, distributor, parallel)
 *     local_pool.set_comm(comm)             # <<<<<<<<<<<<<<
 *     p = gevent.spawn(comm.run)
 *     if join:
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v_local_pool->__pyx_vtab)->set_comm(__pyx_v_local_pool, ((PyObject *)__pyx_v_comm), 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1422
 *     comm = Communicator(local_pool, cluster_info, pipe, distributor, parallel)
 *     local_pool.set_comm(comm)
 *     p = gevent.spawn(comm.run)             # <<<<<<<<<<<<<<
 *     if join:
 *         p.get()
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_spawn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_comm), __pyx_n_s_run); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_p = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1423
 *     local_pool.set_comm(comm)
 *     p = gevent.spawn(comm.run)
 *     if join:             # <<<<<<<<<<<<<<
 *         p.get()
 *     else:
 */
  __pyx_t_5 = (__pyx_v_join != 0);
  if (__pyx_t_5) {

    /* "mars/actors/pool/gevent_pool.pyx":1424
 *     p = gevent.spawn(comm.run)
 *     if join:
 *         p.get()             # <<<<<<<<<<<<<<
 *     else:
 *         return comm
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1424, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1424, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1423
 *     local_pool.set_comm(comm)
 *     p = gevent.spawn(comm.run)
 *     if join:             # <<<<<<<<<<<<<<
 *         p.get()
 *     else:
 */
    goto __pyx_L3;
  }

  /* "mars/actors/pool/gevent_pool.pyx":1426
 *         p.get()
 *     else:
 *         return comm             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_comm));
    __pyx_r = ((PyObject *)__pyx_v_comm);
    goto __pyx_L0;
  }
  __pyx_L3:;

  /* "mars/actors/pool/gevent_pool.pyx":1407
 * 
 * 
 * def start_local_pool(int index, ClusterInfo cluster_info,             # <<<<<<<<<<<<<<
 *                      object pipe=None, Distributor distributor=None,
 *                      object parallel=None, bint join=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_AddTraceback("mars.actors.pool.gevent_pool.start_local_pool", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_np);
  __Pyx_XDECREF((PyObject *)__pyx_v_local_pool);
  __Pyx_XDECREF((PyObject *)__pyx_v_comm);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1429
 * 
 * 
 * def close_pipe(p):             # <<<<<<<<<<<<<<
 *     if p is None:
 *         return
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_5close_pipe(PyObject *__pyx_self, PyObject *__pyx_v_p); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_5close_pipe = {"close_pipe", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_5close_pipe, METH_O, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_5close_pipe(PyObject *__pyx_self, PyObject *__pyx_v_p) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("close_pipe (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_4close_pipe(__pyx_self, ((PyObject *)__pyx_v_p));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_4close_pipe(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_p) {
  CYTHON_UNUSED long __pyx_v__;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  long __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;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  __Pyx_RefNannySetupContext("close_pipe", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1430
 * 
 * def close_pipe(p):
 *     if p is None:             # <<<<<<<<<<<<<<
 *         return
 *     for _ in range(3):
 */
  __pyx_t_1 = (__pyx_v_p == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "mars/actors/pool/gevent_pool.pyx":1431
 * def close_pipe(p):
 *     if p is None:
 *         return             # <<<<<<<<<<<<<<
 *     for _ in range(3):
 *         try:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":1430
 * 
 * def close_pipe(p):
 *     if p is None:             # <<<<<<<<<<<<<<
 *         return
 *     for _ in range(3):
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1432
 *     if p is None:
 *         return
 *     for _ in range(3):             # <<<<<<<<<<<<<<
 *         try:
 *             p.close()
 */
  for (__pyx_t_3 = 0; __pyx_t_3 < 3; __pyx_t_3+=1) {
    __pyx_v__ = __pyx_t_3;

    /* "mars/actors/pool/gevent_pool.pyx":1433
 *         return
 *     for _ in range(3):
 *         try:             # <<<<<<<<<<<<<<
 *             p.close()
 *         except gipc.GIPCClosed:
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_6);
      /*try:*/ {

        /* "mars/actors/pool/gevent_pool.pyx":1434
 *     for _ in range(3):
 *         try:
 *             p.close()             # <<<<<<<<<<<<<<
 *         except gipc.GIPCClosed:
 *             break
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_p, __pyx_n_s_close); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1434, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_9)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_9);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
          }
        }
        __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_9) : __Pyx_PyObject_CallNoArg(__pyx_t_8);
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1434, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "mars/actors/pool/gevent_pool.pyx":1433
 *         return
 *     for _ in range(3):
 *         try:             # <<<<<<<<<<<<<<
 *             p.close()
 *         except gipc.GIPCClosed:
 */
      }
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L13_try_end;
      __pyx_L6_error:;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":1435
 *         try:
 *             p.close()
 *         except gipc.GIPCClosed:             # <<<<<<<<<<<<<<
 *             break
 *         except gipc.GIPCLocked:
 */
      __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
      __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_gipc); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1435, __pyx_L8_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_GIPCClosed); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1435, __pyx_L8_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_12 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_7, __pyx_t_11);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0;
      if (__pyx_t_12) {
        __Pyx_AddTraceback("mars.actors.pool.gevent_pool.close_pipe", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7) < 0) __PYX_ERR(0, 1435, __pyx_L8_except_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GOTREF(__pyx_t_7);

        /* "mars/actors/pool/gevent_pool.pyx":1436
 *             p.close()
 *         except gipc.GIPCClosed:
 *             break             # <<<<<<<<<<<<<<
 *         except gipc.GIPCLocked:
 *             continue
 */
        goto __pyx_L14_except_break;
        __pyx_L14_except_break:;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L11_try_break;
      }

      /* "mars/actors/pool/gevent_pool.pyx":1437
 *         except gipc.GIPCClosed:
 *             break
 *         except gipc.GIPCLocked:             # <<<<<<<<<<<<<<
 *             continue
 * 
 */
      __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
      __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_gipc); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1437, __pyx_L8_except_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_GIPCLocked); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1437, __pyx_L8_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_12 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_7, __pyx_t_10);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0;
      if (__pyx_t_12) {
        __Pyx_AddTraceback("mars.actors.pool.gevent_pool.close_pipe", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7) < 0) __PYX_ERR(0, 1437, __pyx_L8_except_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GOTREF(__pyx_t_7);

        /* "mars/actors/pool/gevent_pool.pyx":1438
 *             break
 *         except gipc.GIPCLocked:
 *             continue             # <<<<<<<<<<<<<<
 * 
 * 
 */
        goto __pyx_L17_except_continue;
        __pyx_L17_except_continue:;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L12_try_continue;
      }
      goto __pyx_L8_except_error;
      __pyx_L8_except_error:;

      /* "mars/actors/pool/gevent_pool.pyx":1433
 *         return
 *     for _ in range(3):
 *         try:             # <<<<<<<<<<<<<<
 *             p.close()
 *         except gipc.GIPCClosed:
 */
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
      goto __pyx_L1_error;
      __pyx_L11_try_break:;
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
      goto __pyx_L5_break;
      __pyx_L12_try_continue:;
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
      goto __pyx_L4_continue;
      __pyx_L13_try_end:;
    }
    __pyx_L4_continue:;
  }
  __pyx_L5_break:;

  /* "mars/actors/pool/gevent_pool.pyx":1429
 * 
 * 
 * def close_pipe(p):             # <<<<<<<<<<<<<<
 *     if p is None:
 *         return
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __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_AddTraceback("mars.actors.pool.gevent_pool.close_pipe", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1460
 *     cdef list _pool_pipes
 * 
 *     def __init__(self, ClusterInfo cluster_info, Distributor distributor=None, parallel=None):             # <<<<<<<<<<<<<<
 *         self.cluster_info = cluster_info
 *         self.distributor = distributor
 */

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *__pyx_v_cluster_info = 0;
  struct __pyx_obj_4mars_6actors_11distributor_Distributor *__pyx_v_distributor = 0;
  PyObject *__pyx_v_parallel = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cluster_info,&__pyx_n_s_distributor,&__pyx_n_s_parallel,0};
    PyObject* values[3] = {0,0,0};
    values[1] = (PyObject *)((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)Py_None);
    values[2] = ((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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cluster_info)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_distributor);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_parallel);
          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_ERR(0, 1460, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_cluster_info = ((struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *)values[0]);
    __pyx_v_distributor = ((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)values[1]);
    __pyx_v_parallel = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1460, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cluster_info), __pyx_ptype_4mars_6actors_7cluster_ClusterInfo, 1, "cluster_info", 0))) __PYX_ERR(0, 1460, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distributor), __pyx_ptype_4mars_6actors_11distributor_Distributor, 1, "distributor", 0))) __PYX_ERR(0, 1460, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool___init__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self), __pyx_v_cluster_info, __pyx_v_distributor, __pyx_v_parallel);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *__pyx_v_cluster_info, struct __pyx_obj_4mars_6actors_11distributor_Distributor *__pyx_v_distributor, PyObject *__pyx_v_parallel) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1461
 * 
 *     def __init__(self, ClusterInfo cluster_info, Distributor distributor=None, parallel=None):
 *         self.cluster_info = cluster_info             # <<<<<<<<<<<<<<
 *         self.distributor = distributor
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_cluster_info));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_cluster_info));
  __Pyx_GOTREF(__pyx_v_self->cluster_info);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->cluster_info));
  __pyx_v_self->cluster_info = __pyx_v_cluster_info;

  /* "mars/actors/pool/gevent_pool.pyx":1462
 *     def __init__(self, ClusterInfo cluster_info, Distributor distributor=None, parallel=None):
 *         self.cluster_info = cluster_info
 *         self.distributor = distributor             # <<<<<<<<<<<<<<
 * 
 *         self._started = False
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_distributor));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_distributor));
  __Pyx_GOTREF(__pyx_v_self->distributor);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->distributor));
  __pyx_v_self->distributor = __pyx_v_distributor;

  /* "mars/actors/pool/gevent_pool.pyx":1464
 *         self.distributor = distributor
 * 
 *         self._started = False             # <<<<<<<<<<<<<<
 *         self._stopped = gevent.event.Event()
 *         self._multi_process = self.cluster_info.n_process > 1
 */
  __pyx_v_self->_started = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1465
 * 
 *         self._started = False
 *         self._stopped = gevent.event.Event()             # <<<<<<<<<<<<<<
 *         self._multi_process = self.cluster_info.n_process > 1
 *         self._dispatcher = None
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1465, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_event); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1465, __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_Event); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1465, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1465, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_stopped);
  __Pyx_DECREF(__pyx_v_self->_stopped);
  __pyx_v_self->_stopped = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1466
 *         self._started = False
 *         self._stopped = gevent.event.Event()
 *         self._multi_process = self.cluster_info.n_process > 1             # <<<<<<<<<<<<<<
 *         self._dispatcher = None
 *         self._server = None
 */
  __pyx_v_self->_multi_process = (__pyx_v_self->cluster_info->n_process > 1);

  /* "mars/actors/pool/gevent_pool.pyx":1467
 *         self._stopped = gevent.event.Event()
 *         self._multi_process = self.cluster_info.n_process > 1
 *         self._dispatcher = None             # <<<<<<<<<<<<<<
 *         self._server = None
 *         self._parallel = parallel
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_dispatcher);
  __Pyx_DECREF(__pyx_v_self->_dispatcher);
  __pyx_v_self->_dispatcher = Py_None;

  /* "mars/actors/pool/gevent_pool.pyx":1468
 *         self._multi_process = self.cluster_info.n_process > 1
 *         self._dispatcher = None
 *         self._server = None             # <<<<<<<<<<<<<<
 *         self._parallel = parallel
 *         self._stop_funcs = []
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_server);
  __Pyx_DECREF(__pyx_v_self->_server);
  __pyx_v_self->_server = Py_None;

  /* "mars/actors/pool/gevent_pool.pyx":1469
 *         self._dispatcher = None
 *         self._server = None
 *         self._parallel = parallel             # <<<<<<<<<<<<<<
 *         self._stop_funcs = []
 *         self._processes = []
 */
  __Pyx_INCREF(__pyx_v_parallel);
  __Pyx_GIVEREF(__pyx_v_parallel);
  __Pyx_GOTREF(__pyx_v_self->_parallel);
  __Pyx_DECREF(__pyx_v_self->_parallel);
  __pyx_v_self->_parallel = __pyx_v_parallel;

  /* "mars/actors/pool/gevent_pool.pyx":1470
 *         self._server = None
 *         self._parallel = parallel
 *         self._stop_funcs = []             # <<<<<<<<<<<<<<
 *         self._processes = []
 *         self._comm_pipes = []
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1470, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_stop_funcs);
  __Pyx_DECREF(__pyx_v_self->_stop_funcs);
  __pyx_v_self->_stop_funcs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1471
 *         self._parallel = parallel
 *         self._stop_funcs = []
 *         self._processes = []             # <<<<<<<<<<<<<<
 *         self._comm_pipes = []
 *         self._pool_pipes = []
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1471, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_processes);
  __Pyx_DECREF(__pyx_v_self->_processes);
  __pyx_v_self->_processes = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1472
 *         self._stop_funcs = []
 *         self._processes = []
 *         self._comm_pipes = []             # <<<<<<<<<<<<<<
 *         self._pool_pipes = []
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1472, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_comm_pipes);
  __Pyx_DECREF(__pyx_v_self->_comm_pipes);
  __pyx_v_self->_comm_pipes = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1473
 *         self._processes = []
 *         self._comm_pipes = []
 *         self._pool_pipes = []             # <<<<<<<<<<<<<<
 * 
 *     cdef void _check_started(self):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1473, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_pool_pipes);
  __Pyx_DECREF(__pyx_v_self->_pool_pipes);
  __pyx_v_self->_pool_pipes = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1460
 *     cdef list _pool_pipes
 * 
 *     def __init__(self, ClusterInfo cluster_info, Distributor distributor=None, parallel=None):             # <<<<<<<<<<<<<<
 *         self.cluster_info = cluster_info
 *         self.distributor = distributor
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1475
 *         self._pool_pipes = []
 * 
 *     cdef void _check_started(self):             # <<<<<<<<<<<<<<
 *         if not self._started:
 *             raise ActorPoolNotStarted('Actor pool need to run first')
 */

static void __pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool__check_started(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("_check_started", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1476
 * 
 *     cdef void _check_started(self):
 *         if not self._started:             # <<<<<<<<<<<<<<
 *             raise ActorPoolNotStarted('Actor pool need to run first')
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_self->_started != 0)) != 0);
  if (unlikely(__pyx_t_1)) {

    /* "mars/actors/pool/gevent_pool.pyx":1477
 *     cdef void _check_started(self):
 *         if not self._started:
 *             raise ActorPoolNotStarted('Actor pool need to run first')             # <<<<<<<<<<<<<<
 * 
 *     def create_actor(self, object actor_cls, *args, **kwargs):
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_ActorPoolNotStarted); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1477, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_kp_s_Actor_pool_need_to_run_first) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_s_Actor_pool_need_to_run_first);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1477, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 1477, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":1476
 * 
 *     cdef void _check_started(self):
 *         if not self._started:             # <<<<<<<<<<<<<<
 *             raise ActorPoolNotStarted('Actor pool need to run first')
 * 
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1475
 *         self._pool_pipes = []
 * 
 *     cdef void _check_started(self):             # <<<<<<<<<<<<<<
 *         if not self._started:
 *             raise ActorPoolNotStarted('Actor pool need to run first')
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_WriteUnraisable("mars.actors.pool.gevent_pool.ActorPool._check_started", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "mars/actors/pool/gevent_pool.pyx":1479
 *             raise ActorPoolNotStarted('Actor pool need to run first')
 * 
 *     def create_actor(self, object actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef bint wait
 *         cdef object address
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_3create_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_3create_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_actor_cls = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_actor (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_actor_cls,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);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_cls)) != 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, "create_actor") < 0)) __PYX_ERR(0, 1479, __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_actor_cls = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_actor", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1479, __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("mars.actors.pool.gevent_pool.ActorPool.create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_2create_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self), __pyx_v_actor_cls, __pyx_v_args, __pyx_v_kwargs);

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

/* "mars/actors/pool/gevent_pool.pyx":1500
 *             return actor_ref
 * 
 *         def callback(ref):             # <<<<<<<<<<<<<<
 *             if address is not None:
 *                 ref.address = address
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_12create_actor_1callback(PyObject *__pyx_self, PyObject *__pyx_v_ref); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_9ActorPool_12create_actor_1callback = {"callback", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_12create_actor_1callback, METH_O, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_12create_actor_1callback(PyObject *__pyx_self, PyObject *__pyx_v_ref) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("callback (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_12create_actor_callback(__pyx_self, ((PyObject *)__pyx_v_ref));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_12create_actor_callback(PyObject *__pyx_self, PyObject *__pyx_v_ref) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor *__pyx_outer_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("callback", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":1501
 * 
 *         def callback(ref):
 *             if address is not None:             # <<<<<<<<<<<<<<
 *                 ref.address = address
 *             ref.ctx = ActorContext(self._dispatcher)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_address)) { __Pyx_RaiseClosureNameError("address"); __PYX_ERR(0, 1501, __pyx_L1_error) }
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_address != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "mars/actors/pool/gevent_pool.pyx":1502
 *         def callback(ref):
 *             if address is not None:
 *                 ref.address = address             # <<<<<<<<<<<<<<
 *             ref.ctx = ActorContext(self._dispatcher)
 * 
 */
    if (unlikely(!__pyx_cur_scope->__pyx_v_address)) { __Pyx_RaiseClosureNameError("address"); __PYX_ERR(0, 1502, __pyx_L1_error) }
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_ref, __pyx_n_s_address, __pyx_cur_scope->__pyx_v_address) < 0) __PYX_ERR(0, 1502, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":1501
 * 
 *         def callback(ref):
 *             if address is not None:             # <<<<<<<<<<<<<<
 *                 ref.address = address
 *             ref.ctx = ActorContext(self._dispatcher)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1503
 *             if address is not None:
 *                 ref.address = address
 *             ref.ctx = ActorContext(self._dispatcher)             # <<<<<<<<<<<<<<
 * 
 *         kwargs['wait'] = False
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1503, __pyx_L1_error) }
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext), __pyx_cur_scope->__pyx_v_self->_dispatcher); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1503, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_ref, __pyx_n_s_ctx, __pyx_t_3) < 0) __PYX_ERR(0, 1503, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1500
 *             return actor_ref
 * 
 *         def callback(ref):             # <<<<<<<<<<<<<<
 *             if address is not None:
 *                 ref.address = address
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.create_actor.callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1479
 *             raise ActorPoolNotStarted('Actor pool need to run first')
 * 
 *     def create_actor(self, object actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef bint wait
 *         cdef object address
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_2create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor *__pyx_cur_scope;
  int __pyx_v_wait;
  PyObject *__pyx_v_uid = 0;
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  PyObject *__pyx_v_callback = 0;
  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;
  __Pyx_RefNannySetupContext("create_actor", 0);
  __pyx_cur_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor *)__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor(__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1479, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);

  /* "mars/actors/pool/gevent_pool.pyx":1485
 *         cdef ActorRef actor_ref
 * 
 *         self._check_started()             # <<<<<<<<<<<<<<
 * 
 *         wait = kwargs.pop('wait', True)
 */
  ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->_check_started(__pyx_cur_scope->__pyx_v_self);

  /* "mars/actors/pool/gevent_pool.pyx":1487
 *         self._check_started()
 * 
 *         wait = kwargs.pop('wait', True)             # <<<<<<<<<<<<<<
 * 
 *         address = kwargs.pop('address', None)
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_wait, Py_True); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1487, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1487, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_wait = __pyx_t_2;

  /* "mars/actors/pool/gevent_pool.pyx":1489
 *         wait = kwargs.pop('wait', True)
 * 
 *         address = kwargs.pop('address', None)             # <<<<<<<<<<<<<<
 *         uid = kwargs.pop('uid', None)
 * 
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_address, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1489, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_address = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1490
 * 
 *         address = kwargs.pop('address', None)
 *         uid = kwargs.pop('uid', None)             # <<<<<<<<<<<<<<
 * 
 *         if wait:
 */
  __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_uid, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1490, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_uid = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1492
 *         uid = kwargs.pop('uid', None)
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             actor_ref = self._dispatcher.create_actor(address, uid,
 *                                                       actor_cls, *args, **kwargs)
 */
  __pyx_t_2 = (__pyx_v_wait != 0);
  if (__pyx_t_2) {

    /* "mars/actors/pool/gevent_pool.pyx":1493
 * 
 *         if wait:
 *             actor_ref = self._dispatcher.create_actor(address, uid,             # <<<<<<<<<<<<<<
 *                                                       actor_cls, *args, **kwargs)
 *             if address:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->_dispatcher, __pyx_n_s_create_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1493, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "mars/actors/pool/gevent_pool.pyx":1494
 *         if wait:
 *             actor_ref = self._dispatcher.create_actor(address, uid,
 *                                                       actor_cls, *args, **kwargs)             # <<<<<<<<<<<<<<
 *             if address:
 *                 actor_ref.address = address
 */
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1493, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_address);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_address);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_cur_scope->__pyx_v_address);
    __Pyx_INCREF(__pyx_v_uid);
    __Pyx_GIVEREF(__pyx_v_uid);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_uid);
    __Pyx_INCREF(__pyx_v_actor_cls);
    __Pyx_GIVEREF(__pyx_v_actor_cls);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_actor_cls);

    /* "mars/actors/pool/gevent_pool.pyx":1493
 * 
 *         if wait:
 *             actor_ref = self._dispatcher.create_actor(address, uid,             # <<<<<<<<<<<<<<
 *                                                       actor_cls, *args, **kwargs)
 *             if address:
 */
    __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_v_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1493, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1494
 *         if wait:
 *             actor_ref = self._dispatcher.create_actor(address, uid,
 *                                                       actor_cls, *args, **kwargs)             # <<<<<<<<<<<<<<
 *             if address:
 *                 actor_ref.address = address
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_v_kwargs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1493, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1493
 * 
 *         if wait:
 *             actor_ref = self._dispatcher.create_actor(address, uid,             # <<<<<<<<<<<<<<
 *                                                       actor_cls, *args, **kwargs)
 *             if address:
 */
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_4mars_6actors_4core_ActorRef))))) __PYX_ERR(0, 1493, __pyx_L1_error)
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1495
 *             actor_ref = self._dispatcher.create_actor(address, uid,
 *                                                       actor_cls, *args, **kwargs)
 *             if address:             # <<<<<<<<<<<<<<
 *                 actor_ref.address = address
 *             actor_ref.ctx = ActorContext(self._dispatcher)
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_address); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1495, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "mars/actors/pool/gevent_pool.pyx":1496
 *                                                       actor_cls, *args, **kwargs)
 *             if address:
 *                 actor_ref.address = address             # <<<<<<<<<<<<<<
 *             actor_ref.ctx = ActorContext(self._dispatcher)
 *             return actor_ref
 */
      if (!(likely(PyString_CheckExact(__pyx_cur_scope->__pyx_v_address))||((__pyx_cur_scope->__pyx_v_address) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_cur_scope->__pyx_v_address)->tp_name), 0))) __PYX_ERR(0, 1496, __pyx_L1_error)
      __pyx_t_3 = __pyx_cur_scope->__pyx_v_address;
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_v_actor_ref->address);
      __Pyx_DECREF(__pyx_v_actor_ref->address);
      __pyx_v_actor_ref->address = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":1495
 *             actor_ref = self._dispatcher.create_actor(address, uid,
 *                                                       actor_cls, *args, **kwargs)
 *             if address:             # <<<<<<<<<<<<<<
 *                 actor_ref.address = address
 *             actor_ref.ctx = ActorContext(self._dispatcher)
 */
    }

    /* "mars/actors/pool/gevent_pool.pyx":1497
 *             if address:
 *                 actor_ref.address = address
 *             actor_ref.ctx = ActorContext(self._dispatcher)             # <<<<<<<<<<<<<<
 *             return actor_ref
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext), __pyx_cur_scope->__pyx_v_self->_dispatcher); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1497, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_actor_ref), __pyx_n_s_ctx, __pyx_t_3) < 0) __PYX_ERR(0, 1497, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1498
 *                 actor_ref.address = address
 *             actor_ref.ctx = ActorContext(self._dispatcher)
 *             return actor_ref             # <<<<<<<<<<<<<<
 * 
 *         def callback(ref):
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
    __pyx_r = ((PyObject *)__pyx_v_actor_ref);
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":1492
 *         uid = kwargs.pop('uid', None)
 * 
 *         if wait:             # <<<<<<<<<<<<<<
 *             actor_ref = self._dispatcher.create_actor(address, uid,
 *                                                       actor_cls, *args, **kwargs)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1500
 *             return actor_ref
 * 
 *         def callback(ref):             # <<<<<<<<<<<<<<
 *             if address is not None:
 *                 ref.address = address
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_9ActorPool_12create_actor_1callback, 0, __pyx_n_s_create_actor_locals_callback, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__34)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_callback = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1505
 *             ref.ctx = ActorContext(self._dispatcher)
 * 
 *         kwargs['wait'] = False             # <<<<<<<<<<<<<<
 *         kwargs['callback'] = callback
 *         return self._dispatcher.create_actor(address, uid,
 */
  if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_n_s_wait, Py_False) < 0)) __PYX_ERR(0, 1505, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1506
 * 
 *         kwargs['wait'] = False
 *         kwargs['callback'] = callback             # <<<<<<<<<<<<<<
 *         return self._dispatcher.create_actor(address, uid,
 *                                              actor_cls, *args, **kwargs)
 */
  if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_n_s_callback, __pyx_v_callback) < 0)) __PYX_ERR(0, 1506, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1507
 *         kwargs['wait'] = False
 *         kwargs['callback'] = callback
 *         return self._dispatcher.create_actor(address, uid,             # <<<<<<<<<<<<<<
 *                                              actor_cls, *args, **kwargs)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->_dispatcher, __pyx_n_s_create_actor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "mars/actors/pool/gevent_pool.pyx":1508
 *         kwargs['callback'] = callback
 *         return self._dispatcher.create_actor(address, uid,
 *                                              actor_cls, *args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     cpdef object destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 */
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_address);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_address);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_cur_scope->__pyx_v_address);
  __Pyx_INCREF(__pyx_v_uid);
  __Pyx_GIVEREF(__pyx_v_uid);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_uid);
  __Pyx_INCREF(__pyx_v_actor_cls);
  __Pyx_GIVEREF(__pyx_v_actor_cls);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_actor_cls);

  /* "mars/actors/pool/gevent_pool.pyx":1507
 *         kwargs['wait'] = False
 *         kwargs['callback'] = callback
 *         return self._dispatcher.create_actor(address, uid,             # <<<<<<<<<<<<<<
 *                                              actor_cls, *args, **kwargs)
 * 
 */
  __pyx_t_1 = PyNumber_Add(__pyx_t_4, __pyx_v_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1508
 *         kwargs['callback'] = callback
 *         return self._dispatcher.create_actor(address, uid,
 *                                              actor_cls, *args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     cpdef object destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 */
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, __pyx_v_kwargs); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1479
 *             raise ActorPoolNotStarted('Actor pool need to run first')
 * 
 *     def create_actor(self, object actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef bint wait
 *         cdef object address
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_uid);
  __Pyx_XDECREF((PyObject *)__pyx_v_actor_ref);
  __Pyx_XDECREF(__pyx_v_callback);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1510
 *                                              actor_cls, *args, **kwargs)
 * 
 *     cpdef object destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         self._check_started()
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_5destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool_destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_9ActorPool_destroy_actor *__pyx_optional_args) {
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  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;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("destroy_actor", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_wait = __pyx_optional_args->wait;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_callback = __pyx_optional_args->callback;
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_destroy_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1510, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_5destroy_actor)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1510, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        __pyx_t_6 = 0;
        if (CYTHON_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1510, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1510, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1510, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1510, __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_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":1511
 * 
 *     cpdef object destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 *         self._check_started()             # <<<<<<<<<<<<<<
 * 
 *         return self._dispatcher.destroy_actor(actor_ref, wait=wait, callback=callback)
 */
  ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self->__pyx_vtab)->_check_started(__pyx_v_self);

  /* "mars/actors/pool/gevent_pool.pyx":1513
 *         self._check_started()
 * 
 *         return self._dispatcher.destroy_actor(actor_ref, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_dispatcher, __pyx_n_s_destroy_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1513, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1513, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_actor_ref));
  __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1513, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1513, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_wait, __pyx_t_7) < 0) __PYX_ERR(0, 1513, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1513, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1513, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1510
 *                                              actor_cls, *args, **kwargs)
 * 
 *     cpdef object destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         self._check_started()
 * 
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_5destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_5destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("destroy_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "destroy_actor") < 0)) __PYX_ERR(0, 1510, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    if (values[1]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1510, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("destroy_actor", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1510, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 1510, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_4destroy_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_4destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_9ActorPool_destroy_actor __pyx_t_2;
  __Pyx_RefNannySetupContext("destroy_actor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorPool->destroy_actor(__pyx_v_self, __pyx_v_actor_ref, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1510, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1515
 *         return self._dispatcher.destroy_actor(actor_ref, wait=wait, callback=callback)
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         self._check_started()
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_7has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool_has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_9ActorPool_has_actor *__pyx_optional_args) {
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  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;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("has_actor", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_wait = __pyx_optional_args->wait;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_callback = __pyx_optional_args->callback;
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_has_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1515, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_7has_actor)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1515, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        __pyx_t_6 = 0;
        if (CYTHON_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1515, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1515, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1515, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1515, __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_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":1516
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 *         self._check_started()             # <<<<<<<<<<<<<<
 * 
 *         return self._dispatcher.has_actor(actor_ref, wait=wait, callback=callback)
 */
  ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self->__pyx_vtab)->_check_started(__pyx_v_self);

  /* "mars/actors/pool/gevent_pool.pyx":1518
 *         self._check_started()
 * 
 *         return self._dispatcher.has_actor(actor_ref, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *     def actor_ref(self, *args, **kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_dispatcher, __pyx_n_s_has_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_actor_ref));
  __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_wait, __pyx_t_7) < 0) __PYX_ERR(0, 1518, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1518, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1515
 *         return self._dispatcher.destroy_actor(actor_ref, wait=wait, callback=callback)
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         self._check_started()
 * 
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_7has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_7has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("has_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "has_actor") < 0)) __PYX_ERR(0, 1515, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    if (values[1]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1515, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("has_actor", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1515, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 1515, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_6has_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_6has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_9ActorPool_has_actor __pyx_t_2;
  __Pyx_RefNannySetupContext("has_actor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorPool->has_actor(__pyx_v_self, __pyx_v_actor_ref, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1515, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1520
 *         return self._dispatcher.has_actor(actor_ref, wait=wait, callback=callback)
 * 
 *     def actor_ref(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef ActorRef ref
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_9actor_ref(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_9actor_ref(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("actor_ref (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "actor_ref", 1))) return NULL;
  if (unlikely(__pyx_kwds)) {
    __pyx_v_kwargs = PyDict_Copy(__pyx_kwds); if (unlikely(!__pyx_v_kwargs)) return NULL;
    __Pyx_GOTREF(__pyx_v_kwargs);
  } else {
    __pyx_v_kwargs = NULL;
  }
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_8actor_ref(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__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_4mars_6actors_4pool_11gevent_pool_9ActorPool_8actor_ref(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_ref = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("actor_ref", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1523
 *         cdef ActorRef ref
 * 
 *         ref = create_actor_ref(*args, **kwargs)             # <<<<<<<<<<<<<<
 *         ref.ctx = ActorContext(self._dispatcher)
 *         return ref
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_create_actor_ref); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1523, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1523, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4mars_6actors_4core_ActorRef))))) __PYX_ERR(0, 1523, __pyx_L1_error)
  __pyx_v_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1524
 * 
 *         ref = create_actor_ref(*args, **kwargs)
 *         ref.ctx = ActorContext(self._dispatcher)             # <<<<<<<<<<<<<<
 *         return ref
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext), __pyx_v_self->_dispatcher); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1524, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_ref), __pyx_n_s_ctx, __pyx_t_2) < 0) __PYX_ERR(0, 1524, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1525
 *         ref = create_actor_ref(*args, **kwargs)
 *         ref.ctx = ActorContext(self._dispatcher)
 *         return ref             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_ref));
  __pyx_r = ((PyObject *)__pyx_v_ref);
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1520
 *         return self._dispatcher.has_actor(actor_ref, wait=wait, callback=callback)
 * 
 *     def actor_ref(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef ActorRef ref
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.actor_ref", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ref);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1528
 * 
 *     @property
 *     def processes(self):             # <<<<<<<<<<<<<<
 *         return self._processes
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_9processes_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_9processes_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_9processes___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_9processes___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1529
 *     @property
 *     def processes(self):
 *         return self._processes             # <<<<<<<<<<<<<<
 * 
 *     cpdef tuple _start_process(self, idx):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_processes);
  __pyx_r = __pyx_v_self->_processes;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1528
 * 
 *     @property
 *     def processes(self):             # <<<<<<<<<<<<<<
 *         return self._processes
 * 
 */

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

/* "mars/actors/pool/gevent_pool.pyx":1531
 *         return self._processes
 * 
 *     cpdef tuple _start_process(self, idx):             # <<<<<<<<<<<<<<
 *         comm_pipe, pool_pipe = gipc.pipe(True, encoder=_inaction_encoder, decoder=_inaction_decoder)
 *         p = gipc.start_process(start_local_pool,
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_start_process(PyObject *__pyx_v_self, PyObject *__pyx_v_idx); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool__start_process(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v_idx, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_comm_pipe = NULL;
  PyObject *__pyx_v_pool_pipe = NULL;
  PyObject *__pyx_v_p = 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)(PyObject *);
  __Pyx_RefNannySetupContext("_start_process", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_start_process); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1531, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_start_process)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_idx) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_idx);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1531, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!(likely(PyTuple_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 1531, __pyx_L1_error)
        __pyx_r = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":1532
 * 
 *     cpdef tuple _start_process(self, idx):
 *         comm_pipe, pool_pipe = gipc.pipe(True, encoder=_inaction_encoder, decoder=_inaction_decoder)             # <<<<<<<<<<<<<<
 *         p = gipc.start_process(start_local_pool,
 *                                args=(idx, self.cluster_info, comm_pipe, self.distributor),
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gipc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_pipe); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_inaction_encoder); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_encoder, __pyx_t_3) < 0) __PYX_ERR(0, 1532, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_inaction_decoder); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_decoder, __pyx_t_3) < 0) __PYX_ERR(0, 1532, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__35, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 1532, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1532, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1532, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1532, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(0, 1532, __pyx_L1_error)
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 1532, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_comm_pipe = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_pool_pipe = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1533
 *     cpdef tuple _start_process(self, idx):
 *         comm_pipe, pool_pipe = gipc.pipe(True, encoder=_inaction_encoder, decoder=_inaction_decoder)
 *         p = gipc.start_process(start_local_pool,             # <<<<<<<<<<<<<<
 *                                args=(idx, self.cluster_info, comm_pipe, self.distributor),
 *                                kwargs={'parallel': self._parallel, 'join': True}, daemon=True)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_gipc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_start_process_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_start_local_pool); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1534
 *         comm_pipe, pool_pipe = gipc.pipe(True, encoder=_inaction_encoder, decoder=_inaction_decoder)
 *         p = gipc.start_process(start_local_pool,
 *                                args=(idx, self.cluster_info, comm_pipe, self.distributor),             # <<<<<<<<<<<<<<
 *                                kwargs={'parallel': self._parallel, 'join': True}, daemon=True)
 *         return p, comm_pipe, pool_pipe
 */
  __pyx_t_3 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1534, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1534, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_idx);
  __Pyx_GIVEREF(__pyx_v_idx);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_idx);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->cluster_info));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->cluster_info));
  PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_self->cluster_info));
  __Pyx_INCREF(__pyx_v_comm_pipe);
  __Pyx_GIVEREF(__pyx_v_comm_pipe);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_comm_pipe);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->distributor));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->distributor));
  PyTuple_SET_ITEM(__pyx_t_4, 3, ((PyObject *)__pyx_v_self->distributor));
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_args, __pyx_t_4) < 0) __PYX_ERR(0, 1534, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1535
 *         p = gipc.start_process(start_local_pool,
 *                                args=(idx, self.cluster_info, comm_pipe, self.distributor),
 *                                kwargs={'parallel': self._parallel, 'join': True}, daemon=True)             # <<<<<<<<<<<<<<
 *         return p, comm_pipe, pool_pipe
 * 
 */
  __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_parallel, __pyx_v_self->_parallel) < 0) __PYX_ERR(0, 1535, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_join, Py_True) < 0) __PYX_ERR(0, 1535, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_kwargs, __pyx_t_4) < 0) __PYX_ERR(0, 1534, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_daemon, Py_True) < 0) __PYX_ERR(0, 1534, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1533
 *     cpdef tuple _start_process(self, idx):
 *         comm_pipe, pool_pipe = gipc.pipe(True, encoder=_inaction_encoder, decoder=_inaction_decoder)
 *         p = gipc.start_process(start_local_pool,             # <<<<<<<<<<<<<<
 *                                args=(idx, self.cluster_info, comm_pipe, self.distributor),
 *                                kwargs={'parallel': self._parallel, 'join': True}, daemon=True)
 */
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1533, __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_v_p = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1536
 *                                args=(idx, self.cluster_info, comm_pipe, self.distributor),
 *                                kwargs={'parallel': self._parallel, 'join': True}, daemon=True)
 *         return p, comm_pipe, pool_pipe             # <<<<<<<<<<<<<<
 * 
 *     cpdef restart_process(self, int idx):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_p);
  __Pyx_GIVEREF(__pyx_v_p);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_p);
  __Pyx_INCREF(__pyx_v_comm_pipe);
  __Pyx_GIVEREF(__pyx_v_comm_pipe);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_comm_pipe);
  __Pyx_INCREF(__pyx_v_pool_pipe);
  __Pyx_GIVEREF(__pyx_v_pool_pipe);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_pool_pipe);
  __pyx_r = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1531
 *         return self._processes
 * 
 *     cpdef tuple _start_process(self, idx):             # <<<<<<<<<<<<<<
 *         comm_pipe, pool_pipe = gipc.pipe(True, encoder=_inaction_encoder, decoder=_inaction_decoder)
 *         p = gipc.start_process(start_local_pool,
 */

  /* 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("mars.actors.pool.gevent_pool.ActorPool._start_process", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_comm_pipe);
  __Pyx_XDECREF(__pyx_v_pool_pipe);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_start_process(PyObject *__pyx_v_self, PyObject *__pyx_v_idx); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_start_process(PyObject *__pyx_v_self, PyObject *__pyx_v_idx) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_start_process (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_10_start_process(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self), ((PyObject *)__pyx_v_idx));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_10_start_process(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v_idx) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("_start_process", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool__start_process(__pyx_v_self, __pyx_v_idx, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1531, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool._start_process", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1538
 *         return p, comm_pipe, pool_pipe
 * 
 *     cpdef restart_process(self, int idx):             # <<<<<<<<<<<<<<
 *         if self._processes[idx].is_alive():
 *             self._processes[idx].terminate()
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_13restart_process(PyObject *__pyx_v_self, PyObject *__pyx_arg_idx); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool_restart_process(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, int __pyx_v_idx, int __pyx_skip_dispatch) {
  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;
  __Pyx_RefNannySetupContext("restart_process", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_restart_process); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1538, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_13restart_process)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1538, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        if (CYTHON_UNPACK_METHODS && 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_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1538, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":1539
 * 
 *     cpdef restart_process(self, int idx):
 *         if self._processes[idx].is_alive():             # <<<<<<<<<<<<<<
 *             self._processes[idx].terminate()
 *         close_pipe(self._comm_pipes[idx])
 */
  if (unlikely(__pyx_v_self->_processes == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1539, __pyx_L1_error)
  }
  __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_self->_processes, __pyx_v_idx, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_is_alive); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 1539, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_6) {

    /* "mars/actors/pool/gevent_pool.pyx":1540
 *     cpdef restart_process(self, int idx):
 *         if self._processes[idx].is_alive():
 *             self._processes[idx].terminate()             # <<<<<<<<<<<<<<
 *         close_pipe(self._comm_pipes[idx])
 *         close_pipe(self._pool_pipes[idx])
 */
    if (unlikely(__pyx_v_self->_processes == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1540, __pyx_L1_error)
    }
    __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_self->_processes, __pyx_v_idx, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1540, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_terminate); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1540, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1540, __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;

    /* "mars/actors/pool/gevent_pool.pyx":1539
 * 
 *     cpdef restart_process(self, int idx):
 *         if self._processes[idx].is_alive():             # <<<<<<<<<<<<<<
 *             self._processes[idx].terminate()
 *         close_pipe(self._comm_pipes[idx])
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1541
 *         if self._processes[idx].is_alive():
 *             self._processes[idx].terminate()
 *         close_pipe(self._comm_pipes[idx])             # <<<<<<<<<<<<<<
 *         close_pipe(self._pool_pipes[idx])
 *         self._processes[idx], self._comm_pipes[idx], self._pool_pipes[idx] = self._start_process(idx)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_close_pipe); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1541, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(__pyx_v_self->_comm_pipes == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1541, __pyx_L1_error)
  }
  __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_self->_comm_pipes, __pyx_v_idx, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1541, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1541, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1542
 *             self._processes[idx].terminate()
 *         close_pipe(self._comm_pipes[idx])
 *         close_pipe(self._pool_pipes[idx])             # <<<<<<<<<<<<<<
 *         self._processes[idx], self._comm_pipes[idx], self._pool_pipes[idx] = self._start_process(idx)
 *         self._dispatcher.replace_pipe(idx)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_close_pipe); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1542, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (unlikely(__pyx_v_self->_pool_pipes == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1542, __pyx_L1_error)
  }
  __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_self->_pool_pipes, __pyx_v_idx, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1542, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1542, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1543
 *         close_pipe(self._comm_pipes[idx])
 *         close_pipe(self._pool_pipes[idx])
 *         self._processes[idx], self._comm_pipes[idx], self._pool_pipes[idx] = self._start_process(idx)             # <<<<<<<<<<<<<<
 *         self._dispatcher.replace_pipe(idx)
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self->__pyx_vtab)->_start_process(__pyx_v_self, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_2 != Py_None)) {
    PyObject* sequence = __pyx_t_2;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 1543, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 1543, __pyx_L1_error)
  }
  if (unlikely(__pyx_v_self->_processes == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1543, __pyx_L1_error)
  }
  if (unlikely(__Pyx_SetItemInt(__pyx_v_self->_processes, __pyx_v_idx, __pyx_t_1, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0)) __PYX_ERR(0, 1543, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(__pyx_v_self->_comm_pipes == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1543, __pyx_L1_error)
  }
  if (unlikely(__Pyx_SetItemInt(__pyx_v_self->_comm_pipes, __pyx_v_idx, __pyx_t_4, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0)) __PYX_ERR(0, 1543, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(__pyx_v_self->_pool_pipes == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(0, 1543, __pyx_L1_error)
  }
  if (unlikely(__Pyx_SetItemInt(__pyx_v_self->_pool_pipes, __pyx_v_idx, __pyx_t_3, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0)) __PYX_ERR(0, 1543, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1544
 *         close_pipe(self._pool_pipes[idx])
 *         self._processes[idx], self._comm_pipes[idx], self._pool_pipes[idx] = self._start_process(idx)
 *         self._dispatcher.replace_pipe(idx)             # <<<<<<<<<<<<<<
 * 
 *     def run(self):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_dispatcher, __pyx_n_s_replace_pipe); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1538
 *         return p, comm_pipe, pool_pipe
 * 
 *     cpdef restart_process(self, int idx):             # <<<<<<<<<<<<<<
 *         if self._processes[idx].is_alive():
 *             self._processes[idx].terminate()
 */

  /* 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_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.restart_process", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_13restart_process(PyObject *__pyx_v_self, PyObject *__pyx_arg_idx); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_13restart_process(PyObject *__pyx_v_self, PyObject *__pyx_arg_idx) {
  int __pyx_v_idx;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("restart_process (wrapper)", 0);
  assert(__pyx_arg_idx); {
    __pyx_v_idx = __Pyx_PyInt_As_int(__pyx_arg_idx); if (unlikely((__pyx_v_idx == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1538, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.restart_process", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_12restart_process(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self), ((int)__pyx_v_idx));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_12restart_process(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, int __pyx_v_idx) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("restart_process", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool_restart_process(__pyx_v_self, __pyx_v_idx, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1538, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.restart_process", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1546
 *         self._dispatcher.replace_pipe(idx)
 * 
 *     def run(self):             # <<<<<<<<<<<<<<
 *         if self._started:
 *             return
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_15run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_15run(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("run (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_14run(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self));

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

/* "mars/actors/pool/gevent_pool.pyx":1559
 *             )]
 * 
 *             def stop_func():             # <<<<<<<<<<<<<<
 *                 for process in self._processes:
 *                     process.terminate()
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_1stop_func(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_1stop_func = {"stop_func", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_1stop_func, METH_NOARGS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_1stop_func(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop_func (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_stop_func(__pyx_self);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_stop_func(PyObject *__pyx_self) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *__pyx_outer_scope;
  PyObject *__pyx_v_process = NULL;
  PyObject *__pyx_v_idx = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("stop_func", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":1560
 * 
 *             def stop_func():
 *                 for process in self._processes:             # <<<<<<<<<<<<<<
 *                     process.terminate()
 *                 for idx, p in enumerate(self._comm_pipes):
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1560, __pyx_L1_error) }
  if (unlikely(__pyx_cur_scope->__pyx_v_self->_processes == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 1560, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->_processes; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1560, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1560, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_process, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1561
 *             def stop_func():
 *                 for process in self._processes:
 *                     process.terminate()             # <<<<<<<<<<<<<<
 *                 for idx, p in enumerate(self._comm_pipes):
 *                     close_pipe(p)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_process, __pyx_n_s_terminate); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1561, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1561, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1560
 * 
 *             def stop_func():
 *                 for process in self._processes:             # <<<<<<<<<<<<<<
 *                     process.terminate()
 *                 for idx, p in enumerate(self._comm_pipes):
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1562
 *                 for process in self._processes:
 *                     process.terminate()
 *                 for idx, p in enumerate(self._comm_pipes):             # <<<<<<<<<<<<<<
 *                     close_pipe(p)
 *                     self._comm_pipes[idx] = None
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1562, __pyx_L1_error) }
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_self->_comm_pipes; __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1562, __pyx_L1_error)
    #else
    __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1562, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_4);
    __pyx_t_4 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_1);
    __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1562, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1563
 *                     process.terminate()
 *                 for idx, p in enumerate(self._comm_pipes):
 *                     close_pipe(p)             # <<<<<<<<<<<<<<
 *                     self._comm_pipes[idx] = None
 *                 for idx, p in enumerate(self._pool_pipes):
 */
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_close_pipe); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_v_p) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_p);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1564
 *                 for idx, p in enumerate(self._comm_pipes):
 *                     close_pipe(p)
 *                     self._comm_pipes[idx] = None             # <<<<<<<<<<<<<<
 *                 for idx, p in enumerate(self._pool_pipes):
 *                     close_pipe(p)
 */
    if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1564, __pyx_L1_error) }
    if (unlikely(__pyx_cur_scope->__pyx_v_self->_comm_pipes == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1564, __pyx_L1_error)
    }
    if (unlikely(PyObject_SetItem(__pyx_cur_scope->__pyx_v_self->_comm_pipes, __pyx_v_idx, Py_None) < 0)) __PYX_ERR(0, 1564, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":1562
 *                 for process in self._processes:
 *                     process.terminate()
 *                 for idx, p in enumerate(self._comm_pipes):             # <<<<<<<<<<<<<<
 *                     close_pipe(p)
 *                     self._comm_pipes[idx] = None
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1565
 *                     close_pipe(p)
 *                     self._comm_pipes[idx] = None
 *                 for idx, p in enumerate(self._pool_pipes):             # <<<<<<<<<<<<<<
 *                     close_pipe(p)
 *                     self._pool_pipes[idx] = None
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1565, __pyx_L1_error) }
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_self->_pool_pipes; __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 1565, __pyx_L1_error)
    #else
    __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_4);
    __pyx_t_4 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_1);
    __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1566
 *                     self._comm_pipes[idx] = None
 *                 for idx, p in enumerate(self._pool_pipes):
 *                     close_pipe(p)             # <<<<<<<<<<<<<<
 *                     self._pool_pipes[idx] = None
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_close_pipe); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1566, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(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 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_v_p) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_p);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1566, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1567
 *                 for idx, p in enumerate(self._pool_pipes):
 *                     close_pipe(p)
 *                     self._pool_pipes[idx] = None             # <<<<<<<<<<<<<<
 * 
 *             self._stop_funcs.append(stop_func)
 */
    if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1567, __pyx_L1_error) }
    if (unlikely(__pyx_cur_scope->__pyx_v_self->_pool_pipes == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 1567, __pyx_L1_error)
    }
    if (unlikely(PyObject_SetItem(__pyx_cur_scope->__pyx_v_self->_pool_pipes, __pyx_v_idx, Py_None) < 0)) __PYX_ERR(0, 1567, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":1565
 *                     close_pipe(p)
 *                     self._comm_pipes[idx] = None
 *                 for idx, p in enumerate(self._pool_pipes):             # <<<<<<<<<<<<<<
 *                     close_pipe(p)
 *                     self._pool_pipes[idx] = None
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1559
 *             )]
 * 
 *             def stop_func():             # <<<<<<<<<<<<<<
 *                 for process in self._processes:
 *                     process.terminate()
 */

  /* 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_6);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.run.stop_func", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_process);
  __Pyx_XDECREF(__pyx_v_idx);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1580
 *             self._server = start_actor_server(self.cluster_info, self._dispatcher)
 * 
 *             def close():             # <<<<<<<<<<<<<<
 *                 self._server.stop()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_3close(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_3close = {"close", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_3close, METH_NOARGS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_3close(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("close (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_2close(__pyx_self);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_2close(PyObject *__pyx_self) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *__pyx_cur_scope;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *__pyx_outer_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("close", 0);
  __pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "mars/actors/pool/gevent_pool.pyx":1581
 * 
 *             def close():
 *                 self._server.stop()             # <<<<<<<<<<<<<<
 * 
 *             self._stop_funcs.append(close)
 */
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1581, __pyx_L1_error) }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->_server, __pyx_n_s_stop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1581, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1581, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1580
 *             self._server = start_actor_server(self.cluster_info, self._dispatcher)
 * 
 *             def close():             # <<<<<<<<<<<<<<
 *                 self._server.stop()
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.ActorPool.run.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_6generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "mars/actors/pool/gevent_pool.pyx":1556
 *         else:
 *             self._processes, self._comm_pipes, self._pool_pipes = [list(tp) for tp in zip(
 *                 *(self._start_process(idx) for idx in range(self.cluster_info.n_process))             # <<<<<<<<<<<<<<
 *             )]
 * 
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_4genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr *)__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr(__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1556, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_6generator1, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_run_locals_genexpr, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!gen)) __PYX_ERR(0, 1556, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.run.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_6generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr *__pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1556, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1556, __pyx_L1_error) }
  __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->cluster_info->n_process;
  __pyx_t_2 = __pyx_t_1;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_cur_scope->__pyx_v_idx = __pyx_t_3;
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1556, __pyx_L1_error) }
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_idx); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->__pyx_vtab)->_start_process(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_t_4, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1556, __pyx_L1_error)
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1546
 *         self._dispatcher.replace_pipe(idx)
 * 
 *     def run(self):             # <<<<<<<<<<<<<<
 *         if self._started:
 *             return
 */

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_14run(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *__pyx_cur_scope;
  PyObject *__pyx_v_stop_func = 0;
  PyObject *__pyx_v_close = 0;
  PyObject *__pyx_v_tp = NULL;
  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;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("run", 0);
  __pyx_cur_scope = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *)__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run(__pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1546, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);

  /* "mars/actors/pool/gevent_pool.pyx":1547
 * 
 *     def run(self):
 *         if self._started:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_self->_started != 0);
  if (__pyx_t_1) {

    /* "mars/actors/pool/gevent_pool.pyx":1548
 *     def run(self):
 *         if self._started:
 *             return             # <<<<<<<<<<<<<<
 * 
 *         if not self._multi_process:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "mars/actors/pool/gevent_pool.pyx":1547
 * 
 *     def run(self):
 *         if self._started:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1550
 *             return
 * 
 *         if not self._multi_process:             # <<<<<<<<<<<<<<
 *             # only start local pool
 *             self._dispatcher = start_local_pool(0, self.cluster_info, distributor=self.distributor,
 */
  __pyx_t_1 = ((!(__pyx_cur_scope->__pyx_v_self->_multi_process != 0)) != 0);
  if (__pyx_t_1) {

    /* "mars/actors/pool/gevent_pool.pyx":1552
 *         if not self._multi_process:
 *             # only start local pool
 *             self._dispatcher = start_local_pool(0, self.cluster_info, distributor=self.distributor,             # <<<<<<<<<<<<<<
 *                                                 parallel=self._parallel)
 *         else:
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_start_local_pool); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1552, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1552, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_0);
    __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->cluster_info));
    __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->cluster_info));
    PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_cur_scope->__pyx_v_self->cluster_info));
    __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1552, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_distributor, ((PyObject *)__pyx_cur_scope->__pyx_v_self->distributor)) < 0) __PYX_ERR(0, 1552, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":1553
 *             # only start local pool
 *             self._dispatcher = start_local_pool(0, self.cluster_info, distributor=self.distributor,
 *                                                 parallel=self._parallel)             # <<<<<<<<<<<<<<
 *         else:
 *             self._processes, self._comm_pipes, self._pool_pipes = [list(tp) for tp in zip(
 */
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_parallel, __pyx_cur_scope->__pyx_v_self->_parallel) < 0) __PYX_ERR(0, 1552, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":1552
 *         if not self._multi_process:
 *             # only start local pool
 *             self._dispatcher = start_local_pool(0, self.cluster_info, distributor=self.distributor,             # <<<<<<<<<<<<<<
 *                                                 parallel=self._parallel)
 *         else:
 */
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1552, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->_dispatcher);
    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->_dispatcher);
    __pyx_cur_scope->__pyx_v_self->_dispatcher = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1550
 *             return
 * 
 *         if not self._multi_process:             # <<<<<<<<<<<<<<
 *             # only start local pool
 *             self._dispatcher = start_local_pool(0, self.cluster_info, distributor=self.distributor,
 */
    goto __pyx_L4;
  }

  /* "mars/actors/pool/gevent_pool.pyx":1555
 *                                                 parallel=self._parallel)
 *         else:
 *             self._processes, self._comm_pipes, self._pool_pipes = [list(tp) for tp in zip(             # <<<<<<<<<<<<<<
 *                 *(self._start_process(idx) for idx in range(self.cluster_info.n_process))
 *             )]
 */
  /*else*/ {
    __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1555, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);

    /* "mars/actors/pool/gevent_pool.pyx":1556
 *         else:
 *             self._processes, self._comm_pipes, self._pool_pipes = [list(tp) for tp in zip(
 *                 *(self._start_process(idx) for idx in range(self.cluster_info.n_process))             # <<<<<<<<<<<<<<
 *             )]
 * 
 */
    __pyx_t_4 = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_4genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "mars/actors/pool/gevent_pool.pyx":1555
 *                                                 parallel=self._parallel)
 *         else:
 *             self._processes, self._comm_pipes, self._pool_pipes = [list(tp) for tp in zip(             # <<<<<<<<<<<<<<
 *                 *(self._start_process(idx) for idx in range(self.cluster_info.n_process))
 *             )]
 */
    __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1555, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1555, __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_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1555, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1555, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    for (;;) {
      if (likely(!__pyx_t_7)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 1555, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1555, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 1555, __pyx_L1_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1555, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        }
      } else {
        __pyx_t_4 = __pyx_t_7(__pyx_t_3);
        if (unlikely(!__pyx_t_4)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 1555, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_XDECREF_SET(__pyx_v_tp, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PySequence_List(__pyx_v_tp); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1555, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 1555, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (1) {
      PyObject* sequence = __pyx_t_5;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 1555, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 2); 
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1555, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1555, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1555, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      #endif
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    if (!(likely(PyList_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 1555, __pyx_L1_error)
    if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 1555, __pyx_L1_error)
    if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 1555, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->_processes);
    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->_processes);
    __pyx_cur_scope->__pyx_v_self->_processes = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->_comm_pipes);
    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->_comm_pipes);
    __pyx_cur_scope->__pyx_v_self->_comm_pipes = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->_pool_pipes);
    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->_pool_pipes);
    __pyx_cur_scope->__pyx_v_self->_pool_pipes = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1559
 *             )]
 * 
 *             def stop_func():             # <<<<<<<<<<<<<<
 *                 for process in self._processes:
 *                     process.terminate()
 */
    __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_1stop_func, 0, __pyx_n_s_run_locals_stop_func, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__37)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1559, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_v_stop_func = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1569
 *                     self._pool_pipes[idx] = None
 * 
 *             self._stop_funcs.append(stop_func)             # <<<<<<<<<<<<<<
 * 
 *             # start dispatcher
 */
    if (unlikely(__pyx_cur_scope->__pyx_v_self->_stop_funcs == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append");
      __PYX_ERR(0, 1569, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_self->_stop_funcs, __pyx_v_stop_func); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1569, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":1572
 * 
 *             # start dispatcher
 *             self._dispatcher = Dispatcher(self.cluster_info, self._pool_pipes,             # <<<<<<<<<<<<<<
 *                                           self.distributor)
 *             gevent.spawn(self._dispatcher.run)
 */
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->cluster_info));
    __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->cluster_info));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_cur_scope->__pyx_v_self->cluster_info));
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self->_pool_pipes);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self->_pool_pipes);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_cur_scope->__pyx_v_self->_pool_pipes);
    __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->distributor));
    __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->distributor));
    PyTuple_SET_ITEM(__pyx_t_5, 2, ((PyObject *)__pyx_cur_scope->__pyx_v_self->distributor));
    __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_Dispatcher), __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->_dispatcher);
    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->_dispatcher);
    __pyx_cur_scope->__pyx_v_self->_dispatcher = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1574
 *             self._dispatcher = Dispatcher(self.cluster_info, self._pool_pipes,
 *                                           self.distributor)
 *             gevent.spawn(self._dispatcher.run)             # <<<<<<<<<<<<<<
 * 
 *         if not self.cluster_info.standalone:
 */
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_gevent); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1574, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_spawn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1574, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self->_dispatcher, __pyx_n_s_run); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1574, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1574, __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;
  }
  __pyx_L4:;

  /* "mars/actors/pool/gevent_pool.pyx":1576
 *             gevent.spawn(self._dispatcher.run)
 * 
 *         if not self.cluster_info.standalone:             # <<<<<<<<<<<<<<
 *             # start stream server to handle remote message
 *             self._server = start_actor_server(self.cluster_info, self._dispatcher)
 */
  __pyx_t_1 = ((!(__pyx_cur_scope->__pyx_v_self->cluster_info->standalone != 0)) != 0);
  if (__pyx_t_1) {

    /* "mars/actors/pool/gevent_pool.pyx":1578
 *         if not self.cluster_info.standalone:
 *             # start stream server to handle remote message
 *             self._server = start_actor_server(self.cluster_info, self._dispatcher)             # <<<<<<<<<<<<<<
 * 
 *             def close():
 */
    __pyx_t_2 = ((PyObject *)__pyx_cur_scope->__pyx_v_self->cluster_info);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_4 = __pyx_cur_scope->__pyx_v_self->_dispatcher;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_5 = __pyx_f_4mars_6actors_4pool_11gevent_pool_start_actor_server(((struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *)__pyx_t_2), __pyx_t_4, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1578, __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_GIVEREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->_server);
    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->_server);
    __pyx_cur_scope->__pyx_v_self->_server = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1580
 *             self._server = start_actor_server(self.cluster_info, self._dispatcher)
 * 
 *             def close():             # <<<<<<<<<<<<<<
 *                 self._server.stop()
 * 
 */
    __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_9ActorPool_3run_3close, 0, __pyx_n_s_run_locals_close, ((PyObject*)__pyx_cur_scope), __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__38)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_v_close = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "mars/actors/pool/gevent_pool.pyx":1583
 *                 self._server.stop()
 * 
 *             self._stop_funcs.append(close)             # <<<<<<<<<<<<<<
 * 
 *         self._started = True
 */
    if (unlikely(__pyx_cur_scope->__pyx_v_self->_stop_funcs == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append");
      __PYX_ERR(0, 1583, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_self->_stop_funcs, __pyx_v_close); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1583, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":1576
 *             gevent.spawn(self._dispatcher.run)
 * 
 *         if not self.cluster_info.standalone:             # <<<<<<<<<<<<<<
 *             # start stream server to handle remote message
 *             self._server = start_actor_server(self.cluster_info, self._dispatcher)
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1585
 *             self._stop_funcs.append(close)
 * 
 *         self._started = True             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __pyx_cur_scope->__pyx_v_self->_started = 1;

  /* "mars/actors/pool/gevent_pool.pyx":1546
 *         self._dispatcher.replace_pipe(idx)
 * 
 *     def run(self):             # <<<<<<<<<<<<<<
 *         if self._started:
 *             return
 */

  /* 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_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.run", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_stop_func);
  __Pyx_XDECREF(__pyx_v_close);
  __Pyx_XDECREF(__pyx_v_tp);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1588
 * 
 *     @staticmethod
 *     def sleep(seconds):             # <<<<<<<<<<<<<<
 *         gevent.sleep(seconds)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_17sleep(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_9ActorPool_17sleep = {"sleep", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_17sleep, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_17sleep(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_seconds = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sleep (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_seconds,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) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_seconds)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sleep") < 0)) __PYX_ERR(0, 1588, __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_seconds = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sleep", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1588, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.sleep", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_16sleep(__pyx_v_seconds);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_16sleep(PyObject *__pyx_v_seconds) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("sleep", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1589
 *     @staticmethod
 *     def sleep(seconds):
 *         gevent.sleep(seconds)             # <<<<<<<<<<<<<<
 * 
 *     def join(self, timeout=None):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_sleep); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_seconds) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_seconds);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1589, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1588
 * 
 *     @staticmethod
 *     def sleep(seconds):             # <<<<<<<<<<<<<<
 *         gevent.sleep(seconds)
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.ActorPool.sleep", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1591
 *         gevent.sleep(seconds)
 * 
 *     def join(self, timeout=None):             # <<<<<<<<<<<<<<
 *         self._stopped.wait(timeout)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_19join(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_19join(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_timeout = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("join (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_timeout,0};
    PyObject* values[1] = {0};
    values[0] = ((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  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_timeout);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "join") < 0)) __PYX_ERR(0, 1591, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_timeout = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("join", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1591, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.join", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_18join(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self), __pyx_v_timeout);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_18join(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__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;
  __Pyx_RefNannySetupContext("join", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1592
 * 
 *     def join(self, timeout=None):
 *         self._stopped.wait(timeout)             # <<<<<<<<<<<<<<
 * 
 *     cpdef stop(self):
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_stopped, __pyx_n_s_wait); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1592, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_timeout) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_timeout);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1592, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1591
 *         gevent.sleep(seconds)
 * 
 *     def join(self, timeout=None):             # <<<<<<<<<<<<<<
 *         self._stopped.wait(timeout)
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.ActorPool.join", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1594
 *         self._stopped.wait(timeout)
 * 
 *     cpdef stop(self):             # <<<<<<<<<<<<<<
 *         try:
 *             for stop_func in self._stop_funcs:
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_21stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool_stop(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_stop_func = 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;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  char const *__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 = NULL;
  PyObject *__pyx_t_14 = NULL;
  __Pyx_RefNannySetupContext("stop", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1594, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_21stop)) {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && 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);
          }
        }
        __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1594, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":1595
 * 
 *     cpdef stop(self):
 *         try:             # <<<<<<<<<<<<<<
 *             for stop_func in self._stop_funcs:
 *                 stop_func()
 */
  /*try:*/ {

    /* "mars/actors/pool/gevent_pool.pyx":1596
 *     cpdef stop(self):
 *         try:
 *             for stop_func in self._stop_funcs:             # <<<<<<<<<<<<<<
 *                 stop_func()
 *         finally:
 */
    if (unlikely(__pyx_v_self->_stop_funcs == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 1596, __pyx_L4_error)
    }
    __pyx_t_1 = __pyx_v_self->_stop_funcs; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
    for (;;) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 1596, __pyx_L4_error)
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1596, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_stop_func, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":1597
 *         try:
 *             for stop_func in self._stop_funcs:
 *                 stop_func()             # <<<<<<<<<<<<<<
 *         finally:
 *             self._stopped.set()
 */
      __Pyx_INCREF(__pyx_v_stop_func);
      __pyx_t_3 = __pyx_v_stop_func; __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && 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);
        }
      }
      __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1597, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "mars/actors/pool/gevent_pool.pyx":1596
 *     cpdef stop(self):
 *         try:
 *             for stop_func in self._stop_funcs:             # <<<<<<<<<<<<<<
 *                 stop_func()
 *         finally:
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "mars/actors/pool/gevent_pool.pyx":1599
 *                 stop_func()
 *         finally:
 *             self._stopped.set()             # <<<<<<<<<<<<<<
 * 
 *     def __enter__(self):
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_stopped, __pyx_n_s_set); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1599, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1599, __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_L5;
    }
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      __pyx_t_6 = __pyx_lineno; __pyx_t_7 = __pyx_clineno; __pyx_t_8 = __pyx_filename;
      {
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_stopped, __pyx_n_s_set); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1599, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = NULL;
        if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1599, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      if (PY_MAJOR_VERSION >= 3) {
        __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);
      }
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_7; __pyx_filename = __pyx_t_8;
      goto __pyx_L1_error;
      __pyx_L9_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __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);
      }
      __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;
      __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L5:;
  }

  /* "mars/actors/pool/gevent_pool.pyx":1594
 *         self._stopped.wait(timeout)
 * 
 *     cpdef stop(self):             # <<<<<<<<<<<<<<
 *         try:
 *             for stop_func in self._stop_funcs:
 */

  /* 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("mars.actors.pool.gevent_pool.ActorPool.stop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_stop_func);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_21stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_21stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_20stop(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_20stop(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("stop", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool_stop(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.stop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1601
 *             self._stopped.set()
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         self.run()
 *         return self
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_23__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_23__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__enter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_22__enter__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_22__enter__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__enter__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1602
 * 
 *     def __enter__(self):
 *         self.run()             # <<<<<<<<<<<<<<
 *         return self
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_run); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1602, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1602, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1603
 *     def __enter__(self):
 *         self.run()
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __exit__(self, *_):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1601
 *             self._stopped.set()
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         self.run()
 *         return self
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1605
 *         return self
 * 
 *     def __exit__(self, *_):             # <<<<<<<<<<<<<<
 *         self.stop()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_25__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_25__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v__ = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__exit__ (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__exit__", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v__ = __pyx_args;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_24__exit__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self), __pyx_v__);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_24__exit__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v__) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__exit__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1606
 * 
 *     def __exit__(self, *_):
 *         self.stop()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self->__pyx_vtab)->stop(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1606, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1605
 *         return self
 * 
 *     def __exit__(self, *_):             # <<<<<<<<<<<<<<
 *         self.stop()
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1447
 *     """
 * 
 *     cdef public ClusterInfo cluster_info             # <<<<<<<<<<<<<<
 *     cdef public object _dispatcher
 *     cpdef public Distributor distributor
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->cluster_info));
  __pyx_r = ((PyObject *)__pyx_v_self->cluster_info);
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_4mars_6actors_7cluster_ClusterInfo))))) __PYX_ERR(0, 1447, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->cluster_info);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->cluster_info));
  __pyx_v_self->cluster_info = ((struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.cluster_info.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info_4__del__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->cluster_info);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->cluster_info));
  __pyx_v_self->cluster_info = ((struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *)Py_None);

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

/* "mars/actors/pool/gevent_pool.pyx":1448
 * 
 *     cdef public ClusterInfo cluster_info
 *     cdef public object _dispatcher             # <<<<<<<<<<<<<<
 *     cpdef public Distributor distributor
 *     cdef bint _started
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_dispatcher);
  __pyx_r = __pyx_v_self->_dispatcher;
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->_dispatcher);
  __Pyx_DECREF(__pyx_v_self->_dispatcher);
  __pyx_v_self->_dispatcher = __pyx_v_value;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher_4__del__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_dispatcher);
  __Pyx_DECREF(__pyx_v_self->_dispatcher);
  __pyx_v_self->_dispatcher = Py_None;

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

/* "mars/actors/pool/gevent_pool.pyx":1449
 *     cdef public ClusterInfo cluster_info
 *     cdef public object _dispatcher
 *     cpdef public Distributor distributor             # <<<<<<<<<<<<<<
 *     cdef bint _started
 *     cdef object _stopped
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->distributor));
  __pyx_r = ((PyObject *)__pyx_v_self->distributor);
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__set__", 0);
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_4mars_6actors_11distributor_Distributor))))) __PYX_ERR(0, 1449, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->distributor);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->distributor));
  __pyx_v_self->distributor = ((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.distributor.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor_4__del__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->distributor);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->distributor));
  __pyx_v_self->distributor = ((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)Py_None);

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

/* "mars/actors/pool/gevent_pool.pyx":1453
 *     cdef object _stopped
 *     cdef bint _multi_process
 *     cdef public object _server             # <<<<<<<<<<<<<<
 *     cdef object _parallel
 *     cdef list _stop_funcs
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server___get__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server___get__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_server);
  __pyx_r = __pyx_v_self->_server;
  goto __pyx_L0;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server_2__set__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self), ((PyObject *)__pyx_v_value));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server_2__set__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->_server);
  __Pyx_DECREF(__pyx_v_self->_server);
  __pyx_v_self->_server = __pyx_v_value;

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

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server_4__del__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self));

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server_4__del__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_server);
  __Pyx_DECREF(__pyx_v_self->_server);
  __pyx_v_self->_server = Py_None;

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

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_27__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_27__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_26__reduce_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_26__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  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_t_5;
  int __pyx_t_6;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self._comm_pipes, self._dispatcher, self._multi_process, self._parallel, self._pool_pipes, self._processes, self._server, self._started, self._stop_funcs, self._stopped, self.cluster_info, self.distributor)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_multi_process); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->_started); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(12); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_self->_comm_pipes);
  __Pyx_GIVEREF(__pyx_v_self->_comm_pipes);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->_comm_pipes);
  __Pyx_INCREF(__pyx_v_self->_dispatcher);
  __Pyx_GIVEREF(__pyx_v_self->_dispatcher);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->_dispatcher);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->_parallel);
  __Pyx_GIVEREF(__pyx_v_self->_parallel);
  PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_self->_parallel);
  __Pyx_INCREF(__pyx_v_self->_pool_pipes);
  __Pyx_GIVEREF(__pyx_v_self->_pool_pipes);
  PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_v_self->_pool_pipes);
  __Pyx_INCREF(__pyx_v_self->_processes);
  __Pyx_GIVEREF(__pyx_v_self->_processes);
  PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_v_self->_processes);
  __Pyx_INCREF(__pyx_v_self->_server);
  __Pyx_GIVEREF(__pyx_v_self->_server);
  PyTuple_SET_ITEM(__pyx_t_3, 6, __pyx_v_self->_server);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 7, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->_stop_funcs);
  __Pyx_GIVEREF(__pyx_v_self->_stop_funcs);
  PyTuple_SET_ITEM(__pyx_t_3, 8, __pyx_v_self->_stop_funcs);
  __Pyx_INCREF(__pyx_v_self->_stopped);
  __Pyx_GIVEREF(__pyx_v_self->_stopped);
  PyTuple_SET_ITEM(__pyx_t_3, 9, __pyx_v_self->_stopped);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->cluster_info));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->cluster_info));
  PyTuple_SET_ITEM(__pyx_t_3, 10, ((PyObject *)__pyx_v_self->cluster_info));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->distributor));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->distributor));
  PyTuple_SET_ITEM(__pyx_t_3, 11, ((PyObject *)__pyx_v_self->distributor));
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self._comm_pipes, self._dispatcher, self._multi_process, self._parallel, self._pool_pipes, self._processes, self._server, self._started, self._stop_funcs, self._stopped, self.cluster_info, self.distributor)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v__dict = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":7
 *     state = (self._comm_pipes, self._dispatcher, self._multi_process, self._parallel, self._pool_pipes, self._processes, self._server, self._started, self._stop_funcs, self._stopped, self.cluster_info, self.distributor)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_4 = (__pyx_v__dict != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict);
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self._comm_pipes is not None or self._dispatcher is not None or self._parallel is not None or self._pool_pipes is not None or self._processes is not None or self._server is not None or self._stop_funcs is not None or self._stopped is not None or self.cluster_info is not None or self.distributor is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self._comm_pipes, self._dispatcher, self._multi_process, self._parallel, self._pool_pipes, self._processes, self._server, self._started, self._stop_funcs, self._stopped, self.cluster_info, self.distributor)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self._comm_pipes is not None or self._dispatcher is not None or self._parallel is not None or self._pool_pipes is not None or self._processes is not None or self._server is not None or self._stop_funcs is not None or self._stopped is not None or self.cluster_info is not None or self.distributor is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_ActorPool, (type(self), 0xcbda5ce, None), state
 */
  /*else*/ {
    __pyx_t_4 = (__pyx_v_self->_comm_pipes != ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->_dispatcher != Py_None);
    __pyx_t_4 = (__pyx_t_6 != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_4 = (__pyx_v_self->_parallel != Py_None);
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->_pool_pipes != ((PyObject*)Py_None));
    __pyx_t_4 = (__pyx_t_6 != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_4 = (__pyx_v_self->_processes != ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->_server != Py_None);
    __pyx_t_4 = (__pyx_t_6 != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_4 = (__pyx_v_self->_stop_funcs != ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_self->_stopped != Py_None);
    __pyx_t_4 = (__pyx_t_6 != 0);
    if (!__pyx_t_4) {
    } else {
      __pyx_t_5 = __pyx_t_4;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_4 = (((PyObject *)__pyx_v_self->cluster_info) != Py_None);
    __pyx_t_6 = (__pyx_t_4 != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_6 = (((PyObject *)__pyx_v_self->distributor) != Py_None);
    __pyx_t_4 = (__pyx_t_6 != 0);
    __pyx_t_5 = __pyx_t_4;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_5;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._comm_pipes is not None or self._dispatcher is not None or self._parallel is not None or self._pool_pipes is not None or self._processes is not None or self._server is not None or self._stop_funcs is not None or self._stopped is not None or self.cluster_info is not None or self.distributor is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ActorPool, (type(self), 0xcbda5ce, None), state
 *     else:
 */
  __pyx_t_5 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_5) {

    /* "(tree fragment)":13
 *         use_setstate = self._comm_pipes is not None or self._dispatcher is not None or self._parallel is not None or self._pool_pipes is not None or self._processes is not None or self._server is not None or self._stop_funcs is not None or self._stopped is not None or self.cluster_info is not None or self.distributor is not None
 *     if use_setstate:
 *         return __pyx_unpickle_ActorPool, (type(self), 0xcbda5ce, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_ActorPool, (type(self), 0xcbda5ce, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pyx_unpickle_ActorPool); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_213755342);
    __Pyx_GIVEREF(__pyx_int_213755342);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_213755342);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self._comm_pipes is not None or self._dispatcher is not None or self._parallel is not None or self._pool_pipes is not None or self._processes is not None or self._server is not None or self._stop_funcs is not None or self._stopped is not None or self.cluster_info is not None or self.distributor is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ActorPool, (type(self), 0xcbda5ce, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_ActorPool, (type(self), 0xcbda5ce, None), state
 *     else:
 *         return __pyx_unpickle_ActorPool, (type(self), 0xcbda5ce, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ActorPool__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle_ActorPool); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_213755342);
    __Pyx_GIVEREF(__pyx_int_213755342);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_213755342);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ActorPool, (type(self), 0xcbda5ce, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ActorPool__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_29__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_29__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_28__setstate_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_9ActorPool_28__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_ActorPool, (type(self), 0xcbda5ce, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ActorPool__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorPool__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ActorPool, (type(self), 0xcbda5ce, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ActorPool__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorPool.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1612
 *     cdef object remote_handler
 * 
 *     def __init__(self, parallel=None):             # <<<<<<<<<<<<<<
 *         self.remote_handler = ActorRemoteHelper(parallel)
 * 
 */

/* Python wrapper */
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_parallel = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_parallel,0};
    PyObject* values[1] = {0};
    values[0] = ((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  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_parallel);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1612, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_parallel = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1612, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorClient.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient___init__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *)__pyx_v_self), __pyx_v_parallel);

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

static int __pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient___init__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self, PyObject *__pyx_v_parallel) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1613
 * 
 *     def __init__(self, parallel=None):
 *         self.remote_handler = ActorRemoteHelper(parallel)             # <<<<<<<<<<<<<<
 * 
 *     def create_actor(self, object actor_cls, *args, **kwargs):
 */
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper), __pyx_v_parallel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1613, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->remote_handler);
  __Pyx_DECREF(__pyx_v_self->remote_handler);
  __pyx_v_self->remote_handler = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1612
 *     cdef object remote_handler
 * 
 *     def __init__(self, parallel=None):             # <<<<<<<<<<<<<<
 *         self.remote_handler = ActorRemoteHelper(parallel)
 * 
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorClient.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1615
 *         self.remote_handler = ActorRemoteHelper(parallel)
 * 
 *     def create_actor(self, object actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef object address
 *         cdef object uid
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_3create_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_3create_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_actor_cls = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_actor (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_actor_cls,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);
        CYTHON_FALLTHROUGH;
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_cls)) != 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, "create_actor") < 0)) __PYX_ERR(0, 1615, __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_actor_cls = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_actor", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1615, __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("mars.actors.pool.gevent_pool.ActorClient.create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_2create_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *)__pyx_v_self), __pyx_v_actor_cls, __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_4mars_6actors_4pool_11gevent_pool_11ActorClient_2create_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self, PyObject *__pyx_v_actor_cls, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  PyObject *__pyx_v_address = 0;
  PyObject *__pyx_v_uid = 0;
  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;
  __Pyx_RefNannySetupContext("create_actor", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1619
 *         cdef object uid
 * 
 *         if 'address' not in kwargs or kwargs.get('address') is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('address must be provided')
 *         address = kwargs.pop('address')
 */
  __pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_address, __pyx_v_kwargs, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1619, __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_PyDict_GetItemDefault(__pyx_v_kwargs, __pyx_n_s_address, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1619, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = (__pyx_t_4 == Py_None);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_2 = (__pyx_t_3 != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_1)) {

    /* "mars/actors/pool/gevent_pool.pyx":1620
 * 
 *         if 'address' not in kwargs or kwargs.get('address') is None:
 *             raise ValueError('address must be provided')             # <<<<<<<<<<<<<<
 *         address = kwargs.pop('address')
 *         uid = kwargs.pop('uid', new_actor_id())
 */
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1620, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 1620, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":1619
 *         cdef object uid
 * 
 *         if 'address' not in kwargs or kwargs.get('address') is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('address must be provided')
 *         address = kwargs.pop('address')
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1621
 *         if 'address' not in kwargs or kwargs.get('address') is None:
 *             raise ValueError('address must be provided')
 *         address = kwargs.pop('address')             # <<<<<<<<<<<<<<
 *         uid = kwargs.pop('uid', new_actor_id())
 *         return self.remote_handler.create_actor(address, uid, actor_cls, *args, **kwargs)
 */
  __pyx_t_4 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_address, ((PyObject *)NULL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1621, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_address = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1622
 *             raise ValueError('address must be provided')
 *         address = kwargs.pop('address')
 *         uid = kwargs.pop('uid', new_actor_id())             # <<<<<<<<<<<<<<
 *         return self.remote_handler.create_actor(address, uid, actor_cls, *args, **kwargs)
 * 
 */
  __pyx_t_4 = __pyx_f_4mars_6actors_4pool_5utils_new_actor_id(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1622, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_uid, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1622, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_uid = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1623
 *         address = kwargs.pop('address')
 *         uid = kwargs.pop('uid', new_actor_id())
 *         return self.remote_handler.create_actor(address, uid, actor_cls, *args, **kwargs)             # <<<<<<<<<<<<<<
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->remote_handler, __pyx_n_s_create_actor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1623, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1623, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_address);
  __Pyx_GIVEREF(__pyx_v_address);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_address);
  __Pyx_INCREF(__pyx_v_uid);
  __Pyx_GIVEREF(__pyx_v_uid);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_uid);
  __Pyx_INCREF(__pyx_v_actor_cls);
  __Pyx_GIVEREF(__pyx_v_actor_cls);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_actor_cls);
  __pyx_t_6 = PyNumber_Add(__pyx_t_4, __pyx_v_args); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1623, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_v_kwargs); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1623, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1615
 *         self.remote_handler = ActorRemoteHelper(parallel)
 * 
 *     def create_actor(self, object actor_cls, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef object address
 *         cdef object uid
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorClient.create_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_address);
  __Pyx_XDECREF(__pyx_v_uid);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1625
 *         return self.remote_handler.create_actor(address, uid, actor_cls, *args, **kwargs)
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self.remote_handler.has_actor(actor_ref, wait=wait, callback=callback)
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_5has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_11ActorClient_has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_11ActorClient_has_actor *__pyx_optional_args) {
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  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;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("has_actor", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_wait = __pyx_optional_args->wait;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_callback = __pyx_optional_args->callback;
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_has_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1625, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_5has_actor)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1625, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        __pyx_t_6 = 0;
        if (CYTHON_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1625, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1625, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1625, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1625, __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_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":1626
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 *         return self.remote_handler.has_actor(actor_ref, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *     cpdef destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->remote_handler, __pyx_n_s_has_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_actor_ref));
  __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_wait, __pyx_t_7) < 0) __PYX_ERR(0, 1626, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1626, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1626, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1625
 *         return self.remote_handler.create_actor(address, uid, actor_cls, *args, **kwargs)
 * 
 *     cpdef object has_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self.remote_handler.has_actor(actor_ref, wait=wait, callback=callback)
 * 
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorClient.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_5has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_5has_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("has_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "has_actor") < 0)) __PYX_ERR(0, 1625, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    if (values[1]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1625, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("has_actor", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1625, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorClient.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 1625, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_4has_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_4has_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_11ActorClient_has_actor __pyx_t_2;
  __Pyx_RefNannySetupContext("has_actor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorClient->has_actor(__pyx_v_self, __pyx_v_actor_ref, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorClient.has_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1628
 *         return self.remote_handler.has_actor(actor_ref, wait=wait, callback=callback)
 * 
 *     cpdef destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self.remote_handler.destroy_actor(actor_ref, wait=wait, callback=callback)
 * 
 */

static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_7destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool_11ActorClient_destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_11ActorClient_destroy_actor *__pyx_optional_args) {
  int __pyx_v_wait = ((int)1);
  PyObject *__pyx_v_callback = ((PyObject *)Py_None);
  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;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("destroy_actor", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_wait = __pyx_optional_args->wait;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_callback = __pyx_optional_args->callback;
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
    #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    static PY_UINT64_T tp_dict_version = 0, obj_dict_version = 0;
    if (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict && tp_dict_version == __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) && (!Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset || obj_dict_version == __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))))));
    else {
      PY_UINT64_T type_dict_guard = (likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict)) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      #endif
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_destroy_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1628, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_7destroy_actor)) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1628, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
        __pyx_t_6 = 0;
        if (CYTHON_UNPACK_METHODS && 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;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1628, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_5, ((PyObject *)__pyx_v_actor_ref), __pyx_t_3, __pyx_v_callback};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1628, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1628, __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(((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_actor_ref));
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_callback);
          __Pyx_GIVEREF(__pyx_v_callback);
          PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_v_callback);
          __pyx_t_3 = 0;
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1628, __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_r = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L0;
      }
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
      tp_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) ? __PYX_GET_DICT_VERSION(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dict) : 0;
      obj_dict_version = likely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset) ? __PYX_GET_DICT_VERSION(_PyObject_GetDictPtr(((PyObject *)__pyx_v_self))) : 0;
      if (unlikely(type_dict_guard != tp_dict_version)) {
        tp_dict_version = obj_dict_version = 0;
      }
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP
    }
    #endif
  }

  /* "mars/actors/pool/gevent_pool.pyx":1629
 * 
 *     cpdef destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):
 *         return self.remote_handler.destroy_actor(actor_ref, wait=wait, callback=callback)             # <<<<<<<<<<<<<<
 * 
 *     def actor_ref(self, *args, **kwargs):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->remote_handler, __pyx_n_s_destroy_actor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_actor_ref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_actor_ref));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_actor_ref));
  __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_wait); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_wait, __pyx_t_7) < 0) __PYX_ERR(0, 1629, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_callback, __pyx_v_callback) < 0) __PYX_ERR(0, 1629, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1628
 *         return self.remote_handler.has_actor(actor_ref, wait=wait, callback=callback)
 * 
 *     cpdef destroy_actor(self, ActorRef actor_ref, bint wait=True, object callback=None):             # <<<<<<<<<<<<<<
 *         return self.remote_handler.destroy_actor(actor_ref, wait=wait, callback=callback)
 * 
 */

  /* 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_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorClient.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_7destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_7destroy_actor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref = 0;
  int __pyx_v_wait;
  PyObject *__pyx_v_callback = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("destroy_actor (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_actor_ref,&__pyx_n_s_wait,&__pyx_n_s_callback,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_actor_ref)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_wait);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_callback);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "destroy_actor") < 0)) __PYX_ERR(0, 1628, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_actor_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)values[0]);
    if (values[1]) {
      __pyx_v_wait = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_wait == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1628, __pyx_L3_error)
    } else {
      __pyx_v_wait = ((int)1);
    }
    __pyx_v_callback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("destroy_actor", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1628, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorClient.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_actor_ref), __pyx_ptype_4mars_6actors_4core_ActorRef, 1, "actor_ref", 0))) __PYX_ERR(0, 1628, __pyx_L1_error)
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_6destroy_actor(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *)__pyx_v_self), __pyx_v_actor_ref, __pyx_v_wait, __pyx_v_callback);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_6destroy_actor(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self, struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_actor_ref, int __pyx_v_wait, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_11ActorClient_destroy_actor __pyx_t_2;
  __Pyx_RefNannySetupContext("destroy_actor", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.wait = __pyx_v_wait;
  __pyx_t_2.callback = __pyx_v_callback;
  __pyx_t_1 = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorClient->destroy_actor(__pyx_v_self, __pyx_v_actor_ref, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1628, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorClient.destroy_actor", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1631
 *         return self.remote_handler.destroy_actor(actor_ref, wait=wait, callback=callback)
 * 
 *     def actor_ref(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef ActorRef ref
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_9actor_ref(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_9actor_ref(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("actor_ref (wrapper)", 0);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "actor_ref", 1))) return NULL;
  if (unlikely(__pyx_kwds)) {
    __pyx_v_kwargs = PyDict_Copy(__pyx_kwds); if (unlikely(!__pyx_v_kwargs)) return NULL;
    __Pyx_GOTREF(__pyx_v_kwargs);
  } else {
    __pyx_v_kwargs = NULL;
  }
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_8actor_ref(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *)__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_4mars_6actors_4pool_11gevent_pool_11ActorClient_8actor_ref(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_4mars_6actors_4core_ActorRef *__pyx_v_ref = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("actor_ref", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1634
 *         cdef ActorRef ref
 * 
 *         ref = self.remote_handler.actor_ref(*args, **kwargs)             # <<<<<<<<<<<<<<
 *         if ref.address is None:
 *             raise ValueError('address must be provided')
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->remote_handler, __pyx_n_s_actor_ref); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1634, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1634, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4mars_6actors_4core_ActorRef))))) __PYX_ERR(0, 1634, __pyx_L1_error)
  __pyx_v_ref = ((struct __pyx_obj_4mars_6actors_4core_ActorRef *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1635
 * 
 *         ref = self.remote_handler.actor_ref(*args, **kwargs)
 *         if ref.address is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('address must be provided')
 *         return ref
 */
  __pyx_t_3 = (__pyx_v_ref->address == ((PyObject*)Py_None));
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (unlikely(__pyx_t_4)) {

    /* "mars/actors/pool/gevent_pool.pyx":1636
 *         ref = self.remote_handler.actor_ref(*args, **kwargs)
 *         if ref.address is None:
 *             raise ValueError('address must be provided')             # <<<<<<<<<<<<<<
 *         return ref
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1636, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __PYX_ERR(0, 1636, __pyx_L1_error)

    /* "mars/actors/pool/gevent_pool.pyx":1635
 * 
 *         ref = self.remote_handler.actor_ref(*args, **kwargs)
 *         if ref.address is None:             # <<<<<<<<<<<<<<
 *             raise ValueError('address must be provided')
 *         return ref
 */
  }

  /* "mars/actors/pool/gevent_pool.pyx":1637
 *         if ref.address is None:
 *             raise ValueError('address must be provided')
 *         return ref             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_ref));
  __pyx_r = ((PyObject *)__pyx_v_ref);
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1631
 *         return self.remote_handler.destroy_actor(actor_ref, wait=wait, callback=callback)
 * 
 *     def actor_ref(self, *args, **kwargs):             # <<<<<<<<<<<<<<
 *         cdef ActorRef ref
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorClient.actor_ref", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_ref);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1640
 * 
 *     @staticmethod
 *     def sleep(seconds):             # <<<<<<<<<<<<<<
 *         gevent.sleep(seconds)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_11sleep(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_11ActorClient_11sleep = {"sleep", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_11sleep, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_11sleep(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_seconds = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sleep (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_seconds,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) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_seconds)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sleep") < 0)) __PYX_ERR(0, 1640, __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_seconds = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sleep", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1640, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorClient.sleep", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_10sleep(__pyx_v_seconds);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_10sleep(PyObject *__pyx_v_seconds) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("sleep", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1641
 *     @staticmethod
 *     def sleep(seconds):
 *         gevent.sleep(seconds)             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1641, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_sleep); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1641, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && 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_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_seconds) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_seconds);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1641, __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;

  /* "mars/actors/pool/gevent_pool.pyx":1640
 * 
 *     @staticmethod
 *     def sleep(seconds):             # <<<<<<<<<<<<<<
 *         gevent.sleep(seconds)
 * 
 */

  /* 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("mars.actors.pool.gevent_pool.ActorClient.sleep", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "mars/actors/pool/gevent_pool.pyx":1644
 * 
 *     @staticmethod
 *     def threadpool(num_threads):             # <<<<<<<<<<<<<<
 *         return ThreadPool(num_threads)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_13threadpool(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_11ActorClient_13threadpool = {"threadpool", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_13threadpool, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_13threadpool(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_num_threads = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("threadpool (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_num_threads,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) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_num_threads)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "threadpool") < 0)) __PYX_ERR(0, 1644, __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_num_threads = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("threadpool", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1644, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorClient.threadpool", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_12threadpool(__pyx_v_num_threads);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_12threadpool(PyObject *__pyx_v_num_threads) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("threadpool", 0);

  /* "mars/actors/pool/gevent_pool.pyx":1645
 *     @staticmethod
 *     def threadpool(num_threads):
 *         return ThreadPool(num_threads)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ThreadPool), __pyx_v_num_threads); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1645, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "mars/actors/pool/gevent_pool.pyx":1644
 * 
 *     @staticmethod
 *     def threadpool(num_threads):             # <<<<<<<<<<<<<<
 *         return ThreadPool(num_threads)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorClient.threadpool", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_14__reduce_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *)__pyx_v_self));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_14__reduce_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  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;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.remote_handler,)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->remote_handler);
  __Pyx_GIVEREF(__pyx_v_self->remote_handler);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->remote_handler);
  __pyx_v_state = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.remote_handler,)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v__dict = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":7
 *     state = (self.remote_handler,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_2 = (__pyx_v__dict != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.remote_handler is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.remote_handler,)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.remote_handler is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_ActorClient, (type(self), 0x2b57a74, None), state
 */
  /*else*/ {
    __pyx_t_3 = (__pyx_v_self->remote_handler != Py_None);
    __pyx_v_use_setstate = __pyx_t_3;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.remote_handler is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ActorClient, (type(self), 0x2b57a74, None), state
 *     else:
 */
  __pyx_t_3 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":13
 *         use_setstate = self.remote_handler is not None
 *     if use_setstate:
 *         return __pyx_unpickle_ActorClient, (type(self), 0x2b57a74, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_ActorClient, (type(self), 0x2b57a74, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_ActorClient); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_45447796);
    __Pyx_GIVEREF(__pyx_int_45447796);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_45447796);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
    __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __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_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
    __pyx_t_4 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.remote_handler is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ActorClient, (type(self), 0x2b57a74, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_ActorClient, (type(self), 0x2b57a74, None), state
 *     else:
 *         return __pyx_unpickle_ActorClient, (type(self), 0x2b57a74, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ActorClient__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_ActorClient); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_45447796);
    __Pyx_GIVEREF(__pyx_int_45447796);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_45447796);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorClient.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ActorClient, (type(self), 0x2b57a74, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ActorClient__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_16__setstate_cython__(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_11ActorClient_16__setstate_cython__(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);

  /* "(tree fragment)":17
 *         return __pyx_unpickle_ActorClient, (type(self), 0x2b57a74, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ActorClient__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorClient__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ActorClient, (type(self), 0x2b57a74, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ActorClient__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.ActorClient.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_MessageContext(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_7__pyx_unpickle_MessageContext(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_7__pyx_unpickle_MessageContext = {"__pyx_unpickle_MessageContext", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_7__pyx_unpickle_MessageContext, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_7__pyx_unpickle_MessageContext(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_MessageContext (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_MessageContext", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_MessageContext", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_MessageContext") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_MessageContext", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_MessageContext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_6__pyx_unpickle_MessageContext(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_6__pyx_unpickle_MessageContext(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  __Pyx_RefNannySetupContext("__pyx_unpickle_MessageContext", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x9212058:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9212058 = (async_result, message))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x9212058) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x9212058:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9212058 = (async_result, message))" % __pyx_checksum)
 *     __pyx_result = MessageContext.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x9212058:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9212058 = (async_result, message))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = MessageContext.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x92, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x9212058:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9212058 = (async_result, message))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9212058 = (async_result, message))" % __pyx_checksum)
 *     __pyx_result = MessageContext.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_MessageContext__set_state(<MessageContext> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_MessageContext), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9212058 = (async_result, message))" % __pyx_checksum)
 *     __pyx_result = MessageContext.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_MessageContext__set_state(<MessageContext> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = MessageContext.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_MessageContext__set_state(<MessageContext> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_MessageContext__set_state(MessageContext __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_MessageContext__set_state(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x9212058 = (async_result, message))" % __pyx_checksum)
 *     __pyx_result = MessageContext.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_MessageContext__set_state(<MessageContext> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_MessageContext__set_state(<MessageContext> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_MessageContext__set_state(MessageContext __pyx_result, tuple __pyx_state):
 *     __pyx_result.async_result = __pyx_state[0]; __pyx_result.message = __pyx_state[1]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_MessageContext(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* 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("mars.actors.pool.gevent_pool.__pyx_unpickle_MessageContext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_MessageContext__set_state(<MessageContext> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_MessageContext__set_state(MessageContext __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.async_result = __pyx_state[0]; __pyx_result.message = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_MessageContext__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_MessageContext__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_MessageContext__set_state(MessageContext __pyx_result, tuple __pyx_state):
 *     __pyx_result.async_result = __pyx_state[0]; __pyx_result.message = __pyx_state[1]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->async_result);
  __Pyx_DECREF(__pyx_v___pyx_result->async_result);
  __pyx_v___pyx_result->async_result = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->message);
  __Pyx_DECREF(__pyx_v___pyx_result->message);
  __pyx_v___pyx_result->message = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_MessageContext__set_state(MessageContext __pyx_result, tuple __pyx_state):
 *     __pyx_result.async_result = __pyx_state[0]; __pyx_result.message = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 2) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result.async_result = __pyx_state[0]; __pyx_result.message = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __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;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_MessageContext__set_state(MessageContext __pyx_result, tuple __pyx_state):
 *     __pyx_result.async_result = __pyx_state[0]; __pyx_result.message = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_MessageContext__set_state(<MessageContext> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_MessageContext__set_state(MessageContext __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.async_result = __pyx_state[0]; __pyx_result.message = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_MessageContext__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_ActorExecutionContext(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9__pyx_unpickle_ActorExecutionContext(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_9__pyx_unpickle_ActorExecutionContext = {"__pyx_unpickle_ActorExecutionContext", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9__pyx_unpickle_ActorExecutionContext, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_9__pyx_unpickle_ActorExecutionContext(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorExecutionContext (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorExecutionContext", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorExecutionContext", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_ActorExecutionContext") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorExecutionContext", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorExecutionContext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_8__pyx_unpickle_ActorExecutionContext(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_8__pyx_unpickle_ActorExecutionContext(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorExecutionContext", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xa6da11f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xa6da11f = (actor, comm, inbox, lock))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xa6da11f) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xa6da11f:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xa6da11f = (actor, comm, inbox, lock))" % __pyx_checksum)
 *     __pyx_result = ActorExecutionContext.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0xa6da11f:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xa6da11f = (actor, comm, inbox, lock))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = ActorExecutionContext.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xa6, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xa6da11f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xa6da11f = (actor, comm, inbox, lock))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xa6da11f = (actor, comm, inbox, lock))" % __pyx_checksum)
 *     __pyx_result = ActorExecutionContext.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorExecutionContext__set_state(<ActorExecutionContext> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xa6da11f = (actor, comm, inbox, lock))" % __pyx_checksum)
 *     __pyx_result = ActorExecutionContext.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ActorExecutionContext__set_state(<ActorExecutionContext> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = ActorExecutionContext.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorExecutionContext__set_state(<ActorExecutionContext> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorExecutionContext__set_state(ActorExecutionContext __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorExecutionContext__set_state(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xa6da11f = (actor, comm, inbox, lock))" % __pyx_checksum)
 *     __pyx_result = ActorExecutionContext.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ActorExecutionContext__set_state(<ActorExecutionContext> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorExecutionContext__set_state(<ActorExecutionContext> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_ActorExecutionContext__set_state(ActorExecutionContext __pyx_result, tuple __pyx_state):
 *     __pyx_result.actor = __pyx_state[0]; __pyx_result.comm = __pyx_state[1]; __pyx_result.inbox = __pyx_state[2]; __pyx_result.lock = __pyx_state[3]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_ActorExecutionContext(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* 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("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorExecutionContext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_ActorExecutionContext__set_state(<ActorExecutionContext> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorExecutionContext__set_state(ActorExecutionContext __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.actor = __pyx_state[0]; __pyx_result.comm = __pyx_state[1]; __pyx_result.inbox = __pyx_state[2]; __pyx_result.lock = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorExecutionContext__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorExecutionContext__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorExecutionContext__set_state(ActorExecutionContext __pyx_result, tuple __pyx_state):
 *     __pyx_result.actor = __pyx_state[0]; __pyx_result.comm = __pyx_state[1]; __pyx_result.inbox = __pyx_state[2]; __pyx_result.lock = __pyx_state[3]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->actor);
  __Pyx_DECREF(__pyx_v___pyx_result->actor);
  __pyx_v___pyx_result->actor = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->comm);
  __Pyx_DECREF(__pyx_v___pyx_result->comm);
  __pyx_v___pyx_result->comm = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->inbox);
  __Pyx_DECREF(__pyx_v___pyx_result->inbox);
  __pyx_v___pyx_result->inbox = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->lock);
  __Pyx_DECREF(__pyx_v___pyx_result->lock);
  __pyx_v___pyx_result->lock = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_ActorExecutionContext__set_state(ActorExecutionContext __pyx_result, tuple __pyx_state):
 *     __pyx_result.actor = __pyx_state[0]; __pyx_result.comm = __pyx_state[1]; __pyx_result.inbox = __pyx_state[2]; __pyx_result.lock = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 4) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result.actor = __pyx_state[0]; __pyx_result.comm = __pyx_state[1]; __pyx_result.inbox = __pyx_state[2]; __pyx_result.lock = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[4])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __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;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_ActorExecutionContext__set_state(ActorExecutionContext __pyx_result, tuple __pyx_state):
 *     __pyx_result.actor = __pyx_state[0]; __pyx_result.comm = __pyx_state[1]; __pyx_result.inbox = __pyx_state[2]; __pyx_result.lock = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_ActorExecutionContext__set_state(<ActorExecutionContext> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorExecutionContext__set_state(ActorExecutionContext __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.actor = __pyx_state[0]; __pyx_result.comm = __pyx_state[1]; __pyx_result.inbox = __pyx_state[2]; __pyx_result.lock = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorExecutionContext__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_ThreadPool(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11__pyx_unpickle_ThreadPool(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_11__pyx_unpickle_ThreadPool = {"__pyx_unpickle_ThreadPool", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11__pyx_unpickle_ThreadPool, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_11__pyx_unpickle_ThreadPool(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_ThreadPool (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ThreadPool", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ThreadPool", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_ThreadPool") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ThreadPool", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_ThreadPool", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_10__pyx_unpickle_ThreadPool(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_10__pyx_unpickle_ThreadPool(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ThreadPool", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xf753458:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xf753458 = (_pool))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xf753458) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xf753458:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xf753458 = (_pool))" % __pyx_checksum)
 *     __pyx_result = ThreadPool.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0xf753458:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xf753458 = (_pool))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = ThreadPool.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xf7, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xf753458:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xf753458 = (_pool))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xf753458 = (_pool))" % __pyx_checksum)
 *     __pyx_result = ThreadPool.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ThreadPool__set_state(<ThreadPool> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ThreadPool), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xf753458 = (_pool))" % __pyx_checksum)
 *     __pyx_result = ThreadPool.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ThreadPool__set_state(<ThreadPool> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = ThreadPool.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ThreadPool__set_state(<ThreadPool> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_ThreadPool__set_state(ThreadPool __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ThreadPool__set_state(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xf753458 = (_pool))" % __pyx_checksum)
 *     __pyx_result = ThreadPool.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ThreadPool__set_state(<ThreadPool> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ThreadPool__set_state(<ThreadPool> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_ThreadPool__set_state(ThreadPool __pyx_result, tuple __pyx_state):
 *     __pyx_result._pool = __pyx_state[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_ThreadPool(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* 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("mars.actors.pool.gevent_pool.__pyx_unpickle_ThreadPool", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_ThreadPool__set_state(<ThreadPool> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ThreadPool__set_state(ThreadPool __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._pool = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ThreadPool__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ThreadPool__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_ThreadPool__set_state(ThreadPool __pyx_result, tuple __pyx_state):
 *     __pyx_result._pool = __pyx_state[0]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_pool);
  __Pyx_DECREF(__pyx_v___pyx_result->_pool);
  __pyx_v___pyx_result->_pool = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_ThreadPool__set_state(ThreadPool __pyx_result, tuple __pyx_state):
 *     __pyx_result._pool = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result._pool = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __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;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_ThreadPool__set_state(ThreadPool __pyx_result, tuple __pyx_state):
 *     __pyx_result._pool = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_ThreadPool__set_state(<ThreadPool> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ThreadPool__set_state(ThreadPool __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._pool = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_ThreadPool__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_ActorContext(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_13__pyx_unpickle_ActorContext(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_13__pyx_unpickle_ActorContext = {"__pyx_unpickle_ActorContext", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_13__pyx_unpickle_ActorContext, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_13__pyx_unpickle_ActorContext(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorContext (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorContext", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorContext", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_ActorContext") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorContext", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorContext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_12__pyx_unpickle_ActorContext(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_12__pyx_unpickle_ActorContext(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorContext", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xb0b0700:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb0b0700 = (_comm))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xb0b0700) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xb0b0700:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb0b0700 = (_comm))" % __pyx_checksum)
 *     __pyx_result = ActorContext.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0xb0b0700:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb0b0700 = (_comm))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = ActorContext.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xb0, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xb0b0700:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb0b0700 = (_comm))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb0b0700 = (_comm))" % __pyx_checksum)
 *     __pyx_result = ActorContext.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorContext__set_state(<ActorContext> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb0b0700 = (_comm))" % __pyx_checksum)
 *     __pyx_result = ActorContext.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ActorContext__set_state(<ActorContext> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = ActorContext.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorContext__set_state(<ActorContext> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorContext__set_state(ActorContext __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorContext__set_state(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb0b0700 = (_comm))" % __pyx_checksum)
 *     __pyx_result = ActorContext.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ActorContext__set_state(<ActorContext> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorContext__set_state(<ActorContext> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_ActorContext__set_state(ActorContext __pyx_result, tuple __pyx_state):
 *     __pyx_result._comm = __pyx_state[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_ActorContext(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* 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("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorContext", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_ActorContext__set_state(<ActorContext> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorContext__set_state(ActorContext __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._comm = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorContext__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorContext__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorContext__set_state(ActorContext __pyx_result, tuple __pyx_state):
 *     __pyx_result._comm = __pyx_state[0]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_comm);
  __Pyx_DECREF(__pyx_v___pyx_result->_comm);
  __pyx_v___pyx_result->_comm = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_ActorContext__set_state(ActorContext __pyx_result, tuple __pyx_state):
 *     __pyx_result._comm = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result._comm = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __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;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_ActorContext__set_state(ActorContext __pyx_result, tuple __pyx_state):
 *     __pyx_result._comm = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_ActorContext__set_state(<ActorContext> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorContext__set_state(ActorContext __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._comm = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorContext__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_LocalActorPool(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_15__pyx_unpickle_LocalActorPool(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_15__pyx_unpickle_LocalActorPool = {"__pyx_unpickle_LocalActorPool", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_15__pyx_unpickle_LocalActorPool, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_15__pyx_unpickle_LocalActorPool(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_LocalActorPool (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_LocalActorPool", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_LocalActorPool", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_LocalActorPool") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_LocalActorPool", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_LocalActorPool", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_14__pyx_unpickle_LocalActorPool(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_14__pyx_unpickle_LocalActorPool(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  __Pyx_RefNannySetupContext("__pyx_unpickle_LocalActorPool", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x406a582:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x406a582 = (actors, address, comm_proxy, index))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x406a582) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x406a582:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x406a582 = (actors, address, comm_proxy, index))" % __pyx_checksum)
 *     __pyx_result = LocalActorPool.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x406a582:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x406a582 = (actors, address, comm_proxy, index))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = LocalActorPool.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x40, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x406a582:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x406a582 = (actors, address, comm_proxy, index))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x406a582 = (actors, address, comm_proxy, index))" % __pyx_checksum)
 *     __pyx_result = LocalActorPool.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_LocalActorPool__set_state(<LocalActorPool> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_LocalActorPool), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x406a582 = (actors, address, comm_proxy, index))" % __pyx_checksum)
 *     __pyx_result = LocalActorPool.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_LocalActorPool__set_state(<LocalActorPool> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = LocalActorPool.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_LocalActorPool__set_state(<LocalActorPool> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_LocalActorPool__set_state(LocalActorPool __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_LocalActorPool__set_state(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x406a582 = (actors, address, comm_proxy, index))" % __pyx_checksum)
 *     __pyx_result = LocalActorPool.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_LocalActorPool__set_state(<LocalActorPool> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_LocalActorPool__set_state(<LocalActorPool> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_LocalActorPool__set_state(LocalActorPool __pyx_result, tuple __pyx_state):
 *     __pyx_result.actors = __pyx_state[0]; __pyx_result.address = __pyx_state[1]; __pyx_result.comm_proxy = __pyx_state[2]; __pyx_result.index = __pyx_state[3]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_LocalActorPool(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* 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("mars.actors.pool.gevent_pool.__pyx_unpickle_LocalActorPool", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_LocalActorPool__set_state(<LocalActorPool> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_LocalActorPool__set_state(LocalActorPool __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.actors = __pyx_state[0]; __pyx_result.address = __pyx_state[1]; __pyx_result.comm_proxy = __pyx_state[2]; __pyx_result.index = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_LocalActorPool__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_LocalActorPool__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_LocalActorPool__set_state(LocalActorPool __pyx_result, tuple __pyx_state):
 *     __pyx_result.actors = __pyx_state[0]; __pyx_result.address = __pyx_state[1]; __pyx_result.comm_proxy = __pyx_state[2]; __pyx_result.index = __pyx_state[3]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->actors);
  __Pyx_DECREF(__pyx_v___pyx_result->actors);
  __pyx_v___pyx_result->actors = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->address);
  __Pyx_DECREF(__pyx_v___pyx_result->address);
  __pyx_v___pyx_result->address = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->comm_proxy);
  __Pyx_DECREF(__pyx_v___pyx_result->comm_proxy);
  __pyx_v___pyx_result->comm_proxy = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->index = __pyx_t_2;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_LocalActorPool__set_state(LocalActorPool __pyx_result, tuple __pyx_state):
 *     __pyx_result.actors = __pyx_state[0]; __pyx_result.address = __pyx_state[1]; __pyx_result.comm_proxy = __pyx_state[2]; __pyx_result.index = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 4) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":14
 *     __pyx_result.actors = __pyx_state[0]; __pyx_result.address = __pyx_state[1]; __pyx_result.comm_proxy = __pyx_state[2]; __pyx_result.index = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[4])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __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;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_LocalActorPool__set_state(LocalActorPool __pyx_result, tuple __pyx_state):
 *     __pyx_result.actors = __pyx_state[0]; __pyx_result.address = __pyx_state[1]; __pyx_result.comm_proxy = __pyx_state[2]; __pyx_result.index = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_LocalActorPool__set_state(<LocalActorPool> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_LocalActorPool__set_state(LocalActorPool __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.actors = __pyx_state[0]; __pyx_result.address = __pyx_state[1]; __pyx_result.comm_proxy = __pyx_state[2]; __pyx_result.index = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_LocalActorPool__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_AsyncHandler(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17__pyx_unpickle_AsyncHandler(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_17__pyx_unpickle_AsyncHandler = {"__pyx_unpickle_AsyncHandler", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17__pyx_unpickle_AsyncHandler, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_17__pyx_unpickle_AsyncHandler(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_AsyncHandler (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_AsyncHandler", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_AsyncHandler", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_AsyncHandler") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_AsyncHandler", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_AsyncHandler", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_16__pyx_unpickle_AsyncHandler(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_16__pyx_unpickle_AsyncHandler(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  __Pyx_RefNannySetupContext("__pyx_unpickle_AsyncHandler", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x2e761fc:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2e761fc = (async_results))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x2e761fc) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x2e761fc:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2e761fc = (async_results))" % __pyx_checksum)
 *     __pyx_result = AsyncHandler.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x2e761fc:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2e761fc = (async_results))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = AsyncHandler.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x2e, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x2e761fc:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2e761fc = (async_results))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2e761fc = (async_results))" % __pyx_checksum)
 *     __pyx_result = AsyncHandler.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_AsyncHandler__set_state(<AsyncHandler> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_AsyncHandler), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2e761fc = (async_results))" % __pyx_checksum)
 *     __pyx_result = AsyncHandler.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_AsyncHandler__set_state(<AsyncHandler> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = AsyncHandler.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_AsyncHandler__set_state(<AsyncHandler> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_AsyncHandler__set_state(AsyncHandler __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_AsyncHandler__set_state(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2e761fc = (async_results))" % __pyx_checksum)
 *     __pyx_result = AsyncHandler.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_AsyncHandler__set_state(<AsyncHandler> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_AsyncHandler__set_state(<AsyncHandler> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_AsyncHandler__set_state(AsyncHandler __pyx_result, tuple __pyx_state):
 *     __pyx_result.async_results = __pyx_state[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_AsyncHandler(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* 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("mars.actors.pool.gevent_pool.__pyx_unpickle_AsyncHandler", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_AsyncHandler__set_state(<AsyncHandler> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_AsyncHandler__set_state(AsyncHandler __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.async_results = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_AsyncHandler__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_AsyncHandler__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_AsyncHandler__set_state(AsyncHandler __pyx_result, tuple __pyx_state):
 *     __pyx_result.async_results = __pyx_state[0]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->async_results);
  __Pyx_DECREF(__pyx_v___pyx_result->async_results);
  __pyx_v___pyx_result->async_results = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_AsyncHandler__set_state(AsyncHandler __pyx_result, tuple __pyx_state):
 *     __pyx_result.async_results = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result.async_results = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __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;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_AsyncHandler__set_state(AsyncHandler __pyx_result, tuple __pyx_state):
 *     __pyx_result.async_results = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_AsyncHandler__set_state(<AsyncHandler> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_AsyncHandler__set_state(AsyncHandler __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.async_results = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_AsyncHandler__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Connection(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_19__pyx_unpickle_Connection(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_19__pyx_unpickle_Connection = {"__pyx_unpickle_Connection", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_19__pyx_unpickle_Connection, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_19__pyx_unpickle_Connection(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Connection (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Connection", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Connection", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Connection") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Connection", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_Connection", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_18__pyx_unpickle_Connection(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_18__pyx_unpickle_Connection(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Connection", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xe946d0d:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xe946d0d = (conn, lock))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xe946d0d) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xe946d0d:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xe946d0d = (conn, lock))" % __pyx_checksum)
 *     __pyx_result = Connection.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0xe946d0d:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xe946d0d = (conn, lock))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Connection.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xe9, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xe946d0d:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xe946d0d = (conn, lock))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xe946d0d = (conn, lock))" % __pyx_checksum)
 *     __pyx_result = Connection.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Connection__set_state(<Connection> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_Connection), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xe946d0d = (conn, lock))" % __pyx_checksum)
 *     __pyx_result = Connection.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Connection__set_state(<Connection> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = Connection.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Connection__set_state(<Connection> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Connection__set_state(Connection __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_Connection__set_state(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xe946d0d = (conn, lock))" % __pyx_checksum)
 *     __pyx_result = Connection.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Connection__set_state(<Connection> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Connection__set_state(<Connection> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Connection__set_state(Connection __pyx_result, tuple __pyx_state):
 *     __pyx_result.conn = __pyx_state[0]; __pyx_result.lock = __pyx_state[1]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Connection(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* 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("mars.actors.pool.gevent_pool.__pyx_unpickle_Connection", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Connection__set_state(<Connection> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Connection__set_state(Connection __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.conn = __pyx_state[0]; __pyx_result.lock = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_Connection__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Connection__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Connection__set_state(Connection __pyx_result, tuple __pyx_state):
 *     __pyx_result.conn = __pyx_state[0]; __pyx_result.lock = __pyx_state[1]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->conn);
  __Pyx_DECREF(__pyx_v___pyx_result->conn);
  __pyx_v___pyx_result->conn = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->lock);
  __Pyx_DECREF(__pyx_v___pyx_result->lock);
  __pyx_v___pyx_result->lock = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_Connection__set_state(Connection __pyx_result, tuple __pyx_state):
 *     __pyx_result.conn = __pyx_state[0]; __pyx_result.lock = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 2) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result.conn = __pyx_state[0]; __pyx_result.lock = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[2])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __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;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Connection__set_state(Connection __pyx_result, tuple __pyx_state):
 *     __pyx_result.conn = __pyx_state[0]; __pyx_result.lock = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[2])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Connection__set_state(<Connection> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Connection__set_state(Connection __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.conn = __pyx_state[0]; __pyx_result.lock = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_Connection__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_ActorRemoteHelper(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21__pyx_unpickle_ActorRemoteHelper(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_21__pyx_unpickle_ActorRemoteHelper = {"__pyx_unpickle_ActorRemoteHelper", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_21__pyx_unpickle_ActorRemoteHelper, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_21__pyx_unpickle_ActorRemoteHelper(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorRemoteHelper (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorRemoteHelper", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorRemoteHelper", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_ActorRemoteHelper") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorRemoteHelper", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorRemoteHelper", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_20__pyx_unpickle_ActorRemoteHelper(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_20__pyx_unpickle_ActorRemoteHelper(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorRemoteHelper", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x162dc4f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x162dc4f = (_connections, _lock, _parallel, _pool))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x162dc4f) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x162dc4f:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x162dc4f = (_connections, _lock, _parallel, _pool))" % __pyx_checksum)
 *     __pyx_result = ActorRemoteHelper.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x162dc4f:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x162dc4f = (_connections, _lock, _parallel, _pool))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = ActorRemoteHelper.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x16, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x162dc4f:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x162dc4f = (_connections, _lock, _parallel, _pool))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x162dc4f = (_connections, _lock, _parallel, _pool))" % __pyx_checksum)
 *     __pyx_result = ActorRemoteHelper.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorRemoteHelper__set_state(<ActorRemoteHelper> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x162dc4f = (_connections, _lock, _parallel, _pool))" % __pyx_checksum)
 *     __pyx_result = ActorRemoteHelper.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ActorRemoteHelper__set_state(<ActorRemoteHelper> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = ActorRemoteHelper.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorRemoteHelper__set_state(<ActorRemoteHelper> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorRemoteHelper__set_state(ActorRemoteHelper __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorRemoteHelper__set_state(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x162dc4f = (_connections, _lock, _parallel, _pool))" % __pyx_checksum)
 *     __pyx_result = ActorRemoteHelper.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ActorRemoteHelper__set_state(<ActorRemoteHelper> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorRemoteHelper__set_state(<ActorRemoteHelper> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_ActorRemoteHelper__set_state(ActorRemoteHelper __pyx_result, tuple __pyx_state):
 *     __pyx_result._connections = __pyx_state[0]; __pyx_result._lock = __pyx_state[1]; __pyx_result._parallel = __pyx_state[2]; __pyx_result._pool = __pyx_state[3]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_ActorRemoteHelper(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* 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("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorRemoteHelper", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_ActorRemoteHelper__set_state(<ActorRemoteHelper> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorRemoteHelper__set_state(ActorRemoteHelper __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._connections = __pyx_state[0]; __pyx_result._lock = __pyx_state[1]; __pyx_result._parallel = __pyx_state[2]; __pyx_result._pool = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorRemoteHelper__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorRemoteHelper__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorRemoteHelper__set_state(ActorRemoteHelper __pyx_result, tuple __pyx_state):
 *     __pyx_result._connections = __pyx_state[0]; __pyx_result._lock = __pyx_state[1]; __pyx_result._parallel = __pyx_state[2]; __pyx_result._pool = __pyx_state[3]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_connections);
  __Pyx_DECREF(__pyx_v___pyx_result->_connections);
  __pyx_v___pyx_result->_connections = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_lock);
  __Pyx_DECREF(__pyx_v___pyx_result->_lock);
  __pyx_v___pyx_result->_lock = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_parallel);
  __Pyx_DECREF(__pyx_v___pyx_result->_parallel);
  __pyx_v___pyx_result->_parallel = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_pool);
  __Pyx_DECREF(__pyx_v___pyx_result->_pool);
  __pyx_v___pyx_result->_pool = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_ActorRemoteHelper__set_state(ActorRemoteHelper __pyx_result, tuple __pyx_state):
 *     __pyx_result._connections = __pyx_state[0]; __pyx_result._lock = __pyx_state[1]; __pyx_result._parallel = __pyx_state[2]; __pyx_result._pool = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 4) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result._connections = __pyx_state[0]; __pyx_result._lock = __pyx_state[1]; __pyx_result._parallel = __pyx_state[2]; __pyx_result._pool = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[4])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __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;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_ActorRemoteHelper__set_state(ActorRemoteHelper __pyx_result, tuple __pyx_state):
 *     __pyx_result._connections = __pyx_state[0]; __pyx_result._lock = __pyx_state[1]; __pyx_result._parallel = __pyx_state[2]; __pyx_result._pool = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[4])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_ActorRemoteHelper__set_state(<ActorRemoteHelper> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorRemoteHelper__set_state(ActorRemoteHelper __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._connections = __pyx_state[0]; __pyx_result._lock = __pyx_state[1]; __pyx_result._parallel = __pyx_state[2]; __pyx_result._pool = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorRemoteHelper__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Communicator(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_23__pyx_unpickle_Communicator(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_23__pyx_unpickle_Communicator = {"__pyx_unpickle_Communicator", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_23__pyx_unpickle_Communicator, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_23__pyx_unpickle_Communicator(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Communicator (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Communicator", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Communicator", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Communicator") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Communicator", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_Communicator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_22__pyx_unpickle_Communicator(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_22__pyx_unpickle_Communicator(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Communicator", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xd3b2268:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd3b2268 = (_handlers, async_results, cluster_info, distributor, index, pipe, pool, remote_handler, running))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xd3b2268) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xd3b2268:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd3b2268 = (_handlers, async_results, cluster_info, distributor, index, pipe, pool, remote_handler, running))" % __pyx_checksum)
 *     __pyx_result = Communicator.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0xd3b2268:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd3b2268 = (_handlers, async_results, cluster_info, distributor, index, pipe, pool, remote_handler, running))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Communicator.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xd3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xd3b2268:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd3b2268 = (_handlers, async_results, cluster_info, distributor, index, pipe, pool, remote_handler, running))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd3b2268 = (_handlers, async_results, cluster_info, distributor, index, pipe, pool, remote_handler, running))" % __pyx_checksum)
 *     __pyx_result = Communicator.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Communicator__set_state(<Communicator> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_Communicator), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd3b2268 = (_handlers, async_results, cluster_info, distributor, index, pipe, pool, remote_handler, running))" % __pyx_checksum)
 *     __pyx_result = Communicator.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Communicator__set_state(<Communicator> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = Communicator.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Communicator__set_state(<Communicator> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Communicator__set_state(Communicator __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_Communicator__set_state(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd3b2268 = (_handlers, async_results, cluster_info, distributor, index, pipe, pool, remote_handler, running))" % __pyx_checksum)
 *     __pyx_result = Communicator.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Communicator__set_state(<Communicator> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Communicator__set_state(<Communicator> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Communicator__set_state(Communicator __pyx_result, tuple __pyx_state):
 *     __pyx_result._handlers = __pyx_state[0]; __pyx_result.async_results = __pyx_state[1]; __pyx_result.cluster_info = __pyx_state[2]; __pyx_result.distributor = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.pipe = __pyx_state[5]; __pyx_result.pool = __pyx_state[6]; __pyx_result.remote_handler = __pyx_state[7]; __pyx_result.running = __pyx_state[8]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Communicator(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* 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("mars.actors.pool.gevent_pool.__pyx_unpickle_Communicator", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Communicator__set_state(<Communicator> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Communicator__set_state(Communicator __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._handlers = __pyx_state[0]; __pyx_result.async_results = __pyx_state[1]; __pyx_result.cluster_info = __pyx_state[2]; __pyx_result.distributor = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.pipe = __pyx_state[5]; __pyx_result.pool = __pyx_state[6]; __pyx_result.remote_handler = __pyx_state[7]; __pyx_result.running = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_Communicator__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Communicator__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Communicator__set_state(Communicator __pyx_result, tuple __pyx_state):
 *     __pyx_result._handlers = __pyx_state[0]; __pyx_result.async_results = __pyx_state[1]; __pyx_result.cluster_info = __pyx_state[2]; __pyx_result.distributor = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.pipe = __pyx_state[5]; __pyx_result.pool = __pyx_state[6]; __pyx_result.remote_handler = __pyx_state[7]; __pyx_result.running = __pyx_state[8]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[9])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_handlers);
  __Pyx_DECREF(__pyx_v___pyx_result->_handlers);
  __pyx_v___pyx_result->_handlers = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.async_results);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.async_results);
  __pyx_v___pyx_result->__pyx_base.async_results = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4mars_6actors_7cluster_ClusterInfo))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->cluster_info);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->cluster_info));
  __pyx_v___pyx_result->cluster_info = ((struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4mars_6actors_11distributor_Distributor))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->distributor);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->distributor));
  __pyx_v___pyx_result->distributor = ((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->index = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->pipe);
  __Pyx_DECREF(__pyx_v___pyx_result->pipe);
  __pyx_v___pyx_result->pipe = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->pool);
  __Pyx_DECREF(__pyx_v___pyx_result->pool);
  __pyx_v___pyx_result->pool = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->remote_handler);
  __Pyx_DECREF(__pyx_v___pyx_result->remote_handler);
  __pyx_v___pyx_result->remote_handler = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->running);
  __Pyx_DECREF(__pyx_v___pyx_result->running);
  __pyx_v___pyx_result->running = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_Communicator__set_state(Communicator __pyx_result, tuple __pyx_state):
 *     __pyx_result._handlers = __pyx_state[0]; __pyx_result.async_results = __pyx_state[1]; __pyx_result.cluster_info = __pyx_state[2]; __pyx_result.distributor = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.pipe = __pyx_state[5]; __pyx_result.pool = __pyx_state[6]; __pyx_result.remote_handler = __pyx_state[7]; __pyx_result.running = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[9])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 9) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":14
 *     __pyx_result._handlers = __pyx_state[0]; __pyx_result.async_results = __pyx_state[1]; __pyx_result.cluster_info = __pyx_state[2]; __pyx_result.distributor = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.pipe = __pyx_state[5]; __pyx_result.pool = __pyx_state[6]; __pyx_result.remote_handler = __pyx_state[7]; __pyx_result.running = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[9])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 9, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __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;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Communicator__set_state(Communicator __pyx_result, tuple __pyx_state):
 *     __pyx_result._handlers = __pyx_state[0]; __pyx_result.async_results = __pyx_state[1]; __pyx_result.cluster_info = __pyx_state[2]; __pyx_result.distributor = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.pipe = __pyx_state[5]; __pyx_result.pool = __pyx_state[6]; __pyx_result.remote_handler = __pyx_state[7]; __pyx_result.running = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[9])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Communicator__set_state(<Communicator> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Communicator__set_state(Communicator __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._handlers = __pyx_state[0]; __pyx_result.async_results = __pyx_state[1]; __pyx_result.cluster_info = __pyx_state[2]; __pyx_result.distributor = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.pipe = __pyx_state[5]; __pyx_result.pool = __pyx_state[6]; __pyx_result.remote_handler = __pyx_state[7]; __pyx_result.running = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_Communicator__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Dispatcher(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_25__pyx_unpickle_Dispatcher(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_25__pyx_unpickle_Dispatcher = {"__pyx_unpickle_Dispatcher", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_25__pyx_unpickle_Dispatcher, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_25__pyx_unpickle_Dispatcher(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Dispatcher (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Dispatcher", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Dispatcher", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Dispatcher") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Dispatcher", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_Dispatcher", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_24__pyx_unpickle_Dispatcher(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_24__pyx_unpickle_Dispatcher(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Dispatcher", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x3781f9c:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x3781f9c = (async_results, checker_group, cluster_info, distributor, handlers, index, pipe_checkers, pipes, remote_handler))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x3781f9c) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x3781f9c:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x3781f9c = (async_results, checker_group, cluster_info, distributor, handlers, index, pipe_checkers, pipes, remote_handler))" % __pyx_checksum)
 *     __pyx_result = Dispatcher.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x3781f9c:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x3781f9c = (async_results, checker_group, cluster_info, distributor, handlers, index, pipe_checkers, pipes, remote_handler))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Dispatcher.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x37, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x3781f9c:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x3781f9c = (async_results, checker_group, cluster_info, distributor, handlers, index, pipe_checkers, pipes, remote_handler))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x3781f9c = (async_results, checker_group, cluster_info, distributor, handlers, index, pipe_checkers, pipes, remote_handler))" % __pyx_checksum)
 *     __pyx_result = Dispatcher.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Dispatcher__set_state(<Dispatcher> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_Dispatcher), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x3781f9c = (async_results, checker_group, cluster_info, distributor, handlers, index, pipe_checkers, pipes, remote_handler))" % __pyx_checksum)
 *     __pyx_result = Dispatcher.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Dispatcher__set_state(<Dispatcher> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = Dispatcher.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Dispatcher__set_state(<Dispatcher> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Dispatcher__set_state(Dispatcher __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_Dispatcher__set_state(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x3781f9c = (async_results, checker_group, cluster_info, distributor, handlers, index, pipe_checkers, pipes, remote_handler))" % __pyx_checksum)
 *     __pyx_result = Dispatcher.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Dispatcher__set_state(<Dispatcher> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Dispatcher__set_state(<Dispatcher> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Dispatcher__set_state(Dispatcher __pyx_result, tuple __pyx_state):
 *     __pyx_result.async_results = __pyx_state[0]; __pyx_result.checker_group = __pyx_state[1]; __pyx_result.cluster_info = __pyx_state[2]; __pyx_result.distributor = __pyx_state[3]; __pyx_result.handlers = __pyx_state[4]; __pyx_result.index = __pyx_state[5]; __pyx_result.pipe_checkers = __pyx_state[6]; __pyx_result.pipes = __pyx_state[7]; __pyx_result.remote_handler = __pyx_state[8]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Dispatcher(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* 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("mars.actors.pool.gevent_pool.__pyx_unpickle_Dispatcher", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Dispatcher__set_state(<Dispatcher> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Dispatcher__set_state(Dispatcher __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.async_results = __pyx_state[0]; __pyx_result.checker_group = __pyx_state[1]; __pyx_result.cluster_info = __pyx_state[2]; __pyx_result.distributor = __pyx_state[3]; __pyx_result.handlers = __pyx_state[4]; __pyx_result.index = __pyx_state[5]; __pyx_result.pipe_checkers = __pyx_state[6]; __pyx_result.pipes = __pyx_state[7]; __pyx_result.remote_handler = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_Dispatcher__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Dispatcher__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Dispatcher__set_state(Dispatcher __pyx_result, tuple __pyx_state):
 *     __pyx_result.async_results = __pyx_state[0]; __pyx_result.checker_group = __pyx_state[1]; __pyx_result.cluster_info = __pyx_state[2]; __pyx_result.distributor = __pyx_state[3]; __pyx_result.handlers = __pyx_state[4]; __pyx_result.index = __pyx_state[5]; __pyx_result.pipe_checkers = __pyx_state[6]; __pyx_result.pipes = __pyx_state[7]; __pyx_result.remote_handler = __pyx_state[8]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[9])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.async_results);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.async_results);
  __pyx_v___pyx_result->__pyx_base.async_results = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->checker_group);
  __Pyx_DECREF(__pyx_v___pyx_result->checker_group);
  __pyx_v___pyx_result->checker_group = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4mars_6actors_7cluster_ClusterInfo))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->cluster_info);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->cluster_info));
  __pyx_v___pyx_result->cluster_info = ((struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->distributor);
  __Pyx_DECREF(__pyx_v___pyx_result->distributor);
  __pyx_v___pyx_result->distributor = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->handlers);
  __Pyx_DECREF(__pyx_v___pyx_result->handlers);
  __pyx_v___pyx_result->handlers = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->index = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->pipe_checkers);
  __Pyx_DECREF(__pyx_v___pyx_result->pipe_checkers);
  __pyx_v___pyx_result->pipe_checkers = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->pipes);
  __Pyx_DECREF(__pyx_v___pyx_result->pipes);
  __pyx_v___pyx_result->pipes = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->remote_handler);
  __Pyx_DECREF(__pyx_v___pyx_result->remote_handler);
  __pyx_v___pyx_result->remote_handler = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_Dispatcher__set_state(Dispatcher __pyx_result, tuple __pyx_state):
 *     __pyx_result.async_results = __pyx_state[0]; __pyx_result.checker_group = __pyx_state[1]; __pyx_result.cluster_info = __pyx_state[2]; __pyx_result.distributor = __pyx_state[3]; __pyx_result.handlers = __pyx_state[4]; __pyx_result.index = __pyx_state[5]; __pyx_result.pipe_checkers = __pyx_state[6]; __pyx_result.pipes = __pyx_state[7]; __pyx_result.remote_handler = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[9])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = ((__pyx_t_4 > 9) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_3 = __pyx_t_5;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_6 = (__pyx_t_5 != 0);
  __pyx_t_3 = __pyx_t_6;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_3) {

    /* "(tree fragment)":14
 *     __pyx_result.async_results = __pyx_state[0]; __pyx_result.checker_group = __pyx_state[1]; __pyx_result.cluster_info = __pyx_state[2]; __pyx_result.distributor = __pyx_state[3]; __pyx_result.handlers = __pyx_state[4]; __pyx_result.index = __pyx_state[5]; __pyx_result.pipe_checkers = __pyx_state[6]; __pyx_result.pipes = __pyx_state[7]; __pyx_result.remote_handler = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[9])             # <<<<<<<<<<<<<<
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 9, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __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;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Dispatcher__set_state(Dispatcher __pyx_result, tuple __pyx_state):
 *     __pyx_result.async_results = __pyx_state[0]; __pyx_result.checker_group = __pyx_state[1]; __pyx_result.cluster_info = __pyx_state[2]; __pyx_result.distributor = __pyx_state[3]; __pyx_result.handlers = __pyx_state[4]; __pyx_result.index = __pyx_state[5]; __pyx_result.pipe_checkers = __pyx_state[6]; __pyx_result.pipes = __pyx_state[7]; __pyx_result.remote_handler = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[9])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Dispatcher__set_state(<Dispatcher> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Dispatcher__set_state(Dispatcher __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.async_results = __pyx_state[0]; __pyx_result.checker_group = __pyx_state[1]; __pyx_result.cluster_info = __pyx_state[2]; __pyx_result.distributor = __pyx_state[3]; __pyx_result.handlers = __pyx_state[4]; __pyx_result.index = __pyx_state[5]; __pyx_result.pipe_checkers = __pyx_state[6]; __pyx_result.pipes = __pyx_state[7]; __pyx_result.remote_handler = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_Dispatcher__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_ActorServerHandler(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_27__pyx_unpickle_ActorServerHandler(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_27__pyx_unpickle_ActorServerHandler = {"__pyx_unpickle_ActorServerHandler", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_27__pyx_unpickle_ActorServerHandler, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_27__pyx_unpickle_ActorServerHandler(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorServerHandler (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorServerHandler", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorServerHandler", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_ActorServerHandler") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorServerHandler", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorServerHandler", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_26__pyx_unpickle_ActorServerHandler(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_26__pyx_unpickle_ActorServerHandler(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorServerHandler", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x061f3cd:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x061f3cd = (multi_process, sender, server))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x061f3cd) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x061f3cd:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x061f3cd = (multi_process, sender, server))" % __pyx_checksum)
 *     __pyx_result = ActorServerHandler.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x061f3cd:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x061f3cd = (multi_process, sender, server))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = ActorServerHandler.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x06, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x061f3cd:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x061f3cd = (multi_process, sender, server))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x061f3cd = (multi_process, sender, server))" % __pyx_checksum)
 *     __pyx_result = ActorServerHandler.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorServerHandler__set_state(<ActorServerHandler> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorServerHandler), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x061f3cd = (multi_process, sender, server))" % __pyx_checksum)
 *     __pyx_result = ActorServerHandler.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ActorServerHandler__set_state(<ActorServerHandler> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = ActorServerHandler.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorServerHandler__set_state(<ActorServerHandler> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorServerHandler__set_state(ActorServerHandler __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorServerHandler__set_state(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x061f3cd = (multi_process, sender, server))" % __pyx_checksum)
 *     __pyx_result = ActorServerHandler.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ActorServerHandler__set_state(<ActorServerHandler> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorServerHandler__set_state(<ActorServerHandler> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_ActorServerHandler__set_state(ActorServerHandler __pyx_result, tuple __pyx_state):
 *     __pyx_result.multi_process = __pyx_state[0]; __pyx_result.sender = __pyx_state[1]; __pyx_result.server = __pyx_state[2]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_ActorServerHandler(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* 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("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorServerHandler", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_ActorServerHandler__set_state(<ActorServerHandler> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorServerHandler__set_state(ActorServerHandler __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.multi_process = __pyx_state[0]; __pyx_result.sender = __pyx_state[1]; __pyx_result.server = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorServerHandler__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorServerHandler__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorServerHandler__set_state(ActorServerHandler __pyx_result, tuple __pyx_state):
 *     __pyx_result.multi_process = __pyx_state[0]; __pyx_result.sender = __pyx_state[1]; __pyx_result.server = __pyx_state[2]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->multi_process = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->sender);
  __Pyx_DECREF(__pyx_v___pyx_result->sender);
  __pyx_v___pyx_result->sender = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->server);
  __Pyx_DECREF(__pyx_v___pyx_result->server);
  __pyx_v___pyx_result->server = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_ActorServerHandler__set_state(ActorServerHandler __pyx_result, tuple __pyx_state):
 *     __pyx_result.multi_process = __pyx_state[0]; __pyx_result.sender = __pyx_state[1]; __pyx_result.server = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 3) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result.multi_process = __pyx_state[0]; __pyx_result.sender = __pyx_state[1]; __pyx_result.server = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[3])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __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;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_ActorServerHandler__set_state(ActorServerHandler __pyx_result, tuple __pyx_state):
 *     __pyx_result.multi_process = __pyx_state[0]; __pyx_result.sender = __pyx_state[1]; __pyx_result.server = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[3])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_ActorServerHandler__set_state(<ActorServerHandler> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorServerHandler__set_state(ActorServerHandler __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.multi_process = __pyx_state[0]; __pyx_result.sender = __pyx_state[1]; __pyx_result.server = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorServerHandler__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_ActorPool(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_29__pyx_unpickle_ActorPool(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_29__pyx_unpickle_ActorPool = {"__pyx_unpickle_ActorPool", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_29__pyx_unpickle_ActorPool, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_29__pyx_unpickle_ActorPool(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorPool (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorPool", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorPool", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_ActorPool") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorPool", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorPool", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_28__pyx_unpickle_ActorPool(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_28__pyx_unpickle_ActorPool(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorPool", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xcbda5ce:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xcbda5ce = (_comm_pipes, _dispatcher, _multi_process, _parallel, _pool_pipes, _processes, _server, _started, _stop_funcs, _stopped, cluster_info, distributor))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xcbda5ce) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xcbda5ce:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xcbda5ce = (_comm_pipes, _dispatcher, _multi_process, _parallel, _pool_pipes, _processes, _server, _started, _stop_funcs, _stopped, cluster_info, distributor))" % __pyx_checksum)
 *     __pyx_result = ActorPool.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0xcbda5ce:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xcbda5ce = (_comm_pipes, _dispatcher, _multi_process, _parallel, _pool_pipes, _processes, _server, _started, _stop_funcs, _stopped, cluster_info, distributor))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = ActorPool.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xcb, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0xcbda5ce:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xcbda5ce = (_comm_pipes, _dispatcher, _multi_process, _parallel, _pool_pipes, _processes, _server, _started, _stop_funcs, _stopped, cluster_info, distributor))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xcbda5ce = (_comm_pipes, _dispatcher, _multi_process, _parallel, _pool_pipes, _processes, _server, _started, _stop_funcs, _stopped, cluster_info, distributor))" % __pyx_checksum)
 *     __pyx_result = ActorPool.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorPool__set_state(<ActorPool> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorPool), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xcbda5ce = (_comm_pipes, _dispatcher, _multi_process, _parallel, _pool_pipes, _processes, _server, _started, _stop_funcs, _stopped, cluster_info, distributor))" % __pyx_checksum)
 *     __pyx_result = ActorPool.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ActorPool__set_state(<ActorPool> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = ActorPool.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorPool__set_state(<ActorPool> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorPool__set_state(ActorPool __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorPool__set_state(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xcbda5ce = (_comm_pipes, _dispatcher, _multi_process, _parallel, _pool_pipes, _processes, _server, _started, _stop_funcs, _stopped, cluster_info, distributor))" % __pyx_checksum)
 *     __pyx_result = ActorPool.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ActorPool__set_state(<ActorPool> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorPool__set_state(<ActorPool> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_ActorPool__set_state(ActorPool __pyx_result, tuple __pyx_state):
 *     __pyx_result._comm_pipes = __pyx_state[0]; __pyx_result._dispatcher = __pyx_state[1]; __pyx_result._multi_process = __pyx_state[2]; __pyx_result._parallel = __pyx_state[3]; __pyx_result._pool_pipes = __pyx_state[4]; __pyx_result._processes = __pyx_state[5]; __pyx_result._server = __pyx_state[6]; __pyx_result._started = __pyx_state[7]; __pyx_result._stop_funcs = __pyx_state[8]; __pyx_result._stopped = __pyx_state[9]; __pyx_result.cluster_info = __pyx_state[10]; __pyx_result.distributor = __pyx_state[11]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_ActorPool(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* 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("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorPool", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_ActorPool__set_state(<ActorPool> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorPool__set_state(ActorPool __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._comm_pipes = __pyx_state[0]; __pyx_result._dispatcher = __pyx_state[1]; __pyx_result._multi_process = __pyx_state[2]; __pyx_result._parallel = __pyx_state[3]; __pyx_result._pool_pipes = __pyx_state[4]; __pyx_result._processes = __pyx_state[5]; __pyx_result._server = __pyx_state[6]; __pyx_result._started = __pyx_state[7]; __pyx_result._stop_funcs = __pyx_state[8]; __pyx_result._stopped = __pyx_state[9]; __pyx_result.cluster_info = __pyx_state[10]; __pyx_result.distributor = __pyx_state[11]
 *     if len(__pyx_state) > 12 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorPool__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorPool__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorPool__set_state(ActorPool __pyx_result, tuple __pyx_state):
 *     __pyx_result._comm_pipes = __pyx_state[0]; __pyx_result._dispatcher = __pyx_state[1]; __pyx_result._multi_process = __pyx_state[2]; __pyx_result._parallel = __pyx_state[3]; __pyx_result._pool_pipes = __pyx_state[4]; __pyx_result._processes = __pyx_state[5]; __pyx_result._server = __pyx_state[6]; __pyx_result._started = __pyx_state[7]; __pyx_result._stop_funcs = __pyx_state[8]; __pyx_result._stopped = __pyx_state[9]; __pyx_result.cluster_info = __pyx_state[10]; __pyx_result.distributor = __pyx_state[11]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 12 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[12])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_comm_pipes);
  __Pyx_DECREF(__pyx_v___pyx_result->_comm_pipes);
  __pyx_v___pyx_result->_comm_pipes = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_dispatcher);
  __Pyx_DECREF(__pyx_v___pyx_result->_dispatcher);
  __pyx_v___pyx_result->_dispatcher = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->_multi_process = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_parallel);
  __Pyx_DECREF(__pyx_v___pyx_result->_parallel);
  __pyx_v___pyx_result->_parallel = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_pool_pipes);
  __Pyx_DECREF(__pyx_v___pyx_result->_pool_pipes);
  __pyx_v___pyx_result->_pool_pipes = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_processes);
  __Pyx_DECREF(__pyx_v___pyx_result->_processes);
  __pyx_v___pyx_result->_processes = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_server);
  __Pyx_DECREF(__pyx_v___pyx_result->_server);
  __pyx_v___pyx_result->_server = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->_started = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_stop_funcs);
  __Pyx_DECREF(__pyx_v___pyx_result->_stop_funcs);
  __pyx_v___pyx_result->_stop_funcs = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 9, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->_stopped);
  __Pyx_DECREF(__pyx_v___pyx_result->_stopped);
  __pyx_v___pyx_result->_stopped = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 10, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4mars_6actors_7cluster_ClusterInfo))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->cluster_info);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->cluster_info));
  __pyx_v___pyx_result->cluster_info = ((struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 11, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4mars_6actors_11distributor_Distributor))))) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->distributor);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->distributor));
  __pyx_v___pyx_result->distributor = ((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_ActorPool__set_state(ActorPool __pyx_result, tuple __pyx_state):
 *     __pyx_result._comm_pipes = __pyx_state[0]; __pyx_result._dispatcher = __pyx_state[1]; __pyx_result._multi_process = __pyx_state[2]; __pyx_result._parallel = __pyx_state[3]; __pyx_result._pool_pipes = __pyx_state[4]; __pyx_result._processes = __pyx_state[5]; __pyx_result._server = __pyx_state[6]; __pyx_result._started = __pyx_state[7]; __pyx_result._stop_funcs = __pyx_state[8]; __pyx_result._stopped = __pyx_state[9]; __pyx_result.cluster_info = __pyx_state[10]; __pyx_result.distributor = __pyx_state[11]
 *     if len(__pyx_state) > 12 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[12])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 12) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result._comm_pipes = __pyx_state[0]; __pyx_result._dispatcher = __pyx_state[1]; __pyx_result._multi_process = __pyx_state[2]; __pyx_result._parallel = __pyx_state[3]; __pyx_result._pool_pipes = __pyx_state[4]; __pyx_result._processes = __pyx_state[5]; __pyx_result._server = __pyx_state[6]; __pyx_result._started = __pyx_state[7]; __pyx_result._stop_funcs = __pyx_state[8]; __pyx_result._stopped = __pyx_state[9]; __pyx_result.cluster_info = __pyx_state[10]; __pyx_result.distributor = __pyx_state[11]
 *     if len(__pyx_state) > 12 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[12])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 12, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __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;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_ActorPool__set_state(ActorPool __pyx_result, tuple __pyx_state):
 *     __pyx_result._comm_pipes = __pyx_state[0]; __pyx_result._dispatcher = __pyx_state[1]; __pyx_result._multi_process = __pyx_state[2]; __pyx_result._parallel = __pyx_state[3]; __pyx_result._pool_pipes = __pyx_state[4]; __pyx_result._processes = __pyx_state[5]; __pyx_result._server = __pyx_state[6]; __pyx_result._started = __pyx_state[7]; __pyx_result._stop_funcs = __pyx_state[8]; __pyx_result._stopped = __pyx_state[9]; __pyx_result.cluster_info = __pyx_state[10]; __pyx_result.distributor = __pyx_state[11]
 *     if len(__pyx_state) > 12 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[12])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_ActorPool__set_state(<ActorPool> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorPool__set_state(ActorPool __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._comm_pipes = __pyx_state[0]; __pyx_result._dispatcher = __pyx_state[1]; __pyx_result._multi_process = __pyx_state[2]; __pyx_result._parallel = __pyx_state[3]; __pyx_result._pool_pipes = __pyx_state[4]; __pyx_result._processes = __pyx_state[5]; __pyx_result._server = __pyx_state[6]; __pyx_result._started = __pyx_state[7]; __pyx_result._stop_funcs = __pyx_state[8]; __pyx_result._stopped = __pyx_state[9]; __pyx_result.cluster_info = __pyx_state[10]; __pyx_result.distributor = __pyx_state[11]
 *     if len(__pyx_state) > 12 and hasattr(__pyx_result, '__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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorPool__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_ActorClient(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_31__pyx_unpickle_ActorClient(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4mars_6actors_4pool_11gevent_pool_31__pyx_unpickle_ActorClient = {"__pyx_unpickle_ActorClient", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_31__pyx_unpickle_ActorClient, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4mars_6actors_4pool_11gevent_pool_31__pyx_unpickle_ActorClient(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorClient (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,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);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorClient", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorClient", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_ActorClient") < 0)) __PYX_ERR(1, 1, __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___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ActorClient", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorClient", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4mars_6actors_4pool_11gevent_pool_30__pyx_unpickle_ActorClient(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

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

static PyObject *__pyx_pf_4mars_6actors_4pool_11gevent_pool_30__pyx_unpickle_ActorClient(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  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_t_6;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorClient", 0);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x2b57a74:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2b57a74 = (remote_handler))" % __pyx_checksum)
 */
  __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x2b57a74) != 0);
  if (__pyx_t_1) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x2b57a74:
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2b57a74 = (remote_handler))" % __pyx_checksum)
 *     __pyx_result = ActorClient.__new__(__pyx_type)
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
    __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v___pyx_PickleError = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum != 0x2b57a74:
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2b57a74 = (remote_handler))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = ActorClient.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x2b, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(1, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum != 0x2b57a74:             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2b57a74 = (remote_handler))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2b57a74 = (remote_handler))" % __pyx_checksum)
 *     __pyx_result = ActorClient.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorClient__set_state(<ActorClient> __pyx_result, __pyx_state)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorClient), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v___pyx_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2b57a74 = (remote_handler))" % __pyx_checksum)
 *     __pyx_result = ActorClient.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ActorClient__set_state(<ActorClient> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_6 = (__pyx_t_1 != 0);
  if (__pyx_t_6) {

    /* "(tree fragment)":9
 *     __pyx_result = ActorClient.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorClient__set_state(<ActorClient> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorClient__set_state(ActorClient __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
    __pyx_t_3 = __pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorClient__set_state(((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (%s vs 0x2b57a74 = (remote_handler))" % __pyx_checksum)
 *     __pyx_result = ActorClient.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ActorClient__set_state(<ActorClient> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ActorClient__set_state(<ActorClient> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_ActorClient__set_state(ActorClient __pyx_result, tuple __pyx_state):
 *     __pyx_result.remote_handler = __pyx_state[0]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_ActorClient(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* 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("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorClient", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_ActorClient__set_state(<ActorClient> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorClient__set_state(ActorClient __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.remote_handler = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4mars_6actors_4pool_11gevent_pool___pyx_unpickle_ActorClient__set_state(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ActorClient__set_state", 0);

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorClient__set_state(ActorClient __pyx_result, tuple __pyx_state):
 *     __pyx_result.remote_handler = __pyx_state[0]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(1, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->remote_handler);
  __Pyx_DECREF(__pyx_v___pyx_result->remote_handler);
  __pyx_v___pyx_result->remote_handler = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_ActorClient__set_state(ActorClient __pyx_result, tuple __pyx_state):
 *     __pyx_result.remote_handler = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 13, __pyx_L1_error)
  }
  __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_2) {

    /* "(tree fragment)":14
 *     __pyx_result.remote_handler = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 14, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && 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);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __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;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_ActorClient__set_state(ActorClient __pyx_result, tuple __pyx_state):
 *     __pyx_result.remote_handler = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[1])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_ActorClient__set_state(<ActorClient> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorClient__set_state(ActorClient __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.remote_handler = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("mars.actors.pool.gevent_pool.__pyx_unpickle_ActorClient__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":258
 *         # experimental exception made for __getbuffer__ and __releasebuffer__
 *         # -- the details of this may change.
 *         def __getbuffer__(ndarray self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fulfill the PEP.
 */

/* Python wrapper */
static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));

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

static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_v_i;
  int __pyx_v_ndim;
  int __pyx_v_endian_detector;
  int __pyx_v_little_endian;
  int __pyx_v_t;
  char *__pyx_v_f;
  PyArray_Descr *__pyx_v_descr = 0;
  int __pyx_v_offset;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyArray_Descr *__pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  char *__pyx_t_9;
  if (__pyx_v_info == NULL) {
    PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
    return -1;
  }
  __Pyx_RefNannySetupContext("__getbuffer__", 0);
  __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(__pyx_v_info->obj);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":265
 * 
 *             cdef int i, ndim
 *             cdef int endian_detector = 1             # <<<<<<<<<<<<<<
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 * 
 */
  __pyx_v_endian_detector = 1;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":266
 *             cdef int i, ndim
 *             cdef int endian_detector = 1
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
 * 
 *             ndim = PyArray_NDIM(self)
 */
  __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":268
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 * 
 *             ndim = PyArray_NDIM(self)             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 */
  __pyx_v_ndim = PyArray_NDIM(__pyx_v_self);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":270
 *             ndim = PyArray_NDIM(self)
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")
 */
  __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":271
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 */
  __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_ARRAY_C_CONTIGUOUS) != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":270
 *             ndim = PyArray_NDIM(self)
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")
 */
  if (unlikely(__pyx_t_1)) {

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":272
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 272, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 272, __pyx_L1_error)

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":270
 *             ndim = PyArray_NDIM(self)
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")
 */
  }

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":274
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 */
  __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L7_bool_binop_done;
  }

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":275
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 * 
 */
  __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_ARRAY_F_CONTIGUOUS) != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L7_bool_binop_done:;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":274
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 */
  if (unlikely(__pyx_t_1)) {

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":276
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")             # <<<<<<<<<<<<<<
 * 
 *             info.buf = PyArray_DATA(self)
 */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_ERR(2, 276, __pyx_L1_error)

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":274
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 */
  }

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":278
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 * 
 *             info.buf = PyArray_DATA(self)             # <<<<<<<<<<<<<<
 *             info.ndim = ndim
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  __pyx_v_info->buf = PyArray_DATA(__pyx_v_self);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":279
 * 
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim             # <<<<<<<<<<<<<<
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 # Allocate new buffer for strides and shape info.
 */
  __pyx_v_info->ndim = __pyx_v_ndim;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":280
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 # Allocate new buffer for strides and shape info.
 *                 # This is allocated as one block, strides first.
 */
  __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
  if (__pyx_t_1) {

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":283
 *                 # Allocate new buffer for strides and shape info.
 *                 # This is allocated as one block, strides first.
 *                 info.strides = <Py_ssize_t*>PyObject_Malloc(sizeof(Py_ssize_t) * 2 * <size_t>ndim)             # <<<<<<<<<<<<<<
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):
 */
    __pyx_v_info->strides = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * 2) * ((size_t)__pyx_v_ndim))));

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":284
 *                 # This is allocated as one block, strides first.
 *                 info.strides = <Py_ssize_t*>PyObject_Malloc(sizeof(Py_ssize_t) * 2 * <size_t>ndim)
 *                 info.shape = info.strides + ndim             # <<<<<<<<<<<<<<
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 */
    __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim);

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":285
 *                 info.strides = <Py_ssize_t*>PyObject_Malloc(sizeof(Py_ssize_t) * 2 * <size_t>ndim)
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):             # <<<<<<<<<<<<<<
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 */
    __pyx_t_4 = __pyx_v_ndim;
    __pyx_t_5 = __pyx_t_4;
    for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
      __pyx_v_i = __pyx_t_6;

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":286
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]             # <<<<<<<<<<<<<<
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 *             else:
 */
      (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]);

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":287
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 *                     info.shape[i] = PyArray_DIMS(self)[i]             # <<<<<<<<<<<<<<
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 */
      (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]);
    }

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":280
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 # Allocate new buffer for strides and shape info.
 *                 # This is allocated as one block, strides first.
 */
    goto __pyx_L9;
  }

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":289
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)             # <<<<<<<<<<<<<<
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL
 */
  /*else*/ {
    __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self));

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":290
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)             # <<<<<<<<<<<<<<
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)
 */
    __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self));
  }
  __pyx_L9:;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":291
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
 *             info.itemsize = PyArray_ITEMSIZE(self)
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 */
  __pyx_v_info->suboffsets = NULL;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":292
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)             # <<<<<<<<<<<<<<
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 * 
 */
  __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":293
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)
 *             info.readonly = not PyArray_ISWRITEABLE(self)             # <<<<<<<<<<<<<<
 * 
 *             cdef int t
 */
  __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0));

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":296
 * 
 *             cdef int t
 *             cdef char* f = NULL             # <<<<<<<<<<<<<<
 *             cdef dtype descr = <dtype>PyArray_DESCR(self)
 *             cdef int offset
 */
  __pyx_v_f = NULL;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":297
 *             cdef int t
 *             cdef char* f = NULL
 *             cdef dtype descr = <dtype>PyArray_DESCR(self)             # <<<<<<<<<<<<<<
 *             cdef int offset
 * 
 */
  __pyx_t_7 = PyArray_DESCR(__pyx_v_self);
  __pyx_t_3 = ((PyObject *)__pyx_t_7);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":300
 *             cdef int offset
 * 
 *             info.obj = self             # <<<<<<<<<<<<<<
 * 
 *             if not PyDataType_HASFIELDS(descr):
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __Pyx_GOTREF(__pyx_v_info->obj);
  __Pyx_DECREF(__pyx_v_info->obj);
  __pyx_v_info->obj = ((PyObject *)__pyx_v_self);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":302
 *             info.obj = self
 * 
 *             if not PyDataType_HASFIELDS(descr):             # <<<<<<<<<<<<<<
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or
 */
  __pyx_t_1 = ((!(PyDataType_HASFIELDS(__pyx_v_descr) != 0)) != 0);
  if (__pyx_t_1) {

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":303
 * 
 *             if not PyDataType_HASFIELDS(descr):
 *                 t = descr.type_num             # <<<<<<<<<<<<<<
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):
 */
    __pyx_t_4 = __pyx_v_descr->type_num;
    __pyx_v_t = __pyx_t_4;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":304
 *             if not PyDataType_HASFIELDS(descr):
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 */
    __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0);
    if (!__pyx_t_2) {
      goto __pyx_L15_next_or;
    } else {
    }
    __pyx_t_2 = (__pyx_v_little_endian != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L14_bool_binop_done;
    }
    __pyx_L15_next_or:;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":305
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):             # <<<<<<<<<<<<<<
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"
 */
    __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L14_bool_binop_done;
    }
    __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L14_bool_binop_done:;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":304
 *             if not PyDataType_HASFIELDS(descr):
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 */
    if (unlikely(__pyx_t_1)) {

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":306
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 306, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(2, 306, __pyx_L1_error)

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":304
 *             if not PyDataType_HASFIELDS(descr):
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 */
    }

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":307
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"
 */
    switch (__pyx_v_t) {
      case NPY_BYTE:
      __pyx_v_f = ((char *)"b");
      break;
      case NPY_UBYTE:

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":308
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"
 */
      __pyx_v_f = ((char *)"B");
      break;
      case NPY_SHORT:

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":309
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"
 */
      __pyx_v_f = ((char *)"h");
      break;
      case NPY_USHORT:

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":310
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"
 */
      __pyx_v_f = ((char *)"H");
      break;
      case NPY_INT:

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":311
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"
 */
      __pyx_v_f = ((char *)"i");
      break;
      case NPY_UINT:

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":312
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"
 */
      __pyx_v_f = ((char *)"I");
      break;
      case NPY_LONG:

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":313
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"
 */
      __pyx_v_f = ((char *)"l");
      break;
      case NPY_ULONG:

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":314
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 */
      __pyx_v_f = ((char *)"L");
      break;
      case NPY_LONGLONG:

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":315
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"
 */
      __pyx_v_f = ((char *)"q");
      break;
      case NPY_ULONGLONG:

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":316
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"
 */
      __pyx_v_f = ((char *)"Q");
      break;
      case NPY_FLOAT:

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":317
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 */
      __pyx_v_f = ((char *)"f");
      break;
      case NPY_DOUBLE:

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":318
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 */
      __pyx_v_f = ((char *)"d");
      break;
      case NPY_LONGDOUBLE:

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":319
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 */
      __pyx_v_f = ((char *)"g");
      break;
      case NPY_CFLOAT:

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":320
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 */
      __pyx_v_f = ((char *)"Zf");
      break;
      case NPY_CDOUBLE:

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":321
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"
 */
      __pyx_v_f = ((char *)"Zd");
      break;
      case NPY_CLONGDOUBLE:

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":322
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_OBJECT:      f = "O"
 *                 else:
 */
      __pyx_v_f = ((char *)"Zg");
      break;
      case NPY_OBJECT:

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":323
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 */
      __pyx_v_f = ((char *)"O");
      break;
      default:

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":325
 *                 elif t == NPY_OBJECT:      f = "O"
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 *                 info.format = f
 *                 return
 */
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 325, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 325, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 325, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(2, 325, __pyx_L1_error)
      break;
    }

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":326
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *                 info.format = f             # <<<<<<<<<<<<<<
 *                 return
 *             else:
 */
    __pyx_v_info->format = __pyx_v_f;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":327
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *                 info.format = f
 *                 return             # <<<<<<<<<<<<<<
 *             else:
 *                 info.format = <char*>PyObject_Malloc(_buffer_format_string_len)
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":302
 *             info.obj = self
 * 
 *             if not PyDataType_HASFIELDS(descr):             # <<<<<<<<<<<<<<
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or
 */
  }

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":329
 *                 return
 *             else:
 *                 info.format = <char*>PyObject_Malloc(_buffer_format_string_len)             # <<<<<<<<<<<<<<
 *                 info.format[0] = c'^' # Native data types, manual alignment
 *                 offset = 0
 */
  /*else*/ {
    __pyx_v_info->format = ((char *)PyObject_Malloc(0xFF));

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":330
 *             else:
 *                 info.format = <char*>PyObject_Malloc(_buffer_format_string_len)
 *                 info.format[0] = c'^' # Native data types, manual alignment             # <<<<<<<<<<<<<<
 *                 offset = 0
 *                 f = _util_dtypestring(descr, info.format + 1,
 */
    (__pyx_v_info->format[0]) = '^';

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":331
 *                 info.format = <char*>PyObject_Malloc(_buffer_format_string_len)
 *                 info.format[0] = c'^' # Native data types, manual alignment
 *                 offset = 0             # <<<<<<<<<<<<<<
 *                 f = _util_dtypestring(descr, info.format + 1,
 *                                       info.format + _buffer_format_string_len,
 */
    __pyx_v_offset = 0;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":332
 *                 info.format[0] = c'^' # Native data types, manual alignment
 *                 offset = 0
 *                 f = _util_dtypestring(descr, info.format + 1,             # <<<<<<<<<<<<<<
 *                                       info.format + _buffer_format_string_len,
 *                                       &offset)
 */
    __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(2, 332, __pyx_L1_error)
    __pyx_v_f = __pyx_t_9;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":335
 *                                       info.format + _buffer_format_string_len,
 *                                       &offset)
 *                 f[0] = c'\0' # Terminate format string             # <<<<<<<<<<<<<<
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 */
    (__pyx_v_f[0]) = '\x00';
  }

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":258
 *         # experimental exception made for __getbuffer__ and __releasebuffer__
 *         # -- the details of this may change.
 *         def __getbuffer__(ndarray self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fulfill the PEP.
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  if (__pyx_v_info->obj != NULL) {
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
  }
  goto __pyx_L2;
  __pyx_L0:;
  if (__pyx_v_info->obj == Py_None) {
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
  }
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_descr);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":337
 *                 f[0] = c'\0' # Terminate format string
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             if PyArray_HASFIELDS(self):
 *                 PyObject_Free(info.format)
 */

/* Python wrapper */
static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0);
  __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info));

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

static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__releasebuffer__", 0);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":338
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):             # <<<<<<<<<<<<<<
 *                 PyObject_Free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0);
  if (__pyx_t_1) {

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":339
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):
 *                 PyObject_Free(info.format)             # <<<<<<<<<<<<<<
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 PyObject_Free(info.strides)
 */
    PyObject_Free(__pyx_v_info->format);

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":338
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):             # <<<<<<<<<<<<<<
 *                 PyObject_Free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  }

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":340
 *             if PyArray_HASFIELDS(self):
 *                 PyObject_Free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 PyObject_Free(info.strides)
 *                 # info.shape was stored after info.strides in the same block
 */
  __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
  if (__pyx_t_1) {

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":341
 *                 PyObject_Free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 PyObject_Free(info.strides)             # <<<<<<<<<<<<<<
 *                 # info.shape was stored after info.strides in the same block
 * 
 */
    PyObject_Free(__pyx_v_info->strides);

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":340
 *             if PyArray_HASFIELDS(self):
 *                 PyObject_Free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 PyObject_Free(info.strides)
 *                 # info.shape was stored after info.strides in the same block
 */
  }

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":337
 *                 f[0] = c'\0' # Terminate format string
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             if PyArray_HASFIELDS(self):
 *                 PyObject_Free(info.format)
 */

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

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":821
 * ctypedef npy_cdouble     complex_t
 * 
 * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":822
 * 
 * cdef inline object PyArray_MultiIterNew1(a):
 *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 822, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":821
 * ctypedef npy_cdouble     complex_t
 * 
 * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":824
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":825
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 825, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":824
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":827
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":828
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":827
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":830
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":831
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 831, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":830
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":833
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":834
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)             # <<<<<<<<<<<<<<
 * 
 * cdef inline tuple PyDataType_SHAPE(dtype d):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 834, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":833
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":836
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
 *     if PyDataType_HASSUBARRAY(d):
 *         return <tuple>d.subarray.shape
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":837
 * 
 * cdef inline tuple PyDataType_SHAPE(dtype d):
 *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
 *         return <tuple>d.subarray.shape
 *     else:
 */
  __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0);
  if (__pyx_t_1) {

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":838
 * cdef inline tuple PyDataType_SHAPE(dtype d):
 *     if PyDataType_HASSUBARRAY(d):
 *         return <tuple>d.subarray.shape             # <<<<<<<<<<<<<<
 *     else:
 *         return ()
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
    __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
    goto __pyx_L0;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":837
 * 
 * cdef inline tuple PyDataType_SHAPE(dtype d):
 *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
 *         return <tuple>d.subarray.shape
 *     else:
 */
  }

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":840
 *         return <tuple>d.subarray.shape
 *     else:
 *         return ()             # <<<<<<<<<<<<<<
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_r = __pyx_empty_tuple;
    goto __pyx_L0;
  }

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":836
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
 *     if PyDataType_HASSUBARRAY(d):
 *         return <tuple>d.subarray.shape
 */

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

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":842
 *         return ()
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:             # <<<<<<<<<<<<<<
 *     # Recursive utility function used in __getbuffer__ to get format
 *     # string. The new location in the format string is returned.
 */

static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) {
  PyArray_Descr *__pyx_v_child = 0;
  int __pyx_v_endian_detector;
  int __pyx_v_little_endian;
  PyObject *__pyx_v_fields = 0;
  PyObject *__pyx_v_childname = NULL;
  PyObject *__pyx_v_new_offset = NULL;
  PyObject *__pyx_v_t = NULL;
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  long __pyx_t_8;
  char *__pyx_t_9;
  __Pyx_RefNannySetupContext("_util_dtypestring", 0);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":847
 * 
 *     cdef dtype child
 *     cdef int endian_detector = 1             # <<<<<<<<<<<<<<
 *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 *     cdef tuple fields
 */
  __pyx_v_endian_detector = 1;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":848
 *     cdef dtype child
 *     cdef int endian_detector = 1
 *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
 *     cdef tuple fields
 * 
 */
  __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":851
 *     cdef tuple fields
 * 
 *     for childname in descr.names:             # <<<<<<<<<<<<<<
 *         fields = descr.fields[childname]
 *         child, new_offset = fields
 */
  if (unlikely(__pyx_v_descr->names == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(2, 851, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(2, 851, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 851, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":852
 * 
 *     for childname in descr.names:
 *         fields = descr.fields[childname]             # <<<<<<<<<<<<<<
 *         child, new_offset = fields
 * 
 */
    if (unlikely(__pyx_v_descr->fields == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 852, __pyx_L1_error)
    }
    __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 852, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(2, 852, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":853
 *     for childname in descr.names:
 *         fields = descr.fields[childname]
 *         child, new_offset = fields             # <<<<<<<<<<<<<<
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:
 */
    if (likely(__pyx_v_fields != Py_None)) {
      PyObject* sequence = __pyx_v_fields;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(2, 853, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 853, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 853, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
    } else {
      __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(2, 853, __pyx_L1_error)
    }
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(2, 853, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3));
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":855
 *         child, new_offset = fields
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 */
    __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 855, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0);
    if (unlikely(__pyx_t_6)) {

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":856
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
 * 
 *         if ((child.byteorder == c'>' and little_endian) or
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 856, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(2, 856, __pyx_L1_error)

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":855
 *         child, new_offset = fields
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 */
    }

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":858
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 *         if ((child.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")
 */
    __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0);
    if (!__pyx_t_7) {
      goto __pyx_L8_next_or;
    } else {
    }
    __pyx_t_7 = (__pyx_v_little_endian != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_L8_next_or:;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":859
 * 
 *         if ((child.byteorder == c'>' and little_endian) or
 *             (child.byteorder == c'<' and not little_endian)):             # <<<<<<<<<<<<<<
 *             raise ValueError(u"Non-native byte order not supported")
 *             # One could encode it in the format string and have Cython
 */
    __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_6 = __pyx_t_7;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0);
    __pyx_t_6 = __pyx_t_7;
    __pyx_L7_bool_binop_done:;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":858
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 *         if ((child.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")
 */
    if (unlikely(__pyx_t_6)) {

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":860
 *         if ((child.byteorder == c'>' and little_endian) or
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *             # One could encode it in the format string and have Cython
 *             # complain instead, BUT: < and > in format strings also imply
 */
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 860, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_ERR(2, 860, __pyx_L1_error)

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":858
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 *         if ((child.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")
 */
    }

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":870
 * 
 *         # Output padding bytes
 *         while offset[0] < new_offset:             # <<<<<<<<<<<<<<
 *             f[0] = 120 # "x"; pad byte
 *             f += 1
 */
    while (1) {
      __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 870, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 870, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 870, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!__pyx_t_6) break;

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":871
 *         # Output padding bytes
 *         while offset[0] < new_offset:
 *             f[0] = 120 # "x"; pad byte             # <<<<<<<<<<<<<<
 *             f += 1
 *             offset[0] += 1
 */
      (__pyx_v_f[0]) = 0x78;

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":872
 *         while offset[0] < new_offset:
 *             f[0] = 120 # "x"; pad byte
 *             f += 1             # <<<<<<<<<<<<<<
 *             offset[0] += 1
 * 
 */
      __pyx_v_f = (__pyx_v_f + 1);

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":873
 *             f[0] = 120 # "x"; pad byte
 *             f += 1
 *             offset[0] += 1             # <<<<<<<<<<<<<<
 * 
 *         offset[0] += child.itemsize
 */
      __pyx_t_8 = 0;
      (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1);
    }

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":875
 *             offset[0] += 1
 * 
 *         offset[0] += child.itemsize             # <<<<<<<<<<<<<<
 * 
 *         if not PyDataType_HASFIELDS(child):
 */
    __pyx_t_8 = 0;
    (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize);

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":877
 *         offset[0] += child.itemsize
 * 
 *         if not PyDataType_HASFIELDS(child):             # <<<<<<<<<<<<<<
 *             t = child.type_num
 *             if end - f < 5:
 */
    __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0);
    if (__pyx_t_6) {

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":878
 * 
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num             # <<<<<<<<<<<<<<
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")
 */
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 878, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":879
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num
 *             if end - f < 5:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(u"Format string allocated too short.")
 * 
 */
      __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0);
      if (unlikely(__pyx_t_6)) {

        /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":880
 *             t = child.type_num
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 */
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 880, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __PYX_ERR(2, 880, __pyx_L1_error)

        /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":879
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num
 *             if end - f < 5:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(u"Format string allocated too short.")
 * 
 */
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":883
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"             # <<<<<<<<<<<<<<
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 883, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 883, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 883, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 98;
        goto __pyx_L15;
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":884
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"             # <<<<<<<<<<<<<<
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 884, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 884, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 884, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 66;
        goto __pyx_L15;
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":885
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"             # <<<<<<<<<<<<<<
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 885, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 885, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 885, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x68;
        goto __pyx_L15;
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":886
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"             # <<<<<<<<<<<<<<
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 886, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 886, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 886, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 72;
        goto __pyx_L15;
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":887
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"             # <<<<<<<<<<<<<<
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 887, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 887, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 887, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x69;
        goto __pyx_L15;
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":888
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 888, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 888, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 888, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 73;
        goto __pyx_L15;
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":889
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"             # <<<<<<<<<<<<<<
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 889, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 889, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 889, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x6C;
        goto __pyx_L15;
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":890
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 890, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 890, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 890, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 76;
        goto __pyx_L15;
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":891
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"             # <<<<<<<<<<<<<<
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 891, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 891, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 891, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x71;
        goto __pyx_L15;
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":892
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"             # <<<<<<<<<<<<<<
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 892, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 892, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 892, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 81;
        goto __pyx_L15;
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":893
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"             # <<<<<<<<<<<<<<
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 893, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 893, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 893, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x66;
        goto __pyx_L15;
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":894
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 894, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 894, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 894, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x64;
        goto __pyx_L15;
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":895
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"             # <<<<<<<<<<<<<<
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 895, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 895, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 895, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 0x67;
        goto __pyx_L15;
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":896
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf             # <<<<<<<<<<<<<<
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 896, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 896, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 896, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 0x66;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L15;
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":897
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd             # <<<<<<<<<<<<<<
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 897, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 897, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 897, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 0x64;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L15;
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":898
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg             # <<<<<<<<<<<<<<
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 *             else:
 */
      __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 898, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 898, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 898, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 0x67;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L15;
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":899
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 */
      __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 899, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 899, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 899, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (likely(__pyx_t_6)) {
        (__pyx_v_f[0]) = 79;
        goto __pyx_L15;
      }

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":901
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 *             f += 1
 *         else:
 */
      /*else*/ {
        __pyx_t_3 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 901, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 901, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __PYX_ERR(2, 901, __pyx_L1_error)
      }
      __pyx_L15:;

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":902
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *             f += 1             # <<<<<<<<<<<<<<
 *         else:
 *             # Cython ignores struct boundary information ("T{...}"),
 */
      __pyx_v_f = (__pyx_v_f + 1);

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":877
 *         offset[0] += child.itemsize
 * 
 *         if not PyDataType_HASFIELDS(child):             # <<<<<<<<<<<<<<
 *             t = child.type_num
 *             if end - f < 5:
 */
      goto __pyx_L13;
    }

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":906
 *             # Cython ignores struct boundary information ("T{...}"),
 *             # so don't output it
 *             f = _util_dtypestring(child, f, end, offset)             # <<<<<<<<<<<<<<
 *     return f
 * 
 */
    /*else*/ {
      __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(2, 906, __pyx_L1_error)
      __pyx_v_f = __pyx_t_9;
    }
    __pyx_L13:;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":851
 *     cdef tuple fields
 * 
 *     for childname in descr.names:             # <<<<<<<<<<<<<<
 *         fields = descr.fields[childname]
 *         child, new_offset = fields
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":907
 *             # so don't output it
 *             f = _util_dtypestring(child, f, end, offset)
 *     return f             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_f;
  goto __pyx_L0;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":842
 *         return ()
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:             # <<<<<<<<<<<<<<
 *     # Recursive utility function used in __getbuffer__ to get format
 *     # string. The new location in the format string is returned.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_child);
  __Pyx_XDECREF(__pyx_v_fields);
  __Pyx_XDECREF(__pyx_v_childname);
  __Pyx_XDECREF(__pyx_v_new_offset);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1022
 *     int _import_umath() except -1
 * 
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 *     Py_INCREF(base) # important to do this before stealing the reference below!
 *     PyArray_SetBaseObject(arr, base)
 */

static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_array_base", 0);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1023
 * 
 * cdef inline void set_array_base(ndarray arr, object base):
 *     Py_INCREF(base) # important to do this before stealing the reference below!             # <<<<<<<<<<<<<<
 *     PyArray_SetBaseObject(arr, base)
 * 
 */
  Py_INCREF(__pyx_v_base);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1024
 * cdef inline void set_array_base(ndarray arr, object base):
 *     Py_INCREF(base) # important to do this before stealing the reference below!
 *     PyArray_SetBaseObject(arr, base)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object get_array_base(ndarray arr):
 */
  (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base));

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1022
 *     int _import_umath() except -1
 * 
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 *     Py_INCREF(base) # important to do this before stealing the reference below!
 *     PyArray_SetBaseObject(arr, base)
 */

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

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1026
 *     PyArray_SetBaseObject(arr, base)
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     base = PyArray_BASE(arr)
 *     if base is NULL:
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
  PyObject *__pyx_v_base;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("get_array_base", 0);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1027
 * 
 * cdef inline object get_array_base(ndarray arr):
 *     base = PyArray_BASE(arr)             # <<<<<<<<<<<<<<
 *     if base is NULL:
 *         return None
 */
  __pyx_v_base = PyArray_BASE(__pyx_v_arr);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1028
 * cdef inline object get_array_base(ndarray arr):
 *     base = PyArray_BASE(arr)
 *     if base is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     return <object>base
 */
  __pyx_t_1 = ((__pyx_v_base == NULL) != 0);
  if (__pyx_t_1) {

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1029
 *     base = PyArray_BASE(arr)
 *     if base is NULL:
 *         return None             # <<<<<<<<<<<<<<
 *     return <object>base
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1028
 * cdef inline object get_array_base(ndarray arr):
 *     base = PyArray_BASE(arr)
 *     if base is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     return <object>base
 */
  }

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1030
 *     if base is NULL:
 *         return None
 *     return <object>base             # <<<<<<<<<<<<<<
 * 
 * # Versions of the import_* functions which are more suitable for
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_base));
  __pyx_r = ((PyObject *)__pyx_v_base);
  goto __pyx_L0;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1026
 *     PyArray_SetBaseObject(arr, base)
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     base = PyArray_BASE(arr)
 *     if base is NULL:
 */

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

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1034
 * # Versions of the import_* functions which are more suitable for
 * # Cython code.
 * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         _import_array()
 */

static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) {
  int __pyx_r;
  __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;
  __Pyx_RefNannySetupContext("import_array", 0);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1035
 * # Cython code.
 * cdef inline int import_array() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_array()
 *     except Exception:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __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:*/ {

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1036
 * cdef inline int import_array() except -1:
 *     try:
 *         _import_array()             # <<<<<<<<<<<<<<
 *     except Exception:
 *         raise ImportError("numpy.core.multiarray failed to import")
 */
      __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 1036, __pyx_L3_error)

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1035
 * # Cython code.
 * cdef inline int import_array() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_array()
 *     except Exception:
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1037
 *     try:
 *         _import_array()
 *     except Exception:             # <<<<<<<<<<<<<<
 *         raise ImportError("numpy.core.multiarray failed to import")
 * 
 */
    __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
    if (__pyx_t_4) {
      __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 1037, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1038
 *         _import_array()
 *     except Exception:
 *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
 * 
 * cdef inline int import_umath() except -1:
 */
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 1038, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(2, 1038, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1035
 * # Cython code.
 * cdef inline int import_array() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_array()
 *     except Exception:
 */
    __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_L8_try_end:;
  }

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1034
 * # Versions of the import_* functions which are more suitable for
 * # Cython code.
 * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         _import_array()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1040
 *         raise ImportError("numpy.core.multiarray failed to import")
 * 
 * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         _import_umath()
 */

static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) {
  int __pyx_r;
  __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;
  __Pyx_RefNannySetupContext("import_umath", 0);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1041
 * 
 * cdef inline int import_umath() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __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:*/ {

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1042
 * cdef inline int import_umath() except -1:
 *     try:
 *         _import_umath()             # <<<<<<<<<<<<<<
 *     except Exception:
 *         raise ImportError("numpy.core.umath failed to import")
 */
      __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 1042, __pyx_L3_error)

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1041
 * 
 * cdef inline int import_umath() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1043
 *     try:
 *         _import_umath()
 *     except Exception:             # <<<<<<<<<<<<<<
 *         raise ImportError("numpy.core.umath failed to import")
 * 
 */
    __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
    if (__pyx_t_4) {
      __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 1043, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1044
 *         _import_umath()
 *     except Exception:
 *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
 * 
 * cdef inline int import_ufunc() except -1:
 */
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 1044, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(2, 1044, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1041
 * 
 * cdef inline int import_umath() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
    __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_L8_try_end:;
  }

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1040
 *         raise ImportError("numpy.core.multiarray failed to import")
 * 
 * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         _import_umath()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1046
 *         raise ImportError("numpy.core.umath failed to import")
 * 
 * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         _import_umath()
 */

static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) {
  int __pyx_r;
  __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;
  __Pyx_RefNannySetupContext("import_ufunc", 0);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1047
 * 
 * cdef inline int import_ufunc() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __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:*/ {

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1048
 * cdef inline int import_ufunc() except -1:
 *     try:
 *         _import_umath()             # <<<<<<<<<<<<<<
 *     except Exception:
 *         raise ImportError("numpy.core.umath failed to import")
 */
      __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 1048, __pyx_L3_error)

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1047
 * 
 * cdef inline int import_ufunc() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1049
 *     try:
 *         _import_umath()
 *     except Exception:             # <<<<<<<<<<<<<<
 *         raise ImportError("numpy.core.umath failed to import")
 */
    __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
    if (__pyx_t_4) {
      __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 1049, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1050
 *         _import_umath()
 *     except Exception:
 *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
 */
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 1050, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(2, 1050, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1047
 * 
 * cdef inline int import_ufunc() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
    __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_L8_try_end:;
  }

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1046
 *         raise ImportError("numpy.core.umath failed to import")
 * 
 * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         _import_umath()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_MessageContext __pyx_vtable_4mars_6actors_4pool_11gevent_pool_MessageContext;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_MessageContext(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)o);
  p->__pyx_vtab = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_MessageContext;
  p->message = Py_None; Py_INCREF(Py_None);
  p->async_result = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_MessageContext(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->message);
  Py_CLEAR(p->async_result);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_MessageContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)o;
  if (p->message) {
    e = (*v)(p->message, a); if (e) return e;
  }
  if (p->async_result) {
    e = (*v)(p->async_result, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_MessageContext(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *)o;
  tmp = ((PyObject*)p->message);
  p->message = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->async_result);
  p->async_result = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_14MessageContext_message(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_14MessageContext_message(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message_3__set__(o, v);
  }
  else {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_7message_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_14MessageContext_async_result(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_14MessageContext_async_result(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result_3__set__(o, v);
  }
  else {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_12async_result_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_4mars_6actors_4pool_11gevent_pool_MessageContext[] = {
  {"result", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_3result, METH_NOARGS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_5__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_7__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4mars_6actors_4pool_11gevent_pool_MessageContext[] = {
  {(char *)"message", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_14MessageContext_message, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_14MessageContext_message, (char *)0, 0},
  {(char *)"async_result", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_14MessageContext_async_result, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_14MessageContext_async_result, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool_MessageContext = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.MessageContext", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_MessageContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_MessageContext, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_MessageContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4mars_6actors_4pool_11gevent_pool_MessageContext, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4mars_6actors_4pool_11gevent_pool_MessageContext, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4mars_6actors_4pool_11gevent_pool_14MessageContext_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4mars_6actors_4pool_11gevent_pool_MessageContext, /*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_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)o);
  p->__pyx_vtab = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext;
  p->actor = Py_None; Py_INCREF(Py_None);
  p->lock = Py_None; Py_INCREF(Py_None);
  p->inbox = Py_None; Py_INCREF(Py_None);
  p->comm = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->actor);
  Py_CLEAR(p->lock);
  Py_CLEAR(p->inbox);
  Py_CLEAR(p->comm);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)o;
  if (p->actor) {
    e = (*v)(p->actor, a); if (e) return e;
  }
  if (p->lock) {
    e = (*v)(p->lock, a); if (e) return e;
  }
  if (p->inbox) {
    e = (*v)(p->inbox, a); if (e) return e;
  }
  if (p->comm) {
    e = (*v)(p->comm, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *)o;
  tmp = ((PyObject*)p->actor);
  p->actor = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->lock);
  p->lock = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->inbox);
  p->inbox = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->comm);
  p->comm = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_actor(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_actor(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor_3__set__(o, v);
  }
  else {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5actor_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_lock(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_lock(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock_3__set__(o, v);
  }
  else {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4lock_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_inbox(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_inbox(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox_3__set__(o, v);
  }
  else {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5inbox_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_comm(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_comm(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm_3__set__(o, v);
  }
  else {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_4comm_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext[] = {
  {"fire_run", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_3fire_run, METH_NOARGS, 0},
  {"receive", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_5receive, METH_O, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_7__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_9__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext[] = {
  {(char *)"actor", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_actor, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_actor, (char *)0, 0},
  {(char *)"lock", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_lock, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_lock, (char *)0, 0},
  {(char *)"inbox", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_inbox, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_inbox, (char *)0, 0},
  {(char *)"comm", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_comm, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_comm, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.ActorExecutionContext", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext, /*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 PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ThreadPool(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *)o);
  p->_pool = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_ThreadPool(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->_pool);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_ThreadPool(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *)o;
  if (p->_pool) {
    e = (*v)(p->_pool, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_ThreadPool(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool *)o;
  tmp = ((PyObject*)p->_pool);
  p->_pool = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_4mars_6actors_4pool_11gevent_pool_ThreadPool[] = {
  {"submit", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10ThreadPool_3submit, METH_VARARGS|METH_KEYWORDS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10ThreadPool_5__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10ThreadPool_7__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool_ThreadPool = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.ThreadPool", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ThreadPool), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_ThreadPool, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_ThreadPool, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_ThreadPool, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4mars_6actors_4pool_11gevent_pool_ThreadPool, /*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*/
  __pyx_pw_4mars_6actors_4pool_11gevent_pool_10ThreadPool_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ThreadPool, /*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 PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorContext(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *)o);
  p->_comm = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_ActorContext(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->_comm);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_ActorContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *)o;
  if (p->_comm) {
    e = (*v)(p->_comm, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_ActorContext(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *)o;
  tmp = ((PyObject*)p->_comm);
  p->_comm = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_12ActorContext_index(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_5index_1__get__(o);
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_12ActorContext_distributor(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_11distributor_1__get__(o);
}

static PyMethodDef __pyx_methods_4mars_6actors_4pool_11gevent_pool_ActorContext[] = {
  {"create_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_3create_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"destroy_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_5destroy_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"has_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_7has_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"actor_ref", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_9actor_ref, METH_VARARGS|METH_KEYWORDS, 0},
  {"send", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_11send, METH_VARARGS|METH_KEYWORDS, 0},
  {"tell", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_13tell, METH_VARARGS|METH_KEYWORDS, 0},
  {"sleep", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_15sleep, METH_VARARGS|METH_KEYWORDS, 0},
  {"fileobject", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_17fileobject, METH_VARARGS|METH_KEYWORDS, 0},
  {"popen", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_19popen, METH_VARARGS|METH_KEYWORDS, 0},
  {"threadpool", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_21threadpool, METH_VARARGS|METH_KEYWORDS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_23__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_25__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4mars_6actors_4pool_11gevent_pool_ActorContext[] = {
  {(char *)"index", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_12ActorContext_index, 0, (char *)0, 0},
  {(char *)"distributor", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_12ActorContext_distributor, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorContext = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.ActorContext", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_ActorContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n    Hold by an actor.\n\n    actor = Actor()\n    actor.ctx = ActorContext(comm)\n\n    provide methods:\n\n    create_actor\n    actor_ref\n    ", /*tp_doc*/
  __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_ActorContext, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_ActorContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4mars_6actors_4pool_11gevent_pool_ActorContext, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4mars_6actors_4pool_11gevent_pool_ActorContext, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4mars_6actors_4pool_11gevent_pool_12ActorContext_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorContext, /*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_vtabstruct_4mars_6actors_4pool_11gevent_pool_LocalActorPool __pyx_vtable_4mars_6actors_4pool_11gevent_pool_LocalActorPool;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_LocalActorPool(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)o);
  p->__pyx_vtab = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_LocalActorPool;
  p->actors = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->comm_proxy = Py_None; Py_INCREF(Py_None);
  p->address = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_LocalActorPool(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->actors);
  Py_CLEAR(p->comm_proxy);
  Py_CLEAR(p->address);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_LocalActorPool(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)o;
  if (p->actors) {
    e = (*v)(p->actors, a); if (e) return e;
  }
  if (p->comm_proxy) {
    e = (*v)(p->comm_proxy, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_LocalActorPool(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *)o;
  tmp = ((PyObject*)p->actors);
  p->actors = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->comm_proxy);
  p->comm_proxy = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_comm(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_4comm_1__get__(o);
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_actors(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_actors(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors_3__set__(o, v);
  }
  else {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_6actors_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_comm_proxy(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_comm_proxy(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy_3__set__(o, v);
  }
  else {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_10comm_proxy_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_address(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_address(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address_3__set__(o, v);
  }
  else {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7address_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_index(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_5index_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_index(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_5index_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_4mars_6actors_4pool_11gevent_pool_LocalActorPool[] = {
  {"set_comm", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_3set_comm, METH_O, 0},
  {"get_actor_execution_ctx", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_5get_actor_execution_ctx, METH_O, 0},
  {"create_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_7create_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"has_actor", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_9has_actor, METH_O, 0},
  {"destroy_actor", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_11destroy_actor, METH_O, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_13__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_15__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4mars_6actors_4pool_11gevent_pool_LocalActorPool[] = {
  {(char *)"comm", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_comm, 0, (char *)0, 0},
  {(char *)"actors", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_actors, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_actors, (char *)0, 0},
  {(char *)"comm_proxy", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_comm_proxy, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_comm_proxy, (char *)0, 0},
  {(char *)"address", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_address, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_address, (char *)0, 0},
  {(char *)"index", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_index, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_index, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool_LocalActorPool = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.LocalActorPool", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_LocalActorPool, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n    manage local actors, this pool is not aware of the multi-processes or cluster\n    ", /*tp_doc*/
  __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_LocalActorPool, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_LocalActorPool, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4mars_6actors_4pool_11gevent_pool_LocalActorPool, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4mars_6actors_4pool_11gevent_pool_LocalActorPool, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4mars_6actors_4pool_11gevent_pool_LocalActorPool, /*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_vtabstruct_4mars_6actors_4pool_11gevent_pool_AsyncHandler __pyx_vtable_4mars_6actors_4pool_11gevent_pool_AsyncHandler;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_AsyncHandler(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)o);
  p->__pyx_vtab = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_AsyncHandler;
  p->async_results = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_AsyncHandler(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->async_results);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_AsyncHandler(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)o;
  if (p->async_results) {
    e = (*v)(p->async_results, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_AsyncHandler(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *)o;
  tmp = ((PyObject*)p->async_results);
  p->async_results = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_4mars_6actors_4pool_11gevent_pool_AsyncHandler[] = {
  {"submit", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_3submit, METH_O, 0},
  {"future", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_5future, METH_VARARGS|METH_KEYWORDS, 0},
  {"wait", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_7wait, METH_O, 0},
  {"got", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_9got, METH_VARARGS|METH_KEYWORDS, 0},
  {"err", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_11err, METH_VARARGS|METH_KEYWORDS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_13__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_15__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool_AsyncHandler = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.AsyncHandler", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_AsyncHandler, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_AsyncHandler, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_AsyncHandler, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4mars_6actors_4pool_11gevent_pool_AsyncHandler, /*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*/
  __pyx_pw_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4mars_6actors_4pool_11gevent_pool_AsyncHandler, /*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_vtabstruct_4mars_6actors_4pool_11gevent_pool_Connection __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Connection;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_Connection(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *)o);
  p->__pyx_vtab = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Connection;
  p->conn = Py_None; Py_INCREF(Py_None);
  p->lock = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_Connection(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->conn);
  Py_CLEAR(p->lock);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_Connection(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *)o;
  if (p->conn) {
    e = (*v)(p->conn, a); if (e) return e;
  }
  if (p->lock) {
    e = (*v)(p->lock, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_Connection(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *)o;
  tmp = ((PyObject*)p->conn);
  p->conn = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->lock);
  p->lock = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_10Connection_conn(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4conn_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_10Connection_conn(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4conn_3__set__(o, v);
  }
  else {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4conn_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_10Connection_lock(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4lock_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_10Connection_lock(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4lock_3__set__(o, v);
  }
  else {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_4lock_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_4mars_6actors_4pool_11gevent_pool_Connection[] = {
  {"__enter__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_3__enter__, METH_NOARGS, 0},
  {"__exit__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_5__exit__, METH_VARARGS|METH_KEYWORDS, 0},
  {"release", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_7release, METH_NOARGS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_9__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_11__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4mars_6actors_4pool_11gevent_pool_Connection[] = {
  {(char *)"conn", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_10Connection_conn, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_10Connection_conn, (char *)0, 0},
  {(char *)"lock", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_10Connection_lock, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_10Connection_lock, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool_Connection = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.Connection", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_Connection, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_Connection, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_Connection, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4mars_6actors_4pool_11gevent_pool_Connection, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4mars_6actors_4pool_11gevent_pool_Connection, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Connection_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4mars_6actors_4pool_11gevent_pool_Connection, /*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_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)o);
  p->__pyx_vtab = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper;
  p->_parallel = Py_None; Py_INCREF(Py_None);
  p->_pool = Py_None; Py_INCREF(Py_None);
  p->_connections = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_lock = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->_parallel);
  Py_CLEAR(p->_pool);
  Py_CLEAR(p->_connections);
  Py_CLEAR(p->_lock);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)o;
  if (p->_parallel) {
    e = (*v)(p->_parallel, a); if (e) return e;
  }
  if (p->_pool) {
    e = (*v)(p->_pool, a); if (e) return e;
  }
  if (p->_connections) {
    e = (*v)(p->_connections, a); if (e) return e;
  }
  if (p->_lock) {
    e = (*v)(p->_lock, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)o;
  tmp = ((PyObject*)p->_parallel);
  p->_parallel = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_pool);
  p->_pool = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_connections);
  p->_connections = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_lock);
  p->_lock = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper[] = {
  {"_send_remote", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_3_send_remote, METH_VARARGS|METH_KEYWORDS, 0},
  {"create_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_5create_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"_async_run", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_7_async_run, METH_VARARGS|METH_KEYWORDS, 0},
  {"destroy_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_9destroy_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"has_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_11has_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"actor_ref", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_13actor_ref, METH_VARARGS|METH_KEYWORDS, 0},
  {"_send", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_15_send, METH_VARARGS|METH_KEYWORDS, 0},
  {"send", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_17send, METH_VARARGS|METH_KEYWORDS, 0},
  {"tell", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_19tell, METH_VARARGS|METH_KEYWORDS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_21__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_23__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.ActorRemoteHelper", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n    Used to handle remote operations, like deliver create_actor, destroy_actor, send etc to remote,\n    and handle the response.\n\n    An ActorRemoteHelper instance can be hold by Communicator and ActorClient.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper, /*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*/
  __pyx_pw_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper, /*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_vtabstruct_4mars_6actors_4pool_11gevent_pool_Communicator __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_Communicator(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *p;
  PyObject *o = __pyx_tp_new_4mars_6actors_4pool_11gevent_pool_AsyncHandler(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_AsyncHandler*)__pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Communicator;
  p->distributor = ((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)Py_None); Py_INCREF(Py_None);
  p->pool = Py_None; Py_INCREF(Py_None);
  p->cluster_info = ((struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *)Py_None); Py_INCREF(Py_None);
  p->pipe = Py_None; Py_INCREF(Py_None);
  p->remote_handler = Py_None; Py_INCREF(Py_None);
  p->running = Py_None; Py_INCREF(Py_None);
  p->_handlers = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_Communicator(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  if (p->__weakref__) PyObject_ClearWeakRefs(o);
  Py_CLEAR(p->distributor);
  Py_CLEAR(p->pool);
  Py_CLEAR(p->cluster_info);
  Py_CLEAR(p->pipe);
  Py_CLEAR(p->remote_handler);
  Py_CLEAR(p->running);
  Py_CLEAR(p->_handlers);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_AsyncHandler(o);
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_Communicator(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)o;
  e = __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_AsyncHandler(o, v, a); if (e) return e;
  if (p->distributor) {
    e = (*v)(((PyObject *)p->distributor), a); if (e) return e;
  }
  if (p->pool) {
    e = (*v)(p->pool, a); if (e) return e;
  }
  if (p->cluster_info) {
    e = (*v)(((PyObject *)p->cluster_info), a); if (e) return e;
  }
  if (p->pipe) {
    e = (*v)(p->pipe, a); if (e) return e;
  }
  if (p->remote_handler) {
    e = (*v)(p->remote_handler, a); if (e) return e;
  }
  if (p->running) {
    e = (*v)(p->running, a); if (e) return e;
  }
  if (p->_handlers) {
    e = (*v)(p->_handlers, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_Communicator(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)o;
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_AsyncHandler(o);
  tmp = ((PyObject*)p->distributor);
  p->distributor = ((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pool);
  p->pool = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->cluster_info);
  p->cluster_info = ((struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pipe);
  p->pipe = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->remote_handler);
  p->remote_handler = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->running);
  p->running = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_handlers);
  p->_handlers = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_12Communicator_index(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_5index_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_12Communicator_index(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_5index_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_12Communicator_distributor(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_12Communicator_distributor(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor_3__set__(o, v);
  }
  else {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11distributor_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_4mars_6actors_4pool_11gevent_pool_Communicator[] = {
  {"_dispatch", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_3_dispatch, METH_VARARGS|METH_KEYWORDS, 0},
  {"_send_local", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_5_send_local, METH_VARARGS|METH_KEYWORDS, 0},
  {"_send_process", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_7_send_process, METH_VARARGS|METH_KEYWORDS, 0},
  {"_send_remote", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_9_send_remote, METH_VARARGS|METH_KEYWORDS, 0},
  {"_send", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_11_send, METH_VARARGS|METH_KEYWORDS, 0},
  {"send", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_13send, METH_VARARGS|METH_KEYWORDS, 0},
  {"tell", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_15tell, METH_VARARGS|METH_KEYWORDS, 0},
  {"_create_local_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_17_create_local_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"_create_process_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_19_create_process_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"_create_remote_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_21_create_remote_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"create_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_23create_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"_destroy_local_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_25_destroy_local_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"_destroy_process_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_27_destroy_process_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"destroy_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_29destroy_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"_has_local_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_31_has_local_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"_has_process_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_33_has_process_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"has_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_35has_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"_on_receive_send", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_37_on_receive_send, METH_VARARGS|METH_KEYWORDS, 0},
  {"_on_receive_tell", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_39_on_receive_tell, METH_VARARGS|METH_KEYWORDS, 0},
  {"_on_receive_create_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_41_on_receive_create_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"_on_receive_destroy_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_43_on_receive_destroy_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"_on_receive_has_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_45_on_receive_has_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"_on_receive_result", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_47_on_receive_result, METH_VARARGS|METH_KEYWORDS, 0},
  {"_on_receive_error", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_49_on_receive_error, METH_VARARGS|METH_KEYWORDS, 0},
  {"on_receive", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_51on_receive, METH_VARARGS|METH_KEYWORDS, 0},
  {"run", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_53run, METH_NOARGS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_55__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_57__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4mars_6actors_4pool_11gevent_pool_Communicator[] = {
  {(char *)"index", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_12Communicator_index, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_12Communicator_index, (char *)0, 0},
  {(char *)"distributor", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_12Communicator_distributor, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_12Communicator_distributor, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool_Communicator = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.Communicator", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_Communicator, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n    Communicator, decide to send message to\n    1) local actor pool, just spawn a greenlet to call the ActorExecutionContext.fire_run\n    2) local dispatcher, mainly send message to another process, no pipe means no local dispatcher\n    3) remote dispatcher which serves a stream handler\n\n    Also, communicator receives message from dispatcher which received from different process or remote.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_Communicator, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_Communicator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4mars_6actors_4pool_11gevent_pool_Communicator, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4mars_6actors_4pool_11gevent_pool_Communicator, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4mars_6actors_4pool_11gevent_pool_12Communicator_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4mars_6actors_4pool_11gevent_pool_Communicator, /*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_vtabstruct_4mars_6actors_4pool_11gevent_pool_Dispatcher __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Dispatcher;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_Dispatcher(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *p;
  PyObject *o = __pyx_tp_new_4mars_6actors_4pool_11gevent_pool_AsyncHandler(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4mars_6actors_4pool_11gevent_pool_AsyncHandler*)__pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Dispatcher;
  p->cluster_info = ((struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *)Py_None); Py_INCREF(Py_None);
  p->pipes = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->pipe_checkers = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->distributor = Py_None; Py_INCREF(Py_None);
  p->remote_handler = Py_None; Py_INCREF(Py_None);
  p->checker_group = Py_None; Py_INCREF(Py_None);
  p->handlers = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_Dispatcher(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->cluster_info);
  Py_CLEAR(p->pipes);
  Py_CLEAR(p->pipe_checkers);
  Py_CLEAR(p->distributor);
  Py_CLEAR(p->remote_handler);
  Py_CLEAR(p->checker_group);
  Py_CLEAR(p->handlers);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_AsyncHandler(o);
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_Dispatcher(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)o;
  e = __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_AsyncHandler(o, v, a); if (e) return e;
  if (p->cluster_info) {
    e = (*v)(((PyObject *)p->cluster_info), a); if (e) return e;
  }
  if (p->pipes) {
    e = (*v)(p->pipes, a); if (e) return e;
  }
  if (p->pipe_checkers) {
    e = (*v)(p->pipe_checkers, a); if (e) return e;
  }
  if (p->distributor) {
    e = (*v)(p->distributor, a); if (e) return e;
  }
  if (p->remote_handler) {
    e = (*v)(p->remote_handler, a); if (e) return e;
  }
  if (p->checker_group) {
    e = (*v)(p->checker_group, a); if (e) return e;
  }
  if (p->handlers) {
    e = (*v)(p->handlers, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_Dispatcher(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)o;
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_AsyncHandler(o);
  tmp = ((PyObject*)p->cluster_info);
  p->cluster_info = ((struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pipes);
  p->pipes = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pipe_checkers);
  p->pipe_checkers = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->distributor);
  p->distributor = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->remote_handler);
  p->remote_handler = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->checker_group);
  p->checker_group = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->handlers);
  p->handlers = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_4mars_6actors_4pool_11gevent_pool_Dispatcher[] = {
  {"_send", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_3_send, METH_VARARGS|METH_KEYWORDS, 0},
  {"send", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_5send, METH_VARARGS|METH_KEYWORDS, 0},
  {"tell", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_7tell, METH_VARARGS|METH_KEYWORDS, 0},
  {"create_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_9create_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"destroy_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_11destroy_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"has_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_13has_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"_on_receive_action", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_15_on_receive_action, METH_O, 0},
  {"_on_receive_result", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_17_on_receive_result, METH_O, 0},
  {"_on_receive_error", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_19_on_receive_error, METH_O, 0},
  {"on_receive", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_21on_receive, METH_O, 0},
  {"replace_pipe", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_23replace_pipe, METH_O, 0},
  {"_check_pipe", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_25_check_pipe, METH_O, 0},
  {"run", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_27run, METH_NOARGS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_29__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_31__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool_Dispatcher = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.Dispatcher", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_Dispatcher, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n    Only created when more than 1 process.\n\n    What dispatcher do is redirect the message to the destination process\n    according to the distributor, and then return back the result to the original process.\n    ", /*tp_doc*/
  __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_Dispatcher, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_Dispatcher, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4mars_6actors_4pool_11gevent_pool_Dispatcher, /*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*/
  __pyx_pw_4mars_6actors_4pool_11gevent_pool_10Dispatcher_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4mars_6actors_4pool_11gevent_pool_Dispatcher, /*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 PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorServerHandler(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *)o);
  p->sender = Py_None; Py_INCREF(Py_None);
  p->server = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_ActorServerHandler(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->sender);
  Py_CLEAR(p->server);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_ActorServerHandler(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *)o;
  if (p->sender) {
    e = (*v)(p->sender, a); if (e) return e;
  }
  if (p->server) {
    e = (*v)(p->server, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_ActorServerHandler(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler *)o;
  tmp = ((PyObject*)p->sender);
  p->sender = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->server);
  p->server = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_4mars_6actors_4pool_11gevent_pool_ActorServerHandler[] = {
  {"set_server", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_3set_server, METH_O, 0},
  {"on_receive", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_5on_receive, METH_O, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_9__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_11__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorServerHandler = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.ActorServerHandler", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorServerHandler), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_ActorServerHandler, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  __pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_7__call__, /*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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_ActorServerHandler, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_ActorServerHandler, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4mars_6actors_4pool_11gevent_pool_ActorServerHandler, /*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*/
  __pyx_pw_4mars_6actors_4pool_11gevent_pool_18ActorServerHandler_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorServerHandler, /*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_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorPool __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorPool;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorPool(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)o);
  p->__pyx_vtab = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorPool;
  p->cluster_info = ((struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *)Py_None); Py_INCREF(Py_None);
  p->_dispatcher = Py_None; Py_INCREF(Py_None);
  p->distributor = ((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)Py_None); Py_INCREF(Py_None);
  p->_stopped = Py_None; Py_INCREF(Py_None);
  p->_server = Py_None; Py_INCREF(Py_None);
  p->_parallel = Py_None; Py_INCREF(Py_None);
  p->_stop_funcs = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_processes = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_comm_pipes = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_pool_pipes = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_ActorPool(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->cluster_info);
  Py_CLEAR(p->_dispatcher);
  Py_CLEAR(p->distributor);
  Py_CLEAR(p->_stopped);
  Py_CLEAR(p->_server);
  Py_CLEAR(p->_parallel);
  Py_CLEAR(p->_stop_funcs);
  Py_CLEAR(p->_processes);
  Py_CLEAR(p->_comm_pipes);
  Py_CLEAR(p->_pool_pipes);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_ActorPool(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)o;
  if (p->cluster_info) {
    e = (*v)(((PyObject *)p->cluster_info), a); if (e) return e;
  }
  if (p->_dispatcher) {
    e = (*v)(p->_dispatcher, a); if (e) return e;
  }
  if (p->distributor) {
    e = (*v)(((PyObject *)p->distributor), a); if (e) return e;
  }
  if (p->_stopped) {
    e = (*v)(p->_stopped, a); if (e) return e;
  }
  if (p->_server) {
    e = (*v)(p->_server, a); if (e) return e;
  }
  if (p->_parallel) {
    e = (*v)(p->_parallel, a); if (e) return e;
  }
  if (p->_stop_funcs) {
    e = (*v)(p->_stop_funcs, a); if (e) return e;
  }
  if (p->_processes) {
    e = (*v)(p->_processes, a); if (e) return e;
  }
  if (p->_comm_pipes) {
    e = (*v)(p->_comm_pipes, a); if (e) return e;
  }
  if (p->_pool_pipes) {
    e = (*v)(p->_pool_pipes, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_ActorPool(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)o;
  tmp = ((PyObject*)p->cluster_info);
  p->cluster_info = ((struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_dispatcher);
  p->_dispatcher = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->distributor);
  p->distributor = ((struct __pyx_obj_4mars_6actors_11distributor_Distributor *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_stopped);
  p->_stopped = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_server);
  p->_server = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_parallel);
  p->_parallel = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_stop_funcs);
  p->_stop_funcs = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_processes);
  p->_processes = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_comm_pipes);
  p->_comm_pipes = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_pool_pipes);
  p->_pool_pipes = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_9ActorPool_processes(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_9processes_1__get__(o);
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_9ActorPool_cluster_info(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_9ActorPool_cluster_info(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info_3__set__(o, v);
  }
  else {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_12cluster_info_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_9ActorPool__dispatcher(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_9ActorPool__dispatcher(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher_3__set__(o, v);
  }
  else {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_dispatcher_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_9ActorPool_distributor(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_9ActorPool_distributor(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor_3__set__(o, v);
  }
  else {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11distributor_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4mars_6actors_4pool_11gevent_pool_9ActorPool__server(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server_1__get__(o);
}

static int __pyx_setprop_4mars_6actors_4pool_11gevent_pool_9ActorPool__server(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server_3__set__(o, v);
  }
  else {
    return __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_7_server_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_4mars_6actors_4pool_11gevent_pool_ActorPool[] = {
  {"create_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_3create_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"destroy_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_5destroy_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"has_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_7has_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"actor_ref", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_9actor_ref, METH_VARARGS|METH_KEYWORDS, 0},
  {"_start_process", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_11_start_process, METH_O, 0},
  {"restart_process", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_13restart_process, METH_O, 0},
  {"run", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_15run, METH_NOARGS, 0},
  {"sleep", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_17sleep, METH_VARARGS|METH_KEYWORDS, 0},
  {"join", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_19join, METH_VARARGS|METH_KEYWORDS, 0},
  {"stop", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_21stop, METH_NOARGS, 0},
  {"__enter__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_23__enter__, METH_NOARGS, 0},
  {"__exit__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_25__exit__, METH_VARARGS|METH_KEYWORDS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_27__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_29__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4mars_6actors_4pool_11gevent_pool_ActorPool[] = {
  {(char *)"processes", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_9ActorPool_processes, 0, (char *)0, 0},
  {(char *)"cluster_info", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_9ActorPool_cluster_info, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_9ActorPool_cluster_info, (char *)0, 0},
  {(char *)"_dispatcher", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_9ActorPool__dispatcher, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_9ActorPool__dispatcher, (char *)0, 0},
  {(char *)"distributor", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_9ActorPool_distributor, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_9ActorPool_distributor, (char *)0, 0},
  {(char *)"_server", __pyx_getprop_4mars_6actors_4pool_11gevent_pool_9ActorPool__server, __pyx_setprop_4mars_6actors_4pool_11gevent_pool_9ActorPool__server, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorPool = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.ActorPool", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_ActorPool, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\n    1) If only 1 process, start local pool\n    2) More than 1, start dispatcher, and start local pool in several times\n    ", /*tp_doc*/
  __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_ActorPool, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_ActorPool, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4mars_6actors_4pool_11gevent_pool_ActorPool, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4mars_6actors_4pool_11gevent_pool_ActorPool, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4mars_6actors_4pool_11gevent_pool_9ActorPool_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorPool, /*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_vtabstruct_4mars_6actors_4pool_11gevent_pool_ActorClient __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorClient;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorClient(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *)o);
  p->__pyx_vtab = __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorClient;
  p->remote_handler = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_ActorClient(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->remote_handler);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_ActorClient(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *)o;
  if (p->remote_handler) {
    e = (*v)(p->remote_handler, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_ActorClient(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *)o;
  tmp = ((PyObject*)p->remote_handler);
  p->remote_handler = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_4mars_6actors_4pool_11gevent_pool_ActorClient[] = {
  {"create_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_3create_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"has_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_5has_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"destroy_actor", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_7destroy_actor, METH_VARARGS|METH_KEYWORDS, 0},
  {"actor_ref", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_9actor_ref, METH_VARARGS|METH_KEYWORDS, 0},
  {"sleep", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_11sleep, METH_VARARGS|METH_KEYWORDS, 0},
  {"threadpool", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_13threadpool, METH_VARARGS|METH_KEYWORDS, 0},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_15__reduce_cython__, METH_NOARGS, 0},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_17__setstate_cython__, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorClient = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.ActorClient", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool_ActorClient, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool_ActorClient, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool_ActorClient, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4mars_6actors_4pool_11gevent_pool_ActorClient, /*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*/
  __pyx_pw_4mars_6actors_4pool_11gevent_pool_11ActorClient_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4mars_6actors_4pool_11gevent_pool_ActorClient, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor *__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor[8];
static int __pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor = 0;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor)))) {
    o = (PyObject*)__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor[--__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor];
    memset(o, 0, sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor));
    (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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor)))) {
    __pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor[__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor++] = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor *)o;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorContext *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.__pyx_scope_struct__create_actor", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor *__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor[8];
static int __pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor = 0;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor)))) {
    o = (PyObject*)__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor[--__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor];
    memset(o, 0, sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor));
    (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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_callback);
  Py_CLEAR(p->__pyx_v_future);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor)))) {
    __pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor[__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor++] = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor *)o;
  if (p->__pyx_v_callback) {
    e = (*v)(p->__pyx_v_callback, a); if (e) return e;
  }
  if (p->__pyx_v_future) {
    e = (*v)(p->__pyx_v_future, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor *)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_future);
  p->__pyx_v_future = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.__pyx_scope_struct_1_create_actor", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run *__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run[8];
static int __pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run = 0;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run)))) {
    o = (PyObject*)__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run[--__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run];
    memset(o, 0, sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run));
    (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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_callback);
  Py_CLEAR(p->__pyx_v_future);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run)))) {
    __pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run[__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run++] = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run *)o;
  if (p->__pyx_v_callback) {
    e = (*v)(p->__pyx_v_callback, a); if (e) return e;
  }
  if (p->__pyx_v_future) {
    e = (*v)(p->__pyx_v_future, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run *)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_future);
  p->__pyx_v_future = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.__pyx_scope_struct_2__async_run", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local *__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local[8];
static int __pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local = 0;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local)))) {
    o = (PyObject*)__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local[--__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local];
    memset(o, 0, sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local));
    (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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_callback);
  Py_CLEAR(p->__pyx_v_future);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local)))) {
    __pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local[__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local++] = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local *)o;
  if (p->__pyx_v_callback) {
    e = (*v)(p->__pyx_v_callback, a); if (e) return e;
  }
  if (p->__pyx_v_future) {
    e = (*v)(p->__pyx_v_future, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local *)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_future);
  p->__pyx_v_future = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.__pyx_scope_struct_3__send_local", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process *__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process[8];
static int __pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process = 0;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process)))) {
    o = (PyObject*)__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process[--__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process];
    memset(o, 0, sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process));
    (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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_callback);
  Py_CLEAR(p->__pyx_v_future);
  Py_CLEAR(p->__pyx_v_message);
  Py_CLEAR(p->__pyx_v_message_id);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process)))) {
    __pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process[__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process++] = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process *)o;
  if (p->__pyx_v_callback) {
    e = (*v)(p->__pyx_v_callback, a); if (e) return e;
  }
  if (p->__pyx_v_future) {
    e = (*v)(p->__pyx_v_future, a); if (e) return e;
  }
  if (p->__pyx_v_message) {
    e = (*v)(p->__pyx_v_message, a); if (e) return e;
  }
  if (p->__pyx_v_message_id) {
    e = (*v)(p->__pyx_v_message_id, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process *)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_future);
  p->__pyx_v_future = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_message);
  p->__pyx_v_message = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_message_id);
  p->__pyx_v_message_id = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.__pyx_scope_struct_4__send_process", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor *__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor[8];
static int __pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor = 0;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor)))) {
    o = (PyObject*)__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor[--__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor];
    memset(o, 0, sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor));
    (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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_callback);
  Py_CLEAR(p->__pyx_v_future);
  Py_CLEAR(p->__pyx_v_message);
  Py_CLEAR(p->__pyx_v_message_id);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor)))) {
    __pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor[__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor++] = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor *)o;
  if (p->__pyx_v_callback) {
    e = (*v)(p->__pyx_v_callback, a); if (e) return e;
  }
  if (p->__pyx_v_future) {
    e = (*v)(p->__pyx_v_future, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor *)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_future);
  p->__pyx_v_future = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.__pyx_scope_struct_5__create_process_actor", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor *__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor[8];
static int __pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor = 0;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor)))) {
    o = (PyObject*)__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor[--__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor];
    memset(o, 0, sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor));
    (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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_callback);
  Py_CLEAR(p->__pyx_v_future);
  Py_CLEAR(p->__pyx_v_message);
  Py_CLEAR(p->__pyx_v_message_id);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor)))) {
    __pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor[__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor++] = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor *)o;
  if (p->__pyx_v_callback) {
    e = (*v)(p->__pyx_v_callback, a); if (e) return e;
  }
  if (p->__pyx_v_future) {
    e = (*v)(p->__pyx_v_future, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor *)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_future);
  p->__pyx_v_future = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.__pyx_scope_struct_6__destroy_process_actor", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor *__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor[8];
static int __pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor = 0;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor)))) {
    o = (PyObject*)__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor[--__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor];
    memset(o, 0, sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor));
    (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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_callback);
  Py_CLEAR(p->__pyx_v_future);
  Py_CLEAR(p->__pyx_v_message);
  Py_CLEAR(p->__pyx_v_message_id);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor)))) {
    __pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor[__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor++] = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor *)o;
  if (p->__pyx_v_callback) {
    e = (*v)(p->__pyx_v_callback, a); if (e) return e;
  }
  if (p->__pyx_v_future) {
    e = (*v)(p->__pyx_v_future, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor *)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_future);
  p->__pyx_v_future = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.__pyx_scope_struct_7__has_process_actor", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send *__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send[8];
static int __pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send = 0;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send)))) {
    o = (PyObject*)__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send[--__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send];
    memset(o, 0, sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send));
    (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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_callback);
  Py_CLEAR(p->__pyx_v_future);
  Py_CLEAR(p->__pyx_v_message_id);
  Py_CLEAR(p->__pyx_v_messages);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send)))) {
    __pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send[__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send++] = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send *)o;
  if (p->__pyx_v_callback) {
    e = (*v)(p->__pyx_v_callback, a); if (e) return e;
  }
  if (p->__pyx_v_future) {
    e = (*v)(p->__pyx_v_future, a); if (e) return e;
  }
  if (p->__pyx_v_messages) {
    e = (*v)(p->__pyx_v_messages, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send *)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_future);
  p->__pyx_v_future = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_messages);
  p->__pyx_v_messages = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.__pyx_scope_struct_8__send", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor *__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor[8];
static int __pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor = 0;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor)))) {
    o = (PyObject*)__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor[--__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor];
    memset(o, 0, sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor));
    (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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_callback);
  Py_CLEAR(p->__pyx_v_future);
  Py_CLEAR(p->__pyx_v_message);
  Py_CLEAR(p->__pyx_v_message_id);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor)))) {
    __pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor[__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor++] = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor *)o;
  if (p->__pyx_v_callback) {
    e = (*v)(p->__pyx_v_callback, a); if (e) return e;
  }
  if (p->__pyx_v_future) {
    e = (*v)(p->__pyx_v_future, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor *)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_future);
  p->__pyx_v_future = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.__pyx_scope_struct_9_create_actor", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor *__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor[8];
static int __pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor = 0;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor)))) {
    o = (PyObject*)__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor[--__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor];
    memset(o, 0, sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor));
    (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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_callback);
  Py_CLEAR(p->__pyx_v_future);
  Py_CLEAR(p->__pyx_v_message);
  Py_CLEAR(p->__pyx_v_message_id);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor)))) {
    __pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor[__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor++] = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor *)o;
  if (p->__pyx_v_callback) {
    e = (*v)(p->__pyx_v_callback, a); if (e) return e;
  }
  if (p->__pyx_v_future) {
    e = (*v)(p->__pyx_v_future, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor *)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_future);
  p->__pyx_v_future = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.__pyx_scope_struct_10_destroy_actor", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor *__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor[8];
static int __pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor = 0;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor)))) {
    o = (PyObject*)__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor[--__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor];
    memset(o, 0, sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor));
    (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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_callback);
  Py_CLEAR(p->__pyx_v_future);
  Py_CLEAR(p->__pyx_v_message);
  Py_CLEAR(p->__pyx_v_message_id);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor)))) {
    __pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor[__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor++] = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor *)o;
  if (p->__pyx_v_callback) {
    e = (*v)(p->__pyx_v_callback, a); if (e) return e;
  }
  if (p->__pyx_v_future) {
    e = (*v)(p->__pyx_v_future, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor *)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_future);
  p->__pyx_v_future = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.__pyx_scope_struct_11_has_actor", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run *__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run[8];
static int __pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run = 0;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run)))) {
    o = (PyObject*)__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run[--__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run];
    memset(o, 0, sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run));
    (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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run)))) {
    __pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run[__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run++] = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run *)o;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.__pyx_scope_struct_12_run", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr *__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr[8];
static int __pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr = 0;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr)))) {
    o = (PyObject*)__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr[--__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr));
    (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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_p);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr)))) {
    __pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr[__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr++] = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_p) {
    e = (*v)(p->__pyx_v_p, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.__pyx_scope_struct_13_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr, /*tp_traverse*/
  0, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor *__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor[8];
static int __pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor = 0;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor)))) {
    o = (PyObject*)__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor[--__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor];
    memset(o, 0, sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor));
    (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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_address);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor)))) {
    __pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor[__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor++] = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor *)o;
  if (p->__pyx_v_address) {
    e = (*v)(p->__pyx_v_address, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor *)o;
  tmp = ((PyObject*)p->__pyx_v_address);
  p->__pyx_v_address = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.__pyx_scope_struct_14_create_actor", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run[8];
static int __pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run = 0;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run)))) {
    o = (PyObject*)__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run[--__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run];
    memset(o, 0, sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run));
    (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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run)))) {
    __pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run[__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run++] = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run *)o;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.__pyx_scope_struct_15_run", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run, /*tp_traverse*/
  __pyx_tp_clear_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr *__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr[8];
static int __pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr = 0;

static PyObject *__pyx_tp_new_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr)))) {
    o = (PyObject*)__pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr[--__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr));
    (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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr(PyObject *o) {
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr)))) {
    __pyx_freelist_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr[__pyx_freecount_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr++] = ((struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr *p = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "mars.actors.pool.gevent_pool.__pyx_scope_struct_16_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr, /*tp_traverse*/
  0, /*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_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr, /*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[] = {
  {"start_actor_server", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4mars_6actors_4pool_11gevent_pool_1start_actor_server, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_gevent_pool(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_gevent_pool},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "gevent_pool",
    0, /* m_doc */
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    0, /* m_size */
  #else
    -1, /* m_size */
  #endif
    __pyx_methods /* m_methods */,
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    __pyx_moduledef_slots, /* m_slots */
  #else
    NULL, /* m_reload */
  #endif
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
    #define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
    #define CYTHON_SMALL_CODE __attribute__((cold))
#else
    #define CYTHON_SMALL_CODE
#endif
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_s_ActorAlreadyExist, __pyx_k_ActorAlreadyExist, sizeof(__pyx_k_ActorAlreadyExist), 0, 0, 1, 1},
  {&__pyx_n_s_ActorClient, __pyx_k_ActorClient, sizeof(__pyx_k_ActorClient), 0, 0, 1, 1},
  {&__pyx_n_s_ActorContext, __pyx_k_ActorContext, sizeof(__pyx_k_ActorContext), 0, 0, 1, 1},
  {&__pyx_n_s_ActorExecutionContext, __pyx_k_ActorExecutionContext, sizeof(__pyx_k_ActorExecutionContext), 0, 0, 1, 1},
  {&__pyx_n_s_ActorNotExist, __pyx_k_ActorNotExist, sizeof(__pyx_k_ActorNotExist), 0, 0, 1, 1},
  {&__pyx_n_s_ActorPool, __pyx_k_ActorPool, sizeof(__pyx_k_ActorPool), 0, 0, 1, 1},
  {&__pyx_n_s_ActorPoolNotStarted, __pyx_k_ActorPoolNotStarted, sizeof(__pyx_k_ActorPoolNotStarted), 0, 0, 1, 1},
  {&__pyx_n_s_ActorRemoteHelper, __pyx_k_ActorRemoteHelper, sizeof(__pyx_k_ActorRemoteHelper), 0, 0, 1, 1},
  {&__pyx_n_s_ActorServerHandler, __pyx_k_ActorServerHandler, sizeof(__pyx_k_ActorServerHandler), 0, 0, 1, 1},
  {&__pyx_n_s_ActorStreamServer, __pyx_k_ActorStreamServer, sizeof(__pyx_k_ActorStreamServer), 0, 0, 1, 1},
  {&__pyx_n_s_ActorStreamServer___init, __pyx_k_ActorStreamServer___init, sizeof(__pyx_k_ActorStreamServer___init), 0, 0, 1, 1},
  {&__pyx_n_s_ActorStreamServer_add_sock, __pyx_k_ActorStreamServer_add_sock, sizeof(__pyx_k_ActorStreamServer_add_sock), 0, 0, 1, 1},
  {&__pyx_n_s_ActorStreamServer_close, __pyx_k_ActorStreamServer_close, sizeof(__pyx_k_ActorStreamServer_close), 0, 0, 1, 1},
  {&__pyx_kp_s_Actor_0_already_exist_cannot_cre, __pyx_k_Actor_0_already_exist_cannot_cre, sizeof(__pyx_k_Actor_0_already_exist_cannot_cre), 0, 0, 1, 0},
  {&__pyx_kp_s_Actor_0_does_not_exist, __pyx_k_Actor_0_does_not_exist, sizeof(__pyx_k_Actor_0_does_not_exist), 0, 0, 1, 0},
  {&__pyx_kp_s_Actor_pool_need_to_run_first, __pyx_k_Actor_pool_need_to_run_first, sizeof(__pyx_k_Actor_pool_need_to_run_first), 0, 0, 1, 0},
  {&__pyx_n_s_AsyncHandler, __pyx_k_AsyncHandler, sizeof(__pyx_k_AsyncHandler), 0, 0, 1, 1},
  {&__pyx_n_s_AsyncResult, __pyx_k_AsyncResult, sizeof(__pyx_k_AsyncResult), 0, 0, 1, 1},
  {&__pyx_n_s_AttributeError, __pyx_k_AttributeError, sizeof(__pyx_k_AttributeError), 0, 0, 1, 1},
  {&__pyx_kp_s_Both_address_and_port_should_be, __pyx_k_Both_address_and_port_should_be, sizeof(__pyx_k_Both_address_and_port_should_be), 0, 0, 1, 0},
  {&__pyx_n_s_BrokenPipeError, __pyx_k_BrokenPipeError, sizeof(__pyx_k_BrokenPipeError), 0, 0, 1, 1},
  {&__pyx_n_s_Communicator, __pyx_k_Communicator, sizeof(__pyx_k_Communicator), 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_Connections___del, __pyx_k_Connections___del, sizeof(__pyx_k_Connections___del), 0, 0, 1, 1},
  {&__pyx_n_s_Connections___init, __pyx_k_Connections___init, sizeof(__pyx_k_Connections___init), 0, 0, 1, 1},
  {&__pyx_n_s_Connections__connect, __pyx_k_Connections__connect, sizeof(__pyx_k_Connections__connect), 0, 0, 1, 1},
  {&__pyx_n_s_Connections_conn, __pyx_k_Connections_conn, sizeof(__pyx_k_Connections_conn), 0, 0, 1, 1},
  {&__pyx_n_s_Connections_connect, __pyx_k_Connections_connect, sizeof(__pyx_k_Connections_connect), 0, 0, 1, 1},
  {&__pyx_n_s_Connections_connect_locals_close, __pyx_k_Connections_connect_locals_close, sizeof(__pyx_k_Connections_connect_locals_close), 0, 0, 1, 1},
  {&__pyx_n_s_Connections_got_broken_pipe, __pyx_k_Connections_got_broken_pipe, sizeof(__pyx_k_Connections_got_broken_pipe), 0, 0, 1, 1},
  {&__pyx_n_s_Dispatcher, __pyx_k_Dispatcher, sizeof(__pyx_k_Dispatcher), 0, 0, 1, 1},
  {&__pyx_n_s_EOFError, __pyx_k_EOFError, sizeof(__pyx_k_EOFError), 0, 0, 1, 1},
  {&__pyx_n_s_EPIPE, __pyx_k_EPIPE, sizeof(__pyx_k_EPIPE), 0, 0, 1, 1},
  {&__pyx_n_s_Event, __pyx_k_Event, sizeof(__pyx_k_Event), 0, 0, 1, 1},
  {&__pyx_n_s_FileObject, __pyx_k_FileObject, sizeof(__pyx_k_FileObject), 0, 0, 1, 1},
  {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0},
  {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0},
  {&__pyx_n_s_GIPCClosed, __pyx_k_GIPCClosed, sizeof(__pyx_k_GIPCClosed), 0, 0, 1, 1},
  {&__pyx_n_s_GIPCLocked, __pyx_k_GIPCLocked, sizeof(__pyx_k_GIPCLocked), 0, 0, 1, 1},
  {&__pyx_n_s_GThreadPool, __pyx_k_GThreadPool, sizeof(__pyx_k_GThreadPool), 0, 0, 1, 1},
  {&__pyx_n_s_Group, __pyx_k_Group, sizeof(__pyx_k_Group), 0, 0, 1, 1},
  {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x06, __pyx_k_Incompatible_checksums_s_vs_0x06, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x06), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x16, __pyx_k_Incompatible_checksums_s_vs_0x16, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x16), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x2b, __pyx_k_Incompatible_checksums_s_vs_0x2b, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x2b), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x2e, __pyx_k_Incompatible_checksums_s_vs_0x2e, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x2e), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x37, __pyx_k_Incompatible_checksums_s_vs_0x37, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x37), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x40, __pyx_k_Incompatible_checksums_s_vs_0x40, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x40), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0x92, __pyx_k_Incompatible_checksums_s_vs_0x92, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x92), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xa6, __pyx_k_Incompatible_checksums_s_vs_0xa6, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xa6), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xb0, __pyx_k_Incompatible_checksums_s_vs_0xb0, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xb0), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xcb, __pyx_k_Incompatible_checksums_s_vs_0xcb, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xcb), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xd3, __pyx_k_Incompatible_checksums_s_vs_0xd3, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xd3), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xe9, __pyx_k_Incompatible_checksums_s_vs_0xe9, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xe9), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_s_vs_0xf7, __pyx_k_Incompatible_checksums_s_vs_0xf7, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xf7), 0, 0, 1, 0},
  {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1},
  {&__pyx_n_s_LocalActorPool, __pyx_k_LocalActorPool, sizeof(__pyx_k_LocalActorPool), 0, 0, 1, 1},
  {&__pyx_n_s_MessageContext, __pyx_k_MessageContext, sizeof(__pyx_k_MessageContext), 0, 0, 1, 1},
  {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0},
  {&__pyx_kp_s_Not_allow_to_send_message_to_rem, __pyx_k_Not_allow_to_send_message_to_rem, sizeof(__pyx_k_Not_allow_to_send_message_to_rem), 0, 0, 1, 0},
  {&__pyx_n_s_OrderedDict, __pyx_k_OrderedDict, sizeof(__pyx_k_OrderedDict), 0, 0, 1, 1},
  {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_PicklingError, __pyx_k_PicklingError, sizeof(__pyx_k_PicklingError), 0, 0, 1, 1},
  {&__pyx_n_s_Pool, __pyx_k_Pool, sizeof(__pyx_k_Pool), 0, 0, 1, 1},
  {&__pyx_n_s_Popen, __pyx_k_Popen, sizeof(__pyx_k_Popen), 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_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_n_s_Semaphore, __pyx_k_Semaphore, sizeof(__pyx_k_Semaphore), 0, 0, 1, 1},
  {&__pyx_n_s_StreamServer, __pyx_k_StreamServer, sizeof(__pyx_k_StreamServer), 0, 0, 1, 1},
  {&__pyx_n_s_ThreadPool, __pyx_k_ThreadPool, sizeof(__pyx_k_ThreadPool), 0, 0, 1, 1},
  {&__pyx_kp_s_Unable_to_pickle_0_1_2, __pyx_k_Unable_to_pickle_0_1_2, sizeof(__pyx_k_Unable_to_pickle_0_1_2), 0, 0, 1, 0},
  {&__pyx_kp_s_Unable_to_pickle_message_0, __pyx_k_Unable_to_pickle_message_0, sizeof(__pyx_k_Unable_to_pickle_message_0), 0, 0, 1, 0},
  {&__pyx_kp_s_Unable_to_pickle_message_0_2, __pyx_k_Unable_to_pickle_message_0_2, sizeof(__pyx_k_Unable_to_pickle_message_0_2), 0, 0, 1, 0},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_kp_s__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 0, 1, 0},
  {&__pyx_n_s__66, __pyx_k__66, sizeof(__pyx_k__66), 0, 0, 1, 1},
  {&__pyx_n_s_acquire, __pyx_k_acquire, sizeof(__pyx_k_acquire), 0, 0, 1, 1},
  {&__pyx_n_s_actor, __pyx_k_actor, sizeof(__pyx_k_actor), 0, 0, 1, 1},
  {&__pyx_n_s_actor_cls, __pyx_k_actor_cls, sizeof(__pyx_k_actor_cls), 0, 0, 1, 1},
  {&__pyx_n_s_actor_ref, __pyx_k_actor_ref, sizeof(__pyx_k_actor_ref), 0, 0, 1, 1},
  {&__pyx_n_s_add_sock, __pyx_k_add_sock, sizeof(__pyx_k_add_sock), 0, 0, 1, 1},
  {&__pyx_n_s_address, __pyx_k_address, sizeof(__pyx_k_address), 0, 0, 1, 1},
  {&__pyx_kp_s_address_must_be_provided, __pyx_k_address_must_be_provided, sizeof(__pyx_k_address_must_be_provided), 0, 0, 1, 0},
  {&__pyx_n_s_addrs, __pyx_k_addrs, sizeof(__pyx_k_addrs), 0, 0, 1, 1},
  {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
  {&__pyx_n_s_apply, __pyx_k_apply, sizeof(__pyx_k_apply), 0, 0, 1, 1},
  {&__pyx_n_s_apply_async, __pyx_k_apply_async, sizeof(__pyx_k_apply_async), 0, 0, 1, 1},
  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  {&__pyx_n_s_async_run, __pyx_k_async_run, sizeof(__pyx_k_async_run), 0, 0, 1, 1},
  {&__pyx_n_s_async_run_locals_on_failure, __pyx_k_async_run_locals_on_failure, sizeof(__pyx_k_async_run_locals_on_failure), 0, 0, 1, 1},
  {&__pyx_n_s_async_run_locals_on_success, __pyx_k_async_run_locals_on_success, sizeof(__pyx_k_async_run_locals_on_success), 0, 0, 1, 1},
  {&__pyx_n_s_binaries, __pyx_k_binaries, sizeof(__pyx_k_binaries), 0, 0, 1, 1},
  {&__pyx_n_s_binary, __pyx_k_binary, sizeof(__pyx_k_binary), 0, 0, 1, 1},
  {&__pyx_n_s_blocking, __pyx_k_blocking, sizeof(__pyx_k_blocking), 0, 0, 1, 1},
  {&__pyx_n_s_bufsize, __pyx_k_bufsize, sizeof(__pyx_k_bufsize), 0, 0, 1, 1},
  {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
  {&__pyx_n_s_callback, __pyx_k_callback, sizeof(__pyx_k_callback), 0, 0, 1, 1},
  {&__pyx_n_s_check, __pyx_k_check, sizeof(__pyx_k_check), 0, 0, 1, 1},
  {&__pyx_n_s_check_pipe, __pyx_k_check_pipe, sizeof(__pyx_k_check_pipe), 0, 0, 1, 1},
  {&__pyx_n_s_clear, __pyx_k_clear, sizeof(__pyx_k_clear), 0, 0, 1, 1},
  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  {&__pyx_n_s_close_pipe, __pyx_k_close_pipe, sizeof(__pyx_k_close_pipe), 0, 0, 1, 1},
  {&__pyx_n_s_cluster_info, __pyx_k_cluster_info, sizeof(__pyx_k_cluster_info), 0, 0, 1, 1},
  {&__pyx_n_s_comm, __pyx_k_comm, sizeof(__pyx_k_comm), 0, 0, 1, 1},
  {&__pyx_n_s_compat, __pyx_k_compat, sizeof(__pyx_k_compat), 0, 0, 1, 1},
  {&__pyx_n_s_conn, __pyx_k_conn, sizeof(__pyx_k_conn), 0, 0, 1, 1},
  {&__pyx_n_s_conn_lock, __pyx_k_conn_lock, sizeof(__pyx_k_conn_lock), 0, 0, 1, 1},
  {&__pyx_n_s_conn_locks, __pyx_k_conn_locks, sizeof(__pyx_k_conn_locks), 0, 0, 1, 1},
  {&__pyx_n_s_connect, __pyx_k_connect, sizeof(__pyx_k_connect), 0, 0, 1, 1},
  {&__pyx_n_s_connect_2, __pyx_k_connect_2, sizeof(__pyx_k_connect_2), 0, 0, 1, 1},
  {&__pyx_n_s_create_actor, __pyx_k_create_actor, sizeof(__pyx_k_create_actor), 0, 0, 1, 1},
  {&__pyx_n_s_create_actor_locals_callback, __pyx_k_create_actor_locals_callback, sizeof(__pyx_k_create_actor_locals_callback), 0, 0, 1, 1},
  {&__pyx_n_s_create_actor_locals_check, __pyx_k_create_actor_locals_check, sizeof(__pyx_k_create_actor_locals_check), 0, 0, 1, 1},
  {&__pyx_n_s_create_actor_locals_on_failure, __pyx_k_create_actor_locals_on_failure, sizeof(__pyx_k_create_actor_locals_on_failure), 0, 0, 1, 1},
  {&__pyx_n_s_create_actor_locals_on_success, __pyx_k_create_actor_locals_on_success, sizeof(__pyx_k_create_actor_locals_on_success), 0, 0, 1, 1},
  {&__pyx_n_s_create_actor_ref, __pyx_k_create_actor_ref, sizeof(__pyx_k_create_actor_ref), 0, 0, 1, 1},
  {&__pyx_n_s_create_connection, __pyx_k_create_connection, sizeof(__pyx_k_create_connection), 0, 0, 1, 1},
  {&__pyx_n_s_create_local_actor, __pyx_k_create_local_actor, sizeof(__pyx_k_create_local_actor), 0, 0, 1, 1},
  {&__pyx_n_s_create_process_actor, __pyx_k_create_process_actor, sizeof(__pyx_k_create_process_actor), 0, 0, 1, 1},
  {&__pyx_n_s_create_process_actor_locals_che, __pyx_k_create_process_actor_locals_che, sizeof(__pyx_k_create_process_actor_locals_che), 0, 0, 1, 1},
  {&__pyx_n_s_create_remote_actor, __pyx_k_create_remote_actor, sizeof(__pyx_k_create_remote_actor), 0, 0, 1, 1},
  {&__pyx_n_s_ctx, __pyx_k_ctx, sizeof(__pyx_k_ctx), 0, 0, 1, 1},
  {&__pyx_n_s_daemon, __pyx_k_daemon, sizeof(__pyx_k_daemon), 0, 0, 1, 1},
  {&__pyx_n_s_decoder, __pyx_k_decoder, sizeof(__pyx_k_decoder), 0, 0, 1, 1},
  {&__pyx_n_s_del, __pyx_k_del, sizeof(__pyx_k_del), 0, 0, 1, 1},
  {&__pyx_n_s_delay, __pyx_k_delay, sizeof(__pyx_k_delay), 0, 0, 1, 1},
  {&__pyx_n_s_destroy_actor, __pyx_k_destroy_actor, sizeof(__pyx_k_destroy_actor), 0, 0, 1, 1},
  {&__pyx_n_s_destroy_actor_locals_check, __pyx_k_destroy_actor_locals_check, sizeof(__pyx_k_destroy_actor_locals_check), 0, 0, 1, 1},
  {&__pyx_n_s_destroy_local_actor, __pyx_k_destroy_local_actor, sizeof(__pyx_k_destroy_local_actor), 0, 0, 1, 1},
  {&__pyx_n_s_destroy_process_actor, __pyx_k_destroy_process_actor, sizeof(__pyx_k_destroy_process_actor), 0, 0, 1, 1},
  {&__pyx_n_s_destroy_process_actor_locals_ch, __pyx_k_destroy_process_actor_locals_ch, sizeof(__pyx_k_destroy_process_actor_locals_ch), 0, 0, 1, 1},
  {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
  {&__pyx_n_s_discard, __pyx_k_discard, sizeof(__pyx_k_discard), 0, 0, 1, 1},
  {&__pyx_n_s_dispatch, __pyx_k_dispatch, sizeof(__pyx_k_dispatch), 0, 0, 1, 1},
  {&__pyx_n_s_distribute, __pyx_k_distribute, sizeof(__pyx_k_distribute), 0, 0, 1, 1},
  {&__pyx_n_s_distributor, __pyx_k_distributor, sizeof(__pyx_k_distributor), 0, 0, 1, 1},
  {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  {&__pyx_n_s_encoder, __pyx_k_encoder, sizeof(__pyx_k_encoder), 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_type, __pyx_k_error_type, sizeof(__pyx_k_error_type), 0, 0, 1, 1},
  {&__pyx_n_s_errors, __pyx_k_errors, sizeof(__pyx_k_errors), 0, 0, 1, 1},
  {&__pyx_n_s_event, __pyx_k_event, sizeof(__pyx_k_event), 0, 0, 1, 1},
  {&__pyx_n_s_ex, __pyx_k_ex, sizeof(__pyx_k_ex), 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_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
  {&__pyx_n_s_fd, __pyx_k_fd, sizeof(__pyx_k_fd), 0, 0, 1, 1},
  {&__pyx_n_s_fileno, __pyx_k_fileno, sizeof(__pyx_k_fileno), 0, 0, 1, 1},
  {&__pyx_n_s_fileobject, __pyx_k_fileobject, sizeof(__pyx_k_fileobject), 0, 0, 1, 1},
  {&__pyx_n_s_fire_run, __pyx_k_fire_run, sizeof(__pyx_k_fire_run), 0, 0, 1, 1},
  {&__pyx_n_s_fn, __pyx_k_fn, sizeof(__pyx_k_fn), 0, 0, 1, 1},
  {&__pyx_n_s_fobj, __pyx_k_fobj, sizeof(__pyx_k_fobj), 0, 0, 1, 1},
  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  {&__pyx_n_s_from_index, __pyx_k_from_index, sizeof(__pyx_k_from_index), 0, 0, 1, 1},
  {&__pyx_n_s_future, __pyx_k_future, sizeof(__pyx_k_future), 0, 0, 1, 1},
  {&__pyx_n_s_g, __pyx_k_g, sizeof(__pyx_k_g), 0, 0, 1, 1},
  {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  {&__pyx_n_s_get_actor_execution_ctx, __pyx_k_get_actor_execution_ctx, sizeof(__pyx_k_get_actor_execution_ctx), 0, 0, 1, 1},
  {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  {&__pyx_n_s_gevent, __pyx_k_gevent, sizeof(__pyx_k_gevent), 0, 0, 1, 1},
  {&__pyx_n_s_gevent__tblib, __pyx_k_gevent__tblib, sizeof(__pyx_k_gevent__tblib), 0, 0, 1, 1},
  {&__pyx_n_s_gevent_event, __pyx_k_gevent_event, sizeof(__pyx_k_gevent_event), 0, 0, 1, 1},
  {&__pyx_n_s_gevent_fileobject, __pyx_k_gevent_fileobject, sizeof(__pyx_k_gevent_fileobject), 0, 0, 1, 1},
  {&__pyx_n_s_gevent_init_tblib, __pyx_k_gevent_init_tblib, sizeof(__pyx_k_gevent_init_tblib), 0, 0, 1, 1},
  {&__pyx_n_s_gevent_lock, __pyx_k_gevent_lock, sizeof(__pyx_k_gevent_lock), 0, 0, 1, 1},
  {&__pyx_n_s_gevent_pool, __pyx_k_gevent_pool, sizeof(__pyx_k_gevent_pool), 0, 0, 1, 1},
  {&__pyx_n_s_gevent_queue, __pyx_k_gevent_queue, sizeof(__pyx_k_gevent_queue), 0, 0, 1, 1},
  {&__pyx_n_s_gevent_server, __pyx_k_gevent_server, sizeof(__pyx_k_gevent_server), 0, 0, 1, 1},
  {&__pyx_n_s_gevent_socket, __pyx_k_gevent_socket, sizeof(__pyx_k_gevent_socket), 0, 0, 1, 1},
  {&__pyx_n_s_gevent_subprocess, __pyx_k_gevent_subprocess, sizeof(__pyx_k_gevent_subprocess), 0, 0, 1, 1},
  {&__pyx_n_s_gevent_threadpool, __pyx_k_gevent_threadpool, sizeof(__pyx_k_gevent_threadpool), 0, 0, 1, 1},
  {&__pyx_n_s_gipc, __pyx_k_gipc, sizeof(__pyx_k_gipc), 0, 0, 1, 1},
  {&__pyx_n_s_global_lock, __pyx_k_global_lock, sizeof(__pyx_k_global_lock), 0, 0, 1, 1},
  {&__pyx_n_s_got, __pyx_k_got, sizeof(__pyx_k_got), 0, 0, 1, 1},
  {&__pyx_n_s_got_broken_pipe, __pyx_k_got_broken_pipe, sizeof(__pyx_k_got_broken_pipe), 0, 0, 1, 1},
  {&__pyx_n_s_handler, __pyx_k_handler, sizeof(__pyx_k_handler), 0, 0, 1, 1},
  {&__pyx_n_s_has_actor, __pyx_k_has_actor, sizeof(__pyx_k_has_actor), 0, 0, 1, 1},
  {&__pyx_n_s_has_actor_locals_check, __pyx_k_has_actor_locals_check, sizeof(__pyx_k_has_actor_locals_check), 0, 0, 1, 1},
  {&__pyx_n_s_has_local_actor, __pyx_k_has_local_actor, sizeof(__pyx_k_has_local_actor), 0, 0, 1, 1},
  {&__pyx_n_s_has_process_actor, __pyx_k_has_process_actor, sizeof(__pyx_k_has_process_actor), 0, 0, 1, 1},
  {&__pyx_n_s_has_process_actor_locals_check, __pyx_k_has_process_actor_locals_check, sizeof(__pyx_k_has_process_actor_locals_check), 0, 0, 1, 1},
  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  {&__pyx_n_s_idx, __pyx_k_idx, sizeof(__pyx_k_idx), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_inaction_decoder, __pyx_k_inaction_decoder, sizeof(__pyx_k_inaction_decoder), 0, 0, 1, 1},
  {&__pyx_n_s_inaction_encoder, __pyx_k_inaction_encoder, sizeof(__pyx_k_inaction_encoder), 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_init_2, __pyx_k_init_2, sizeof(__pyx_k_init_2), 0, 0, 1, 1},
  {&__pyx_n_s_is_alive, __pyx_k_is_alive, sizeof(__pyx_k_is_alive), 0, 0, 1, 1},
  {&__pyx_n_s_islice, __pyx_k_islice, sizeof(__pyx_k_islice), 0, 0, 1, 1},
  {&__pyx_n_s_iteritems, __pyx_k_iteritems, sizeof(__pyx_k_iteritems), 0, 0, 1, 1},
  {&__pyx_n_s_iterkeys, __pyx_k_iterkeys, sizeof(__pyx_k_iterkeys), 0, 0, 1, 1},
  {&__pyx_n_s_itertools, __pyx_k_itertools, sizeof(__pyx_k_itertools), 0, 0, 1, 1},
  {&__pyx_n_s_itervalues, __pyx_k_itervalues, sizeof(__pyx_k_itervalues), 0, 0, 1, 1},
  {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
  {&__pyx_n_s_joinall, __pyx_k_joinall, sizeof(__pyx_k_joinall), 0, 0, 1, 1},
  {&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
  {&__pyx_n_s_l, __pyx_k_l, sizeof(__pyx_k_l), 0, 0, 1, 1},
  {&__pyx_n_s_lib, __pyx_k_lib, sizeof(__pyx_k_lib), 0, 0, 1, 1},
  {&__pyx_n_s_link_exception, __pyx_k_link_exception, sizeof(__pyx_k_link_exception), 0, 0, 1, 1},
  {&__pyx_n_s_link_value, __pyx_k_link_value, sizeof(__pyx_k_link_value), 0, 0, 1, 1},
  {&__pyx_n_s_listener, __pyx_k_listener, sizeof(__pyx_k_listener), 0, 0, 1, 1},
  {&__pyx_n_s_lk, __pyx_k_lk, sizeof(__pyx_k_lk), 0, 0, 1, 1},
  {&__pyx_n_s_local_func, __pyx_k_local_func, sizeof(__pyx_k_local_func), 0, 0, 1, 1},
  {&__pyx_n_s_local_pool, __pyx_k_local_pool, sizeof(__pyx_k_local_pool), 0, 0, 1, 1},
  {&__pyx_n_s_lock, __pyx_k_lock, sizeof(__pyx_k_lock), 0, 0, 1, 1},
  {&__pyx_n_s_locked, __pyx_k_locked, sizeof(__pyx_k_locked), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_mars_actors_pool_gevent_pool, __pyx_k_mars_actors_pool_gevent_pool, sizeof(__pyx_k_mars_actors_pool_gevent_pool), 0, 0, 1, 1},
  {&__pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_k_mars_actors_pool_gevent_pool_pyx, sizeof(__pyx_k_mars_actors_pool_gevent_pool_pyx), 0, 0, 1, 0},
  {&__pyx_n_s_maxlen, __pyx_k_maxlen, sizeof(__pyx_k_maxlen), 0, 0, 1, 1},
  {&__pyx_n_s_message, __pyx_k_message, sizeof(__pyx_k_message), 0, 0, 1, 1},
  {&__pyx_n_s_message_id, __pyx_k_message_id, sizeof(__pyx_k_message_id), 0, 0, 1, 1},
  {&__pyx_n_s_messages, __pyx_k_messages, sizeof(__pyx_k_messages), 0, 0, 1, 1},
  {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
  {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  {&__pyx_n_s_multi_process, __pyx_k_multi_process, sizeof(__pyx_k_multi_process), 0, 0, 1, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0},
  {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0},
  {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
  {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
  {&__pyx_n_s_num_threads, __pyx_k_num_threads, sizeof(__pyx_k_num_threads), 0, 0, 1, 1},
  {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  {&__pyx_kp_s_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 0, 1, 0},
  {&__pyx_kp_s_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 0, 1, 0},
  {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
  {&__pyx_n_s_on_failure, __pyx_k_on_failure, sizeof(__pyx_k_on_failure), 0, 0, 1, 1},
  {&__pyx_n_s_on_receive, __pyx_k_on_receive, sizeof(__pyx_k_on_receive), 0, 0, 1, 1},
  {&__pyx_n_s_on_receive_action, __pyx_k_on_receive_action, sizeof(__pyx_k_on_receive_action), 0, 0, 1, 1},
  {&__pyx_n_s_on_receive_create_actor, __pyx_k_on_receive_create_actor, sizeof(__pyx_k_on_receive_create_actor), 0, 0, 1, 1},
  {&__pyx_n_s_on_receive_destroy_actor, __pyx_k_on_receive_destroy_actor, sizeof(__pyx_k_on_receive_destroy_actor), 0, 0, 1, 1},
  {&__pyx_n_s_on_receive_error, __pyx_k_on_receive_error, sizeof(__pyx_k_on_receive_error), 0, 0, 1, 1},
  {&__pyx_n_s_on_receive_has_actor, __pyx_k_on_receive_has_actor, sizeof(__pyx_k_on_receive_has_actor), 0, 0, 1, 1},
  {&__pyx_n_s_on_receive_locals_lambda, __pyx_k_on_receive_locals_lambda, sizeof(__pyx_k_on_receive_locals_lambda), 0, 0, 1, 1},
  {&__pyx_n_s_on_receive_result, __pyx_k_on_receive_result, sizeof(__pyx_k_on_receive_result), 0, 0, 1, 1},
  {&__pyx_n_s_on_receive_send, __pyx_k_on_receive_send, sizeof(__pyx_k_on_receive_send), 0, 0, 1, 1},
  {&__pyx_n_s_on_receive_tell, __pyx_k_on_receive_tell, sizeof(__pyx_k_on_receive_tell), 0, 0, 1, 1},
  {&__pyx_n_s_on_success, __pyx_k_on_success, sizeof(__pyx_k_on_success), 0, 0, 1, 1},
  {&__pyx_n_s_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 0, 1, 1},
  {&__pyx_n_s_parallel, __pyx_k_parallel, sizeof(__pyx_k_parallel), 0, 0, 1, 1},
  {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
  {&__pyx_n_s_pipe, __pyx_k_pipe, sizeof(__pyx_k_pipe), 0, 0, 1, 1},
  {&__pyx_n_s_pipes, __pyx_k_pipes, sizeof(__pyx_k_pipes), 0, 0, 1, 1},
  {&__pyx_n_s_pool, __pyx_k_pool, sizeof(__pyx_k_pool), 0, 0, 1, 1},
  {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
  {&__pyx_n_s_popen, __pyx_k_popen, sizeof(__pyx_k_popen), 0, 0, 1, 1},
  {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  {&__pyx_n_s_process, __pyx_k_process, sizeof(__pyx_k_process), 0, 0, 1, 1},
  {&__pyx_n_s_property, __pyx_k_property, sizeof(__pyx_k_property), 0, 0, 1, 1},
  {&__pyx_n_s_ps, __pyx_k_ps, sizeof(__pyx_k_ps), 0, 0, 1, 1},
  {&__pyx_n_s_put, __pyx_k_put, sizeof(__pyx_k_put), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_ActorClient, __pyx_k_pyx_unpickle_ActorClient, sizeof(__pyx_k_pyx_unpickle_ActorClient), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_ActorContext, __pyx_k_pyx_unpickle_ActorContext, sizeof(__pyx_k_pyx_unpickle_ActorContext), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_ActorExecutionCon, __pyx_k_pyx_unpickle_ActorExecutionCon, sizeof(__pyx_k_pyx_unpickle_ActorExecutionCon), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_ActorPool, __pyx_k_pyx_unpickle_ActorPool, sizeof(__pyx_k_pyx_unpickle_ActorPool), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_ActorRemoteHelper, __pyx_k_pyx_unpickle_ActorRemoteHelper, sizeof(__pyx_k_pyx_unpickle_ActorRemoteHelper), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_ActorServerHandle, __pyx_k_pyx_unpickle_ActorServerHandle, sizeof(__pyx_k_pyx_unpickle_ActorServerHandle), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_AsyncHandler, __pyx_k_pyx_unpickle_AsyncHandler, sizeof(__pyx_k_pyx_unpickle_AsyncHandler), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Communicator, __pyx_k_pyx_unpickle_Communicator, sizeof(__pyx_k_pyx_unpickle_Communicator), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Connection, __pyx_k_pyx_unpickle_Connection, sizeof(__pyx_k_pyx_unpickle_Connection), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Dispatcher, __pyx_k_pyx_unpickle_Dispatcher, sizeof(__pyx_k_pyx_unpickle_Dispatcher), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_LocalActorPool, __pyx_k_pyx_unpickle_LocalActorPool, sizeof(__pyx_k_pyx_unpickle_LocalActorPool), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_MessageContext, __pyx_k_pyx_unpickle_MessageContext, sizeof(__pyx_k_pyx_unpickle_MessageContext), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_ThreadPool, __pyx_k_pyx_unpickle_ThreadPool, sizeof(__pyx_k_pyx_unpickle_ThreadPool), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  {&__pyx_n_s_queue, __pyx_k_queue, sizeof(__pyx_k_queue), 0, 0, 1, 1},
  {&__pyx_n_s_randint, __pyx_k_randint, sizeof(__pyx_k_randint), 0, 0, 1, 1},
  {&__pyx_n_s_random, __pyx_k_random, sizeof(__pyx_k_random), 0, 0, 1, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_rb, __pyx_k_rb, sizeof(__pyx_k_rb), 0, 0, 1, 1},
  {&__pyx_n_s_receive, __pyx_k_receive, sizeof(__pyx_k_receive), 0, 0, 1, 1},
  {&__pyx_n_s_recv, __pyx_k_recv, sizeof(__pyx_k_recv), 0, 0, 1, 1},
  {&__pyx_n_s_redirect_func, __pyx_k_redirect_func, sizeof(__pyx_k_redirect_func), 0, 0, 1, 1},
  {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  {&__pyx_n_s_ref, __pyx_k_ref, sizeof(__pyx_k_ref), 0, 0, 1, 1},
  {&__pyx_n_s_release, __pyx_k_release, sizeof(__pyx_k_release), 0, 0, 1, 1},
  {&__pyx_n_s_remote_func, __pyx_k_remote_func, sizeof(__pyx_k_remote_func), 0, 0, 1, 1},
  {&__pyx_n_s_replace_pipe, __pyx_k_replace_pipe, sizeof(__pyx_k_replace_pipe), 0, 0, 1, 1},
  {&__pyx_n_s_reraise, __pyx_k_reraise, sizeof(__pyx_k_reraise), 0, 0, 1, 1},
  {&__pyx_n_s_restart_process, __pyx_k_restart_process, sizeof(__pyx_k_restart_process), 0, 0, 1, 1},
  {&__pyx_n_s_result, __pyx_k_result, sizeof(__pyx_k_result), 0, 0, 1, 1},
  {&__pyx_n_s_ret, __pyx_k_ret, sizeof(__pyx_k_ret), 0, 0, 1, 1},
  {&__pyx_n_s_run, __pyx_k_run, sizeof(__pyx_k_run), 0, 0, 1, 1},
  {&__pyx_n_s_run_locals_close, __pyx_k_run_locals_close, sizeof(__pyx_k_run_locals_close), 0, 0, 1, 1},
  {&__pyx_n_s_run_locals_genexpr, __pyx_k_run_locals_genexpr, sizeof(__pyx_k_run_locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_run_locals_stop_func, __pyx_k_run_locals_stop_func, sizeof(__pyx_k_run_locals_stop_func), 0, 0, 1, 1},
  {&__pyx_n_s_seconds, __pyx_k_seconds, sizeof(__pyx_k_seconds), 0, 0, 1, 1},
  {&__pyx_n_s_seed, __pyx_k_seed, sizeof(__pyx_k_seed), 0, 0, 1, 1},
  {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  {&__pyx_n_s_send_2, __pyx_k_send_2, sizeof(__pyx_k_send_2), 0, 0, 1, 1},
  {&__pyx_n_s_send_local, __pyx_k_send_local, sizeof(__pyx_k_send_local), 0, 0, 1, 1},
  {&__pyx_n_s_send_local_locals_on_failure, __pyx_k_send_local_locals_on_failure, sizeof(__pyx_k_send_local_locals_on_failure), 0, 0, 1, 1},
  {&__pyx_n_s_send_local_locals_on_success, __pyx_k_send_local_locals_on_success, sizeof(__pyx_k_send_local_locals_on_success), 0, 0, 1, 1},
  {&__pyx_n_s_send_locals_check, __pyx_k_send_locals_check, sizeof(__pyx_k_send_locals_check), 0, 0, 1, 1},
  {&__pyx_n_s_send_process, __pyx_k_send_process, sizeof(__pyx_k_send_process), 0, 0, 1, 1},
  {&__pyx_n_s_send_process_locals_check, __pyx_k_send_process_locals_check, sizeof(__pyx_k_send_process_locals_check), 0, 0, 1, 1},
  {&__pyx_n_s_send_remote, __pyx_k_send_remote, sizeof(__pyx_k_send_remote), 0, 0, 1, 1},
  {&__pyx_n_s_sendall, __pyx_k_sendall, sizeof(__pyx_k_sendall), 0, 0, 1, 1},
  {&__pyx_n_s_sender, __pyx_k_sender, sizeof(__pyx_k_sender), 0, 0, 1, 1},
  {&__pyx_n_s_server, __pyx_k_server, sizeof(__pyx_k_server), 0, 0, 1, 1},
  {&__pyx_n_s_set, __pyx_k_set, sizeof(__pyx_k_set), 0, 0, 1, 1},
  {&__pyx_n_s_set_comm, __pyx_k_set_comm, sizeof(__pyx_k_set_comm), 0, 0, 1, 1},
  {&__pyx_n_s_set_exception, __pyx_k_set_exception, sizeof(__pyx_k_set_exception), 0, 0, 1, 1},
  {&__pyx_n_s_set_result, __pyx_k_set_result, sizeof(__pyx_k_set_result), 0, 0, 1, 1},
  {&__pyx_n_s_set_server, __pyx_k_set_server, sizeof(__pyx_k_set_server), 0, 0, 1, 1},
  {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_six, __pyx_k_six, sizeof(__pyx_k_six), 0, 0, 1, 1},
  {&__pyx_n_s_sleep, __pyx_k_sleep, sizeof(__pyx_k_sleep), 0, 0, 1, 1},
  {&__pyx_n_s_sock, __pyx_k_sock, sizeof(__pyx_k_sock), 0, 0, 1, 1},
  {&__pyx_n_s_socket, __pyx_k_socket, sizeof(__pyx_k_socket), 0, 0, 1, 1},
  {&__pyx_n_s_socks, __pyx_k_socks, sizeof(__pyx_k_socks), 0, 0, 1, 1},
  {&__pyx_n_s_spawn, __pyx_k_spawn, sizeof(__pyx_k_spawn), 0, 0, 1, 1},
  {&__pyx_n_s_spawn_later, __pyx_k_spawn_later, sizeof(__pyx_k_spawn_later), 0, 0, 1, 1},
  {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
  {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
  {&__pyx_n_s_start_local_pool, __pyx_k_start_local_pool, sizeof(__pyx_k_start_local_pool), 0, 0, 1, 1},
  {&__pyx_n_s_start_process, __pyx_k_start_process, sizeof(__pyx_k_start_process), 0, 0, 1, 1},
  {&__pyx_n_s_start_process_2, __pyx_k_start_process_2, sizeof(__pyx_k_start_process_2), 0, 0, 1, 1},
  {&__pyx_n_s_staticmethod, __pyx_k_staticmethod, sizeof(__pyx_k_staticmethod), 0, 0, 1, 1},
  {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
  {&__pyx_n_s_stop_func, __pyx_k_stop_func, sizeof(__pyx_k_stop_func), 0, 0, 1, 1},
  {&__pyx_n_s_string_types, __pyx_k_string_types, sizeof(__pyx_k_string_types), 0, 0, 1, 1},
  {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
  {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1},
  {&__pyx_n_s_submit, __pyx_k_submit, sizeof(__pyx_k_submit), 0, 0, 1, 1},
  {&__pyx_n_s_subprocess, __pyx_k_subprocess, sizeof(__pyx_k_subprocess), 0, 0, 1, 1},
  {&__pyx_n_s_successful, __pyx_k_successful, sizeof(__pyx_k_successful), 0, 0, 1, 1},
  {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1},
  {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
  {&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1},
  {&__pyx_n_s_tb, __pyx_k_tb, sizeof(__pyx_k_tb), 0, 0, 1, 1},
  {&__pyx_n_s_tell, __pyx_k_tell, sizeof(__pyx_k_tell), 0, 0, 1, 1},
  {&__pyx_n_s_terminate, __pyx_k_terminate, sizeof(__pyx_k_terminate), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_threadpool, __pyx_k_threadpool, sizeof(__pyx_k_threadpool), 0, 0, 1, 1},
  {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  {&__pyx_n_s_timeout, __pyx_k_timeout, sizeof(__pyx_k_timeout), 0, 0, 1, 1},
  {&__pyx_n_s_to_index, __pyx_k_to_index, sizeof(__pyx_k_to_index), 0, 0, 1, 1},
  {&__pyx_n_s_traceback, __pyx_k_traceback, sizeof(__pyx_k_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_uid, __pyx_k_uid, sizeof(__pyx_k_uid), 0, 0, 1, 1},
  {&__pyx_n_s_unique_id, __pyx_k_unique_id, sizeof(__pyx_k_unique_id), 0, 0, 1, 1},
  {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0},
  {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
  {&__pyx_n_s_utils, __pyx_k_utils, sizeof(__pyx_k_utils), 0, 0, 1, 1},
  {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
  {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1},
  {&__pyx_n_s_wait, __pyx_k_wait, sizeof(__pyx_k_wait), 0, 0, 1, 1},
  {&__pyx_n_s_wait_response, __pyx_k_wait_response, sizeof(__pyx_k_wait_response), 0, 0, 1, 1},
  {&__pyx_n_s_weakref, __pyx_k_weakref, sizeof(__pyx_k_weakref), 0, 0, 1, 1},
  {&__pyx_n_s_write_remote_message, __pyx_k_write_remote_message, sizeof(__pyx_k_write_remote_message), 0, 0, 1, 1},
  {&__pyx_n_s_zip, __pyx_k_zip, sizeof(__pyx_k_zip), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_staticmethod = __Pyx_GetBuiltinName(__pyx_n_s_staticmethod); if (!__pyx_builtin_staticmethod) __PYX_ERR(0, 186, __pyx_L1_error)
  __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 334, __pyx_L1_error)
  __pyx_builtin_property = __Pyx_GetBuiltinName(__pyx_n_s_property); if (!__pyx_builtin_property) __PYX_ERR(0, 350, __pyx_L1_error)
  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 229, __pyx_L1_error)
  __pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 475, __pyx_L1_error)
  __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 612, __pyx_L1_error)
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 651, __pyx_L1_error)
  __pyx_builtin_EOFError = __Pyx_GetBuiltinName(__pyx_n_s_EOFError); if (!__pyx_builtin_EOFError) __PYX_ERR(0, 1320, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 1432, __pyx_L1_error)
  __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) __PYX_ERR(0, 1555, __pyx_L1_error)
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 1562, __pyx_L1_error)
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(2, 856, __pyx_L1_error)
  __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(2, 1038, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "mars/actors/pool/gevent_pool.pyx":91
 *         cdef MessageContext message_ctx
 * 
 *         with self.lock:             # <<<<<<<<<<<<<<
 *             message_ctx = self.inbox.get()
 *             actor = self.actor()
 */
  __pyx_tuple_ = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 91, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "mars/actors/pool/gevent_pool.pyx":158
 *             return ref
 * 
 *         def callback(ret):             # <<<<<<<<<<<<<<
 *             ret.ctx = self
 * 
 */
  __pyx_tuple__2 = PyTuple_Pack(1, __pyx_n_s_ret); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);
  __pyx_codeobj__3 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__2, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_callback, 158, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(0, 158, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":340
 *     def __init__(self, address):
 *         if isinstance(address, six.string_types):
 *             self.address = address.split(':', 1)             # <<<<<<<<<<<<<<
 *         else:
 *             self.address = address
 */
  __pyx_tuple__5 = PyTuple_Pack(2, __pyx_kp_s__4, __pyx_int_1); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);

  /* "mars/actors/pool/gevent_pool.pyx":384
 *                 return self._connect(conn, lock)
 * 
 *             def close(c, lk):             # <<<<<<<<<<<<<<
 *                 with lk:
 *                     c.close()
 */
  __pyx_tuple__6 = PyTuple_Pack(2, __pyx_n_s_c, __pyx_n_s_lk); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);
  __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_close, 384, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 384, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":474
 *             binaries = pack_create_actor_message(
 *                 ActorRemoteHelper.index, UNKNOWN_TO_INDEX,
 *                 ActorRef(address, uid), actor_cls, args, kwargs)[1:]             # <<<<<<<<<<<<<<
 *         except (AttributeError, pickle.PickleError):
 *             raise pickle.PicklingError('Unable to pickle {0}(*{1}, **{2})'.format(actor_cls, args, kwargs))
 */
  __pyx_slice__8 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__8)) __PYX_ERR(0, 474, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__8);
  __Pyx_GIVEREF(__pyx_slice__8);

  /* "mars/actors/pool/gevent_pool.pyx":486
 *         future = gevent.event.AsyncResult()
 * 
 *         def on_success(g):             # <<<<<<<<<<<<<<
 *             actor_ref = g.value
 *             actor_ref.ctx = ActorContext(self)
 */
  __pyx_tuple__9 = PyTuple_Pack(2, __pyx_n_s_g, __pyx_n_s_actor_ref); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 486, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);
  __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_on_success, 486, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 486, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":493
 *             future.set_result(actor_ref)
 * 
 *         def on_failure(g):             # <<<<<<<<<<<<<<
 *             try:
 *                 g.get()
 */
  __pyx_tuple__11 = PyTuple_Pack(4, __pyx_n_s_g, __pyx_n_s_t, __pyx_n_s_ex, __pyx_n_s_tb); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__11);
  __Pyx_GIVEREF(__pyx_tuple__11);
  __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_on_failure, 493, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 493, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":511
 *         future = gevent.event.AsyncResult()
 * 
 *         def on_success(g):             # <<<<<<<<<<<<<<
 *             ret = g.value
 *             if callback:
 */
  __pyx_tuple__13 = PyTuple_Pack(2, __pyx_n_s_g, __pyx_n_s_ret); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 511, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__13);
  __Pyx_GIVEREF(__pyx_tuple__13);
  __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_on_success, 511, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 511, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":517
 *             future.set_result(ret)
 * 
 *         def on_failure(g):             # <<<<<<<<<<<<<<
 *             try:
 *                 g.get()
 */
  __pyx_tuple__15 = PyTuple_Pack(4, __pyx_n_s_g, __pyx_n_s_t, __pyx_n_s_ex, __pyx_n_s_tb); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);
  __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_on_failure, 517, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 517, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":651
 *         else:
 *             if self.cluster_info.standalone:
 *                 raise ValueError('Not allow to send message to remote in standalone mode')             # <<<<<<<<<<<<<<
 * 
 *             return remote_func(*args, **kwargs)
 */
  __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_Not_allow_to_send_message_to_rem); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 651, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "mars/actors/pool/gevent_pool.pyx":679
 *         if wait_response:
 *             # send, not wait
 *             def on_success(g):             # <<<<<<<<<<<<<<
 *                 ret = g.value
 *                 if callback:
 */
  __pyx_tuple__18 = PyTuple_Pack(2, __pyx_n_s_g, __pyx_n_s_ret); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 679, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);
  __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_on_success, 679, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 679, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":685
 *                 future.set_result(ret)
 * 
 *             def on_failure(g):             # <<<<<<<<<<<<<<
 *                 try:
 *                     g.get()
 */
  __pyx_tuple__20 = PyTuple_Pack(4, __pyx_n_s_g, __pyx_n_s_t, __pyx_n_s_ex, __pyx_n_s_tb); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 685, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);
  __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_on_failure, 685, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 685, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":723
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipe.put(*message)
 *             self.future(message_id, future, callback=callback)
 */
  __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_check, 723, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 723, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":761
 *         cdef object res
 * 
 *         wait = kwargs.pop('wait', True)             # <<<<<<<<<<<<<<
 *         callback = kwargs.pop('callback', None)
 * 
 */
  __pyx_tuple__23 = PyTuple_Pack(2, __pyx_n_s_wait, Py_True); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 761, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);

  /* "mars/actors/pool/gevent_pool.pyx":762
 * 
 *         wait = kwargs.pop('wait', True)
 *         callback = kwargs.pop('callback', None)             # <<<<<<<<<<<<<<
 * 
 *         if wait:
 */
  __pyx_tuple__24 = PyTuple_Pack(2, __pyx_n_s_callback, Py_None); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);

  /* "mars/actors/pool/gevent_pool.pyx":803
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             self.future(message_id, future, callback=callback)
 */
  __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_check, 803, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 803, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":860
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             self.future(message_id, future, callback=callback)
 */
  __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_check, 860, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 860, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":902
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipe.put(message)
 *             self.future(message_id, future, callback=callback)
 */
  __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_check, 902, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 902, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1133
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(*messages)
 *             self.future(message_id, future, callback=callback)
 */
  __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_check, 1133, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 1133, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1187
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             self.future(message_id, future, callback=callback)
 */
  __pyx_codeobj__29 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_check, 1187, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 1187, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1215
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             self.future(message_id, future, callback=callback)
 */
  __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_check, 1215, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 1215, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1243
 *         future = gevent.event.AsyncResult()
 * 
 *         def check():             # <<<<<<<<<<<<<<
 *             self.pipes[to_index].put(message)
 *             self.future(message_id, future, callback=callback)
 */
  __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_check, 1243, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 1243, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1399
 *     address, port = cluster_info.location, cluster_info.port
 *     if address is None or port is None:
 *         raise ValueError('Both address and port should be provided')             # <<<<<<<<<<<<<<
 *     multi_process = cluster_info.n_process > 1
 * 
 */
  __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_Both_address_and_port_should_be); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 1399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);

  /* "mars/actors/pool/gevent_pool.pyx":1500
 *             return actor_ref
 * 
 *         def callback(ref):             # <<<<<<<<<<<<<<
 *             if address is not None:
 *                 ref.address = address
 */
  __pyx_tuple__33 = PyTuple_Pack(1, __pyx_n_s_ref); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 1500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);
  __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_callback, 1500, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 1500, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1532
 * 
 *     cpdef tuple _start_process(self, idx):
 *         comm_pipe, pool_pipe = gipc.pipe(True, encoder=_inaction_encoder, decoder=_inaction_decoder)             # <<<<<<<<<<<<<<
 *         p = gipc.start_process(start_local_pool,
 *                                args=(idx, self.cluster_info, comm_pipe, self.distributor),
 */
  __pyx_tuple__35 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 1532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);

  /* "mars/actors/pool/gevent_pool.pyx":1559
 *             )]
 * 
 *             def stop_func():             # <<<<<<<<<<<<<<
 *                 for process in self._processes:
 *                     process.terminate()
 */
  __pyx_tuple__36 = PyTuple_Pack(3, __pyx_n_s_process, __pyx_n_s_idx, __pyx_n_s_p); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 1559, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);
  __pyx_codeobj__37 = (PyObject*)__Pyx_PyCode_New(0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_stop_func, 1559, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) __PYX_ERR(0, 1559, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1580
 *             self._server = start_actor_server(self.cluster_info, self._dispatcher)
 * 
 *             def close():             # <<<<<<<<<<<<<<
 *                 self._server.stop()
 * 
 */
  __pyx_codeobj__38 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_close, 1580, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__38)) __PYX_ERR(0, 1580, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1620
 * 
 *         if 'address' not in kwargs or kwargs.get('address') is None:
 *             raise ValueError('address must be provided')             # <<<<<<<<<<<<<<
 *         address = kwargs.pop('address')
 *         uid = kwargs.pop('uid', new_actor_id())
 */
  __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_s_address_must_be_provided); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 1620, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":272
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 */
  __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(2, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":276
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")             # <<<<<<<<<<<<<<
 * 
 *             info.buf = PyArray_DATA(self)
 */
  __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(2, 276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":306
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 */
  __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(2, 306, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":856
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
 * 
 *         if ((child.byteorder == c'>' and little_endian) or
 */
  __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(2, 856, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":880
 *             t = child.type_num
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 */
  __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(2, 880, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__44);
  __Pyx_GIVEREF(__pyx_tuple__44);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1038
 *         _import_array()
 *     except Exception:
 *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
 * 
 * cdef inline int import_umath() except -1:
 */
  __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(2, 1038, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_GIVEREF(__pyx_tuple__45);

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1044
 *         _import_umath()
 *     except Exception:
 *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
 * 
 * cdef inline int import_ufunc() except -1:
 */
  __pyx_tuple__46 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(2, 1044, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__46);
  __Pyx_GIVEREF(__pyx_tuple__46);

  /* "mars/actors/pool/gevent_pool.pyx":187
 * 
 *     @staticmethod
 *     def sleep(seconds):             # <<<<<<<<<<<<<<
 *         gevent.sleep(seconds)
 * 
 */
  __pyx_tuple__47 = PyTuple_Pack(1, __pyx_n_s_seconds); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);
  __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_sleep, 187, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) __PYX_ERR(0, 187, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":191
 * 
 *     @staticmethod
 *     def fileobject(fobj, mode='rb', bufsize=-1, close=True):             # <<<<<<<<<<<<<<
 *         return gevent.fileobject.FileObject(fobj, mode=mode, bufsize=bufsize, close=close)
 * 
 */
  __pyx_tuple__49 = PyTuple_Pack(4, __pyx_n_s_fobj, __pyx_n_s_mode, __pyx_n_s_bufsize, __pyx_n_s_close); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);
  __pyx_codeobj__50 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_fileobject, 191, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__50)) __PYX_ERR(0, 191, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":195
 * 
 *     @staticmethod
 *     def popen(*args, **kwargs):             # <<<<<<<<<<<<<<
 *         return gevent.subprocess.Popen(*args, **kwargs)
 * 
 */
  __pyx_tuple__51 = PyTuple_Pack(2, __pyx_n_s_args, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(0, 195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__51);
  __Pyx_GIVEREF(__pyx_tuple__51);
  __pyx_codeobj__52 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__51, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_popen, 195, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__52)) __PYX_ERR(0, 195, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":199
 * 
 *     @staticmethod
 *     def threadpool(num_threads):             # <<<<<<<<<<<<<<
 *         return ThreadPool(num_threads)
 * 
 */
  __pyx_tuple__53 = PyTuple_Pack(1, __pyx_n_s_num_threads); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__53);
  __Pyx_GIVEREF(__pyx_tuple__53);
  __pyx_codeobj__54 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__53, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_threadpool, 199, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__54)) __PYX_ERR(0, 199, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":334
 * 
 * 
 * class Connections(object):             # <<<<<<<<<<<<<<
 *     global_lock = gevent.lock.Semaphore()
 *     addrs = 0
 */
  __pyx_tuple__55 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__55);
  __Pyx_GIVEREF(__pyx_tuple__55);

  /* "mars/actors/pool/gevent_pool.pyx":338
 *     addrs = 0
 * 
 *     def __init__(self, address):             # <<<<<<<<<<<<<<
 *         if isinstance(address, six.string_types):
 *             self.address = address.split(':', 1)
 */
  __pyx_tuple__56 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_address); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__56);
  __Pyx_GIVEREF(__pyx_tuple__56);
  __pyx_codeobj__57 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__56, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_init, 338, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__57)) __PYX_ERR(0, 338, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":351
 * 
 *     @property
 *     def conn(self):             # <<<<<<<<<<<<<<
 *         return [conn_lock[0] for conn_lock in six.itervalues(self.conn_locks)]
 * 
 */
  __pyx_tuple__58 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_conn_lock); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(0, 351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__58);
  __Pyx_GIVEREF(__pyx_tuple__58);
  __pyx_codeobj__59 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__58, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_conn, 351, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__59)) __PYX_ERR(0, 351, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":354
 *         return [conn_lock[0] for conn_lock in six.itervalues(self.conn_locks)]
 * 
 *     def _connect(self, conn, lock):             # <<<<<<<<<<<<<<
 *         return Connection(conn, lock)
 * 
 */
  __pyx_tuple__60 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_conn, __pyx_n_s_lock); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(0, 354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__60);
  __Pyx_GIVEREF(__pyx_tuple__60);
  __pyx_codeobj__61 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__60, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_connect, 354, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__61)) __PYX_ERR(0, 354, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":357
 *         return Connection(conn, lock)
 * 
 *     def got_broken_pipe(self, fd):             # <<<<<<<<<<<<<<
 *         del self.conn_locks[fd]
 * 
 */
  __pyx_tuple__62 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_fd); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(0, 357, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__62);
  __Pyx_GIVEREF(__pyx_tuple__62);
  __pyx_codeobj__63 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__62, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_got_broken_pipe, 357, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__63)) __PYX_ERR(0, 357, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":360
 *         del self.conn_locks[fd]
 * 
 *     def connect(self):             # <<<<<<<<<<<<<<
 *         cdef int maxlen
 *         cdef object conn
 */
  __pyx_tuple__64 = PyTuple_Pack(12, __pyx_n_s_self, __pyx_n_s_maxlen, __pyx_n_s_conn, __pyx_n_s_lock, __pyx_n_s_locked, __pyx_n_s_close, __pyx_n_s_close, __pyx_n_s_ps, __pyx_n_s_i, __pyx_n_s_fd, __pyx_n_s_c, __pyx_n_s_l); if (unlikely(!__pyx_tuple__64)) __PYX_ERR(0, 360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__64);
  __Pyx_GIVEREF(__pyx_tuple__64);
  __pyx_codeobj__65 = (PyObject*)__Pyx_PyCode_New(1, 0, 12, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__64, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_connect_2, 360, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__65)) __PYX_ERR(0, 360, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":402
 *             return self._connect(conn, lock)
 * 
 *     def __del__(self):             # <<<<<<<<<<<<<<
 *         for c, _ in self.conn_locks.values():
 *             try:
 */
  __pyx_tuple__67 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_c, __pyx_n_s__66); if (unlikely(!__pyx_tuple__67)) __PYX_ERR(0, 402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__67);
  __Pyx_GIVEREF(__pyx_tuple__67);
  __pyx_codeobj__68 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__67, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_del, 402, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__68)) __PYX_ERR(0, 402, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1378
 * 
 * class ActorStreamServer(gevent.server.StreamServer):
 *     def __init__(self, listener, handler):             # <<<<<<<<<<<<<<
 *         super(ActorStreamServer, self).__init__(listener, handler)
 *         self._socks = []
 */
  __pyx_tuple__69 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_listener, __pyx_n_s_handler); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(0, 1378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__69);
  __Pyx_GIVEREF(__pyx_tuple__69);
  __pyx_codeobj__70 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__69, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_init, 1378, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__70)) __PYX_ERR(0, 1378, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1383
 *         handler.set_server(self)
 * 
 *     def add_sock(self, sock):             # <<<<<<<<<<<<<<
 *         self._socks.append(sock)
 * 
 */
  __pyx_tuple__71 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_sock); if (unlikely(!__pyx_tuple__71)) __PYX_ERR(0, 1383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__71);
  __Pyx_GIVEREF(__pyx_tuple__71);
  __pyx_codeobj__72 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__71, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_add_sock, 1383, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__72)) __PYX_ERR(0, 1383, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1386
 *         self._socks.append(sock)
 * 
 *     def close(self):             # <<<<<<<<<<<<<<
 *         super(ActorStreamServer, self).close()
 *         [sock.close() for sock in self._socks]
 */
  __pyx_tuple__73 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_sock); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(0, 1386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__73);
  __Pyx_GIVEREF(__pyx_tuple__73);
  __pyx_codeobj__74 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__73, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_close, 1386, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__74)) __PYX_ERR(0, 1386, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1407
 * 
 * 
 * def start_local_pool(int index, ClusterInfo cluster_info,             # <<<<<<<<<<<<<<
 *                      object pipe=None, Distributor distributor=None,
 *                      object parallel=None, bint join=False):
 */
  __pyx_tuple__75 = PyTuple_Pack(10, __pyx_n_s_index, __pyx_n_s_cluster_info, __pyx_n_s_pipe, __pyx_n_s_distributor, __pyx_n_s_parallel, __pyx_n_s_join, __pyx_n_s_np, __pyx_n_s_local_pool, __pyx_n_s_comm, __pyx_n_s_p); if (unlikely(!__pyx_tuple__75)) __PYX_ERR(0, 1407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__75);
  __Pyx_GIVEREF(__pyx_tuple__75);
  __pyx_codeobj__76 = (PyObject*)__Pyx_PyCode_New(6, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__75, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_start_local_pool, 1407, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__76)) __PYX_ERR(0, 1407, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1429
 * 
 * 
 * def close_pipe(p):             # <<<<<<<<<<<<<<
 *     if p is None:
 *         return
 */
  __pyx_tuple__77 = PyTuple_Pack(2, __pyx_n_s_p, __pyx_n_s__66); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(0, 1429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__77);
  __Pyx_GIVEREF(__pyx_tuple__77);
  __pyx_codeobj__78 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__77, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_close_pipe, 1429, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__78)) __PYX_ERR(0, 1429, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1588
 * 
 *     @staticmethod
 *     def sleep(seconds):             # <<<<<<<<<<<<<<
 *         gevent.sleep(seconds)
 * 
 */
  __pyx_tuple__79 = PyTuple_Pack(1, __pyx_n_s_seconds); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(0, 1588, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__79);
  __Pyx_GIVEREF(__pyx_tuple__79);
  __pyx_codeobj__80 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__79, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_sleep, 1588, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__80)) __PYX_ERR(0, 1588, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1640
 * 
 *     @staticmethod
 *     def sleep(seconds):             # <<<<<<<<<<<<<<
 *         gevent.sleep(seconds)
 * 
 */
  __pyx_tuple__81 = PyTuple_Pack(1, __pyx_n_s_seconds); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(0, 1640, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__81);
  __Pyx_GIVEREF(__pyx_tuple__81);
  __pyx_codeobj__82 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__81, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_sleep, 1640, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__82)) __PYX_ERR(0, 1640, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":1644
 * 
 *     @staticmethod
 *     def threadpool(num_threads):             # <<<<<<<<<<<<<<
 *         return ThreadPool(num_threads)
 */
  __pyx_tuple__83 = PyTuple_Pack(1, __pyx_n_s_num_threads); if (unlikely(!__pyx_tuple__83)) __PYX_ERR(0, 1644, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__83);
  __Pyx_GIVEREF(__pyx_tuple__83);
  __pyx_codeobj__84 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__83, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mars_actors_pool_gevent_pool_pyx, __pyx_n_s_threadpool, 1644, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__84)) __PYX_ERR(0, 1644, __pyx_L1_error)

  /* "(tree fragment)":1
 * def __pyx_unpickle_MessageContext(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_tuple__85 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__85)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__85);
  __Pyx_GIVEREF(__pyx_tuple__85);
  __pyx_codeobj__86 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__85, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_MessageContext, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__86)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__87 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__87);
  __Pyx_GIVEREF(__pyx_tuple__87);
  __pyx_codeobj__88 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__87, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_ActorExecutionCon, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__88)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__89 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__89);
  __Pyx_GIVEREF(__pyx_tuple__89);
  __pyx_codeobj__90 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__89, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_ThreadPool, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__90)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__91 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__91)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__91);
  __Pyx_GIVEREF(__pyx_tuple__91);
  __pyx_codeobj__92 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__91, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_ActorContext, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__92)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__93 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__93)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__93);
  __Pyx_GIVEREF(__pyx_tuple__93);
  __pyx_codeobj__94 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__93, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_LocalActorPool, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__94)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__95 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__95)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__95);
  __Pyx_GIVEREF(__pyx_tuple__95);
  __pyx_codeobj__96 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__95, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_AsyncHandler, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__96)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__97 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__97)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__97);
  __Pyx_GIVEREF(__pyx_tuple__97);
  __pyx_codeobj__98 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__97, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Connection, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__98)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__99 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__99)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__99);
  __Pyx_GIVEREF(__pyx_tuple__99);
  __pyx_codeobj__100 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__99, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_ActorRemoteHelper, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__100)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__101 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__101)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__101);
  __Pyx_GIVEREF(__pyx_tuple__101);
  __pyx_codeobj__102 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__101, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Communicator, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__102)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__103 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__103)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__103);
  __Pyx_GIVEREF(__pyx_tuple__103);
  __pyx_codeobj__104 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__103, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Dispatcher, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__104)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__105 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__105)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__105);
  __Pyx_GIVEREF(__pyx_tuple__105);
  __pyx_codeobj__106 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__105, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_ActorServerHandle, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__106)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__107 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__107)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__107);
  __Pyx_GIVEREF(__pyx_tuple__107);
  __pyx_codeobj__108 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__107, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_ActorPool, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__108)) __PYX_ERR(1, 1, __pyx_L1_error)
  __pyx_tuple__109 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__109)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__109);
  __Pyx_GIVEREF(__pyx_tuple__109);
  __pyx_codeobj__110 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__109, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_ActorClient, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__110)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  __pyx_umethod_PyDict_Type_get.type = (PyObject*)&PyDict_Type;
  __pyx_umethod_PyDict_Type_pop.type = (PyObject*)&PyDict_Type;
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_float_0_05 = PyFloat_FromDouble(0.05); if (unlikely(!__pyx_float_0_05)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_6419405 = PyInt_FromLong(6419405L); if (unlikely(!__pyx_int_6419405)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_23256143 = PyInt_FromLong(23256143L); if (unlikely(!__pyx_int_23256143)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_45447796 = PyInt_FromLong(45447796L); if (unlikely(!__pyx_int_45447796)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_48718332 = PyInt_FromLong(48718332L); if (unlikely(!__pyx_int_48718332)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_58204060 = PyInt_FromLong(58204060L); if (unlikely(!__pyx_int_58204060)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_67544450 = PyInt_FromLong(67544450L); if (unlikely(!__pyx_int_67544450)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_153165912 = PyInt_FromLong(153165912L); if (unlikely(!__pyx_int_153165912)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_174956831 = PyInt_FromLong(174956831L); if (unlikely(!__pyx_int_174956831)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_185272064 = PyInt_FromLong(185272064L); if (unlikely(!__pyx_int_185272064)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_213755342 = PyInt_FromLong(213755342L); if (unlikely(!__pyx_int_213755342)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_221979240 = PyInt_FromLong(221979240L); if (unlikely(!__pyx_int_221979240)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_244608269 = PyInt_FromLong(244608269L); if (unlikely(!__pyx_int_244608269)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_259339352 = PyInt_FromLong(259339352L); if (unlikely(!__pyx_int_259339352)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/

static int __Pyx_modinit_global_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  /*--- Global init code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  /*--- Variable export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  /*--- Function export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_type_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  /*--- Type init code ---*/
  __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_MessageContext = &__pyx_vtable_4mars_6actors_4pool_11gevent_pool_MessageContext;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_MessageContext.result = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_14MessageContext_result;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool_MessageContext) < 0) __PYX_ERR(0, 64, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool_MessageContext.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool_MessageContext.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool_MessageContext.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool_MessageContext.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_4mars_6actors_4pool_11gevent_pool_MessageContext.tp_dict, __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_MessageContext) < 0) __PYX_ERR(0, 64, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_MessageContext, (PyObject *)&__pyx_type_4mars_6actors_4pool_11gevent_pool_MessageContext) < 0) __PYX_ERR(0, 64, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4mars_6actors_4pool_11gevent_pool_MessageContext) < 0) __PYX_ERR(0, 64, __pyx_L1_error)
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool_MessageContext = &__pyx_type_4mars_6actors_4pool_11gevent_pool_MessageContext;
  __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext = &__pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext.fire_run = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_fire_run;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext.receive = (void (*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *, struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_MessageContext *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_21ActorExecutionContext_receive;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext) < 0) __PYX_ERR(0, 76, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext.tp_dict, __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext) < 0) __PYX_ERR(0, 76, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_ActorExecutionContext, (PyObject *)&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext) < 0) __PYX_ERR(0, 76, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext) < 0) __PYX_ERR(0, 76, __pyx_L1_error)
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext = &__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool_ThreadPool) < 0) __PYX_ERR(0, 108, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool_ThreadPool.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool_ThreadPool.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool_ThreadPool.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool_ThreadPool.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_ThreadPool, (PyObject *)&__pyx_type_4mars_6actors_4pool_11gevent_pool_ThreadPool) < 0) __PYX_ERR(0, 108, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4mars_6actors_4pool_11gevent_pool_ThreadPool) < 0) __PYX_ERR(0, 108, __pyx_L1_error)
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool_ThreadPool = &__pyx_type_4mars_6actors_4pool_11gevent_pool_ThreadPool;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorContext) < 0) __PYX_ERR(0, 118, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorContext.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorContext.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorContext.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorContext.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_ActorContext, (PyObject *)&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorContext) < 0) __PYX_ERR(0, 118, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorContext) < 0) __PYX_ERR(0, 118, __pyx_L1_error)
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext = &__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorContext;
  __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_LocalActorPool = &__pyx_vtable_4mars_6actors_4pool_11gevent_pool_LocalActorPool;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_LocalActorPool.set_comm = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_set_comm;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_LocalActorPool.get_actor_execution_ctx = (struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorExecutionContext *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_get_actor_execution_ctx;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_LocalActorPool.has_actor = (int (*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_has_actor;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_LocalActorPool.destroy_actor = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_LocalActorPool *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_14LocalActorPool_destroy_actor;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool_LocalActorPool) < 0) __PYX_ERR(0, 203, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool_LocalActorPool.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool_LocalActorPool.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool_LocalActorPool.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool_LocalActorPool.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_4mars_6actors_4pool_11gevent_pool_LocalActorPool.tp_dict, __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_LocalActorPool) < 0) __PYX_ERR(0, 203, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_LocalActorPool, (PyObject *)&__pyx_type_4mars_6actors_4pool_11gevent_pool_LocalActorPool) < 0) __PYX_ERR(0, 203, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4mars_6actors_4pool_11gevent_pool_LocalActorPool) < 0) __PYX_ERR(0, 203, __pyx_L1_error)
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool_LocalActorPool = &__pyx_type_4mars_6actors_4pool_11gevent_pool_LocalActorPool;
  __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_AsyncHandler = &__pyx_vtable_4mars_6actors_4pool_11gevent_pool_AsyncHandler;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_AsyncHandler.submit = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_submit;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_AsyncHandler.future = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_future;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_AsyncHandler.wait = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_wait;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_AsyncHandler.got = (void (*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_got;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_AsyncHandler.err = (void (*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_AsyncHandler *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_12AsyncHandler_err;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool_AsyncHandler) < 0) __PYX_ERR(0, 263, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool_AsyncHandler.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool_AsyncHandler.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool_AsyncHandler.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool_AsyncHandler.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_4mars_6actors_4pool_11gevent_pool_AsyncHandler.tp_dict, __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_AsyncHandler) < 0) __PYX_ERR(0, 263, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_AsyncHandler, (PyObject *)&__pyx_type_4mars_6actors_4pool_11gevent_pool_AsyncHandler) < 0) __PYX_ERR(0, 263, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4mars_6actors_4pool_11gevent_pool_AsyncHandler) < 0) __PYX_ERR(0, 263, __pyx_L1_error)
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool_AsyncHandler = &__pyx_type_4mars_6actors_4pool_11gevent_pool_AsyncHandler;
  __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Connection = &__pyx_vtable_4mars_6actors_4pool_11gevent_pool_Connection;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Connection.release = (void (*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Connection *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_10Connection_release;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool_Connection) < 0) __PYX_ERR(0, 316, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool_Connection.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool_Connection.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool_Connection.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool_Connection.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_4mars_6actors_4pool_11gevent_pool_Connection.tp_dict, __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Connection) < 0) __PYX_ERR(0, 316, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Connection, (PyObject *)&__pyx_type_4mars_6actors_4pool_11gevent_pool_Connection) < 0) __PYX_ERR(0, 316, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4mars_6actors_4pool_11gevent_pool_Connection) < 0) __PYX_ERR(0, 316, __pyx_L1_error)
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool_Connection = &__pyx_type_4mars_6actors_4pool_11gevent_pool_Connection;
  __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper = &__pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper._new_connection = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *, PyObject *))__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__new_connection;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper._send_remote = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__send_remote;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper.destroy_actor = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_destroy_actor *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_destroy_actor;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper.has_actor = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_has_actor *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_has_actor;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper._send = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__send *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper__send;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper.send = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_send *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_send;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper.tell = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_tell *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_17ActorRemoteHelper_tell;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper) < 0) __PYX_ERR(0, 410, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper.tp_dict, __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper) < 0) __PYX_ERR(0, 410, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_ActorRemoteHelper, (PyObject *)&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper) < 0) __PYX_ERR(0, 410, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper) < 0) __PYX_ERR(0, 410, __pyx_L1_error)
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper = &__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper;
  __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Communicator = &__pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator.__pyx_base = *__pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_AsyncHandler;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator._dispatch = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, PyObject *, PyObject *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__dispatch;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator._send_remote = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__send_remote *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__send_remote;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator._send = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__send *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__send;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator.send = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_send *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator_send;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator.tell = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_tell *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator_tell;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator._create_local_actor = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__create_local_actor;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator._create_remote_actor = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__create_remote_actor;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator._destroy_local_actor = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__destroy_local_actor *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__destroy_local_actor;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator.destroy_actor = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_destroy_actor *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator_destroy_actor;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator._has_local_actor = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator__has_local_actor *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__has_local_actor;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator.has_actor = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_has_actor *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator_has_actor;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator._on_receive_send = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_send;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator._on_receive_tell = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_tell;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator._on_receive_create_actor = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_create_actor;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator._on_receive_destroy_actor = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_destroy_actor;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator._on_receive_has_actor = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_has_actor;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator._on_receive_result = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_result;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator._on_receive_error = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator__on_receive_error;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Communicator.on_receive = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_12Communicator_on_receive *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_12Communicator_on_receive;
  __pyx_type_4mars_6actors_4pool_11gevent_pool_Communicator.tp_base = __pyx_ptype_4mars_6actors_4pool_11gevent_pool_AsyncHandler;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool_Communicator) < 0) __PYX_ERR(0, 590, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool_Communicator.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool_Communicator.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool_Communicator.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool_Communicator.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_4mars_6actors_4pool_11gevent_pool_Communicator.tp_dict, __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Communicator) < 0) __PYX_ERR(0, 590, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Communicator, (PyObject *)&__pyx_type_4mars_6actors_4pool_11gevent_pool_Communicator) < 0) __PYX_ERR(0, 590, __pyx_L1_error)
  if (__pyx_type_4mars_6actors_4pool_11gevent_pool_Communicator.tp_weaklistoffset == 0) __pyx_type_4mars_6actors_4pool_11gevent_pool_Communicator.tp_weaklistoffset = offsetof(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Communicator, __weakref__);
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4mars_6actors_4pool_11gevent_pool_Communicator) < 0) __PYX_ERR(0, 590, __pyx_L1_error)
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool_Communicator = &__pyx_type_4mars_6actors_4pool_11gevent_pool_Communicator;
  __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Dispatcher = &__pyx_vtable_4mars_6actors_4pool_11gevent_pool_Dispatcher;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Dispatcher.__pyx_base = *__pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_AsyncHandler;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Dispatcher._is_remote = (int (*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *, struct __pyx_obj_4mars_6actors_4core_ActorRef *))__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__is_remote;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Dispatcher.send = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_10Dispatcher_send *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher_send;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Dispatcher.tell = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_10Dispatcher_tell *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher_tell;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Dispatcher._on_receive_action = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__on_receive_action;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Dispatcher._on_receive_result = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__on_receive_result;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Dispatcher._on_receive_error = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher__on_receive_error;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_Dispatcher.on_receive = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_Dispatcher *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_10Dispatcher_on_receive;
  __pyx_type_4mars_6actors_4pool_11gevent_pool_Dispatcher.tp_base = __pyx_ptype_4mars_6actors_4pool_11gevent_pool_AsyncHandler;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool_Dispatcher) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool_Dispatcher.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool_Dispatcher.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool_Dispatcher.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool_Dispatcher.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_4mars_6actors_4pool_11gevent_pool_Dispatcher.tp_dict, __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_Dispatcher) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Dispatcher, (PyObject *)&__pyx_type_4mars_6actors_4pool_11gevent_pool_Dispatcher) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4mars_6actors_4pool_11gevent_pool_Dispatcher) < 0) __PYX_ERR(0, 1054, __pyx_L1_error)
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool_Dispatcher = &__pyx_type_4mars_6actors_4pool_11gevent_pool_Dispatcher;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorServerHandler) < 0) __PYX_ERR(0, 1341, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorServerHandler.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorServerHandler.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorServerHandler.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorServerHandler.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_ActorServerHandler, (PyObject *)&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorServerHandler) < 0) __PYX_ERR(0, 1341, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorServerHandler) < 0) __PYX_ERR(0, 1341, __pyx_L1_error)
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorServerHandler = &__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorServerHandler;
  __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorPool = &__pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorPool;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorPool._check_started = (void (*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *))__pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool__check_started;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorPool.destroy_actor = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_9ActorPool_destroy_actor *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool_destroy_actor;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorPool.has_actor = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_9ActorPool_has_actor *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool_has_actor;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorPool._start_process = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool__start_process;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorPool.restart_process = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *, int, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool_restart_process;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorPool.stop = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorPool *, int __pyx_skip_dispatch))__pyx_f_4mars_6actors_4pool_11gevent_pool_9ActorPool_stop;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorPool) < 0) __PYX_ERR(0, 1441, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorPool.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorPool.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorPool.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorPool.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorPool.tp_dict, __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorPool) < 0) __PYX_ERR(0, 1441, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_ActorPool, (PyObject *)&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorPool) < 0) __PYX_ERR(0, 1441, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorPool) < 0) __PYX_ERR(0, 1441, __pyx_L1_error)
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorPool = &__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorPool;
  __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorClient = &__pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorClient;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorClient.has_actor = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_11ActorClient_has_actor *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_11ActorClient_has_actor;
  __pyx_vtable_4mars_6actors_4pool_11gevent_pool_ActorClient.destroy_actor = (PyObject *(*)(struct __pyx_obj_4mars_6actors_4pool_11gevent_pool_ActorClient *, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_11gevent_pool_11ActorClient_destroy_actor *__pyx_optional_args))__pyx_f_4mars_6actors_4pool_11gevent_pool_11ActorClient_destroy_actor;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorClient) < 0) __PYX_ERR(0, 1609, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorClient.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorClient.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorClient.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool_ActorClient.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorClient.tp_dict, __pyx_vtabptr_4mars_6actors_4pool_11gevent_pool_ActorClient) < 0) __PYX_ERR(0, 1609, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_ActorClient, (PyObject *)&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorClient) < 0) __PYX_ERR(0, 1609, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorClient) < 0) __PYX_ERR(0, 1609, __pyx_L1_error)
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorClient = &__pyx_type_4mars_6actors_4pool_11gevent_pool_ActorClient;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor) < 0) __PYX_ERR(0, 143, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor = &__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct__create_actor;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor) < 0) __PYX_ERR(0, 461, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor = &__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_1_create_actor;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run) < 0) __PYX_ERR(0, 505, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run = &__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_2__async_run;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local) < 0) __PYX_ERR(0, 655, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local = &__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_3__send_local;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process) < 0) __PYX_ERR(0, 702, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process = &__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_4__send_process;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor) < 0) __PYX_ERR(0, 779, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor = &__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_5__create_process_actor;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor) < 0) __PYX_ERR(0, 847, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor = &__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_6__destroy_process_actor;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor) < 0) __PYX_ERR(0, 888, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor = &__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_7__has_process_actor;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send) < 0) __PYX_ERR(0, 1101, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send = &__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_8__send;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor) < 0) __PYX_ERR(0, 1152, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor = &__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_9_create_actor;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor) < 0) __PYX_ERR(0, 1194, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor = &__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_10_destroy_actor;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor) < 0) __PYX_ERR(0, 1222, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor = &__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_11_has_actor;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run) < 0) __PYX_ERR(0, 1328, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run = &__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_12_run;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr) < 0) __PYX_ERR(0, 1337, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr = &__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_13_genexpr;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor) < 0) __PYX_ERR(0, 1479, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor = &__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_14_create_actor;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run) < 0) __PYX_ERR(0, 1546, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run = &__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_15_run;
  if (PyType_Ready(&__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr) < 0) __PYX_ERR(0, 1556, __pyx_L1_error)
  __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr.tp_print = 0;
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr.tp_dictoffset && __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr = &__pyx_type_4mars_6actors_4pool_11gevent_pool___pyx_scope_struct_16_genexpr;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __pyx_t_1 = PyImport_ImportModule("mars.actors.distributor"); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_4mars_6actors_11distributor_Distributor = __Pyx_ImportType(__pyx_t_1, "mars.actors.distributor", "Distributor", sizeof(struct __pyx_obj_4mars_6actors_11distributor_Distributor), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4mars_6actors_11distributor_Distributor) __PYX_ERR(3, 17, __pyx_L1_error)
  __pyx_vtabptr_4mars_6actors_11distributor_Distributor = (struct __pyx_vtabstruct_4mars_6actors_11distributor_Distributor*)__Pyx_GetVtable(__pyx_ptype_4mars_6actors_11distributor_Distributor->tp_dict); if (unlikely(!__pyx_vtabptr_4mars_6actors_11distributor_Distributor)) __PYX_ERR(3, 17, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("mars.actors.core"); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_4mars_6actors_4core_ActorRef = __Pyx_ImportType(__pyx_t_1, "mars.actors.core", "ActorRef", sizeof(struct __pyx_obj_4mars_6actors_4core_ActorRef), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4mars_6actors_4core_ActorRef) __PYX_ERR(4, 18, __pyx_L1_error)
  __pyx_vtabptr_4mars_6actors_4core_ActorRef = (struct __pyx_vtabstruct_4mars_6actors_4core_ActorRef*)__Pyx_GetVtable(__pyx_ptype_4mars_6actors_4core_ActorRef->tp_dict); if (unlikely(!__pyx_vtabptr_4mars_6actors_4core_ActorRef)) __PYX_ERR(4, 18, __pyx_L1_error)
  __pyx_ptype_4mars_6actors_4core_Actor = __Pyx_ImportType(__pyx_t_1, "mars.actors.core", "Actor", sizeof(struct __pyx_obj_4mars_6actors_4core_Actor), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4mars_6actors_4core_Actor) __PYX_ERR(4, 29, __pyx_L1_error)
  __pyx_vtabptr_4mars_6actors_4core_Actor = (struct __pyx_vtabstruct_4mars_6actors_4core_Actor*)__Pyx_GetVtable(__pyx_ptype_4mars_6actors_4core_Actor->tp_dict); if (unlikely(!__pyx_vtabptr_4mars_6actors_4core_Actor)) __PYX_ERR(4, 29, __pyx_L1_error)
  __pyx_ptype_4mars_6actors_4core_FunctionActor = __Pyx_ImportType(__pyx_t_1, "mars.actors.core", "FunctionActor", sizeof(struct __pyx_obj_4mars_6actors_4core_FunctionActor), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4mars_6actors_4core_FunctionActor) __PYX_ERR(4, 40, __pyx_L1_error)
  __pyx_vtabptr_4mars_6actors_4core_FunctionActor = (struct __pyx_vtabstruct_4mars_6actors_4core_FunctionActor*)__Pyx_GetVtable(__pyx_ptype_4mars_6actors_4core_FunctionActor->tp_dict); if (unlikely(!__pyx_vtabptr_4mars_6actors_4core_FunctionActor)) __PYX_ERR(4, 40, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("mars.actors.cluster"); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_4mars_6actors_7cluster_ClusterInfo = __Pyx_ImportType(__pyx_t_1, "mars.actors.cluster", "ClusterInfo", sizeof(struct __pyx_obj_4mars_6actors_7cluster_ClusterInfo), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_4mars_6actors_7cluster_ClusterInfo) __PYX_ERR(5, 18, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", 
  #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(6, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore);
   if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(2, 206, __pyx_L1_error)
  __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(2, 229, __pyx_L1_error)
  __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(2, 233, __pyx_L1_error)
  __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore);
   if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(2, 242, __pyx_L1_error)
  __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(2, 918, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_variable_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  /*--- Variable import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __pyx_t_1 = PyImport_ImportModule("mars.actors.pool.messages"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "unpack_message_type_value", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_unpack_message_type_value, "int (PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "unpack_message_type", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_unpack_message_type, "PyObject *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "unpack_message_id", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_unpack_message_id, "PyObject *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "unpack_send_message", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_unpack_send_message, "PyObject *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "pack_send_message", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_pack_send_message, "PyObject *(__pyx_t_4mars_6actors_4pool_8messages_INT32_t, __pyx_t_4mars_6actors_4pool_8messages_INT32_t, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_send_message *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "pack_tell_message", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_pack_tell_message, "PyObject *(__pyx_t_4mars_6actors_4pool_8messages_INT32_t, __pyx_t_4mars_6actors_4pool_8messages_INT32_t, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_tell_message *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "unpack_tell_message", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_unpack_tell_message, "PyObject *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "get_index", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_get_index, "PyObject *(PyObject *, PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "pack_create_actor_message", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_pack_create_actor_message, "PyObject *(__pyx_t_4mars_6actors_4pool_8messages_INT32_t, int, struct __pyx_obj_4mars_6actors_4core_ActorRef *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_create_actor_message *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "unpack_create_actor_message", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_unpack_create_actor_message, "PyObject *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "pack_destroy_actor_message", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_pack_destroy_actor_message, "PyObject *(__pyx_t_4mars_6actors_4pool_8messages_INT32_t, __pyx_t_4mars_6actors_4pool_8messages_INT32_t, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_destroy_actor_message *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "unpack_destroy_actor_message", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_unpack_destroy_actor_message, "PyObject *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "pack_has_actor_message", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_pack_has_actor_message, "PyObject *(__pyx_t_4mars_6actors_4pool_8messages_INT32_t, int, struct __pyx_obj_4mars_6actors_4core_ActorRef *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_has_actor_message *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "unpack_has_actor_message", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_unpack_has_actor_message, "PyObject *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "pack_result_message", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_pack_result_message, "PyObject *(PyObject *, __pyx_t_4mars_6actors_4pool_8messages_INT32_t, int, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_result_message *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "unpack_result_message", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_unpack_result_message, "PyObject *(PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_8messages_unpack_result_message *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "pack_error_message", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_pack_error_message, "PyObject *(PyObject *, __pyx_t_4mars_6actors_4pool_8messages_INT32_t, __pyx_t_4mars_6actors_4pool_8messages_INT32_t, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_4mars_6actors_4pool_8messages_pack_error_message *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "unpack_error_message", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_unpack_error_message, "PyObject *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "read_remote_message", (void (**)(void))&__pyx_f_4mars_6actors_4pool_8messages_read_remote_message, "PyObject *(PyObject *, int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = PyImport_ImportModule("mars.actors.pool.utils"); if (!__pyx_t_2) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_2, "new_actor_id", (void (**)(void))&__pyx_f_4mars_6actors_4pool_5utils_new_actor_id, "PyObject *(int __pyx_skip_dispatch)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_RefNannyFinishContext();
  return -1;
}


#if PY_MAJOR_VERSION < 3
#ifdef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC void
#else
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#endif
#else
#ifdef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#endif
#endif


#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC initgevent_pool(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC initgevent_pool(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_gevent_pool(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_gevent_pool(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
    #if PY_VERSION_HEX >= 0x030700A1
    static PY_INT64_T main_interpreter_id = -1;
    PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
    if (main_interpreter_id == -1) {
        main_interpreter_id = current_id;
        return (unlikely(current_id == -1)) ? -1 : 0;
    } else if (unlikely(main_interpreter_id != current_id))
    #else
    static PyInterpreterState *main_interpreter = NULL;
    PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
    if (!main_interpreter) {
        main_interpreter = current_interpreter;
    } else if (unlikely(main_interpreter != current_interpreter))
    #endif
    {
        PyErr_SetString(
            PyExc_ImportError,
            "Interpreter change detected - this module can only be loaded into one interpreter per process.");
        return -1;
    }
    return 0;
}
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        if (allow_none || value != Py_None) {
            result = PyDict_SetItemString(moddict, to_name, value);
        }
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    if (__Pyx_check_single_interpreter())
        return NULL;
    if (__pyx_m)
        return __Pyx_NewRef(__pyx_m);
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static CYTHON_SMALL_CODE int __pyx_pymod_exec_gevent_pool(PyObject *__pyx_pyinit_module)
#endif
#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;
  __Pyx_RefNannyDeclarations
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  if (__pyx_m) {
    if (__pyx_m == __pyx_pyinit_module) return 0;
    PyErr_SetString(PyExc_RuntimeError, "Module 'gevent_pool' has already been imported. Re-initialisation is not supported.");
    return -1;
  }
  #elif PY_MAJOR_VERSION >= 3
  if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  #endif
  #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("__Pyx_PyMODINIT_FUNC PyInit_gevent_pool(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pxy_PyFrame_Initialize_Offsets
  __Pxy_PyFrame_Initialize_Offsets();
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_AsyncGen_USED
  if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __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 CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_m = __pyx_pyinit_module;
  Py_INCREF(__pyx_m);
  #else
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("gevent_pool", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __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_ERR(0, 1, __pyx_L1_error)
  #endif
  if (__pyx_module_is_main_mars__actors__pool__gevent_pool) {
    if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "mars.actors.pool.gevent_pool")) {
      if (unlikely(PyDict_SetItemString(modules, "mars.actors.pool.gevent_pool", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Global type/function init code ---*/
  (void)__Pyx_modinit_global_init_code();
  (void)__Pyx_modinit_variable_export_code();
  (void)__Pyx_modinit_function_export_code();
  if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
  if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
  (void)__Pyx_modinit_variable_import_code();
  if (unlikely(__Pyx_modinit_function_import_code() != 0)) goto __pyx_L1_error;
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "mars/actors/pool/gevent_pool.pyx":17
 * # limitations under the License.
 * 
 * import weakref             # <<<<<<<<<<<<<<
 * import sys
 * import pickle
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_weakref, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_weakref, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":18
 * 
 * import weakref
 * import sys             # <<<<<<<<<<<<<<
 * import pickle
 * import random
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":19
 * import weakref
 * import sys
 * import pickle             # <<<<<<<<<<<<<<
 * import random
 * import errno
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_pickle, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pickle, __pyx_t_1) < 0) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":20
 * import sys
 * import pickle
 * import random             # <<<<<<<<<<<<<<
 * import errno
 * import socket
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_random, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_random, __pyx_t_1) < 0) __PYX_ERR(0, 20, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":21
 * import pickle
 * import random
 * import errno             # <<<<<<<<<<<<<<
 * import socket
 * import struct
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_errno, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_errno, __pyx_t_1) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":22
 * import random
 * import errno
 * import socket             # <<<<<<<<<<<<<<
 * import struct
 * import itertools
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_socket, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_socket, __pyx_t_1) < 0) __PYX_ERR(0, 22, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":23
 * import errno
 * import socket
 * import struct             # <<<<<<<<<<<<<<
 * import itertools
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_struct, __pyx_t_1) < 0) __PYX_ERR(0, 23, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":24
 * import socket
 * import struct
 * import itertools             # <<<<<<<<<<<<<<
 * 
 * import gevent
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_itertools, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_itertools, __pyx_t_1) < 0) __PYX_ERR(0, 24, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":26
 * import itertools
 * 
 * import gevent             # <<<<<<<<<<<<<<
 * import gevent.queue
 * import gevent.lock
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 26, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_gevent, __pyx_t_1) < 0) __PYX_ERR(0, 26, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":27
 * 
 * import gevent
 * import gevent.queue             # <<<<<<<<<<<<<<
 * import gevent.lock
 * import gevent.event
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent_queue, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_gevent, __pyx_t_1) < 0) __PYX_ERR(0, 27, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":28
 * import gevent
 * import gevent.queue
 * import gevent.lock             # <<<<<<<<<<<<<<
 * import gevent.event
 * import gevent.pool
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent_lock, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_gevent, __pyx_t_1) < 0) __PYX_ERR(0, 28, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":29
 * import gevent.queue
 * import gevent.lock
 * import gevent.event             # <<<<<<<<<<<<<<
 * import gevent.pool
 * import gevent.socket
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent_event, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_gevent, __pyx_t_1) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":30
 * import gevent.lock
 * import gevent.event
 * import gevent.pool             # <<<<<<<<<<<<<<
 * import gevent.socket
 * import gevent.server
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent_pool, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_gevent, __pyx_t_1) < 0) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":31
 * import gevent.event
 * import gevent.pool
 * import gevent.socket             # <<<<<<<<<<<<<<
 * import gevent.server
 * import gevent.subprocess
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent_socket, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_gevent, __pyx_t_1) < 0) __PYX_ERR(0, 31, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":32
 * import gevent.pool
 * import gevent.socket
 * import gevent.server             # <<<<<<<<<<<<<<
 * import gevent.subprocess
 * import gevent.fileobject
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent_server, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_gevent, __pyx_t_1) < 0) __PYX_ERR(0, 32, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":33
 * import gevent.socket
 * import gevent.server
 * import gevent.subprocess             # <<<<<<<<<<<<<<
 * import gevent.fileobject
 * from gevent._tblib import _init as gevent_init_tblib
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent_subprocess, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_gevent, __pyx_t_1) < 0) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":34
 * import gevent.server
 * import gevent.subprocess
 * import gevent.fileobject             # <<<<<<<<<<<<<<
 * from gevent._tblib import _init as gevent_init_tblib
 * from gevent.threadpool import ThreadPool as GThreadPool
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent_fileobject, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_gevent, __pyx_t_1) < 0) __PYX_ERR(0, 34, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":35
 * import gevent.subprocess
 * import gevent.fileobject
 * from gevent._tblib import _init as gevent_init_tblib             # <<<<<<<<<<<<<<
 * from gevent.threadpool import ThreadPool as GThreadPool
 * 
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_init_2);
  __Pyx_GIVEREF(__pyx_n_s_init_2);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_init_2);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_gevent__tblib, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __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_init_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_gevent_init_tblib, __pyx_t_1) < 0) __PYX_ERR(0, 35, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":36
 * import gevent.fileobject
 * from gevent._tblib import _init as gevent_init_tblib
 * from gevent.threadpool import ThreadPool as GThreadPool             # <<<<<<<<<<<<<<
 * 
 * from ...lib import gipc
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_ThreadPool);
  __Pyx_GIVEREF(__pyx_n_s_ThreadPool);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_ThreadPool);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_gevent_threadpool, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __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_ThreadPool); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_GThreadPool, __pyx_t_2) < 0) __PYX_ERR(0, 36, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":38
 * from gevent.threadpool import ThreadPool as GThreadPool
 * 
 * from ...lib import gipc             # <<<<<<<<<<<<<<
 * from ...compat import six, OrderedDict, BrokenPipeError
 * from ..errors import ActorPoolNotStarted, ActorNotExist, ActorAlreadyExist
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_gipc);
  __Pyx_GIVEREF(__pyx_n_s_gipc);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_gipc);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_lib, __pyx_t_1, 3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __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_gipc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_gipc, __pyx_t_1) < 0) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":39
 * 
 * from ...lib import gipc
 * from ...compat import six, OrderedDict, BrokenPipeError             # <<<<<<<<<<<<<<
 * from ..errors import ActorPoolNotStarted, ActorNotExist, ActorAlreadyExist
 * from ..distributor cimport Distributor
 */
  __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_six);
  __Pyx_GIVEREF(__pyx_n_s_six);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_six);
  __Pyx_INCREF(__pyx_n_s_OrderedDict);
  __Pyx_GIVEREF(__pyx_n_s_OrderedDict);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_OrderedDict);
  __Pyx_INCREF(__pyx_n_s_BrokenPipeError);
  __Pyx_GIVEREF(__pyx_n_s_BrokenPipeError);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_BrokenPipeError);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_compat, __pyx_t_2, 3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 39, __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_six); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_six, __pyx_t_2) < 0) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_OrderedDict, __pyx_t_2) < 0) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_BrokenPipeError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_BrokenPipeError, __pyx_t_2) < 0) __PYX_ERR(0, 39, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":40
 * from ...lib import gipc
 * from ...compat import six, OrderedDict, BrokenPipeError
 * from ..errors import ActorPoolNotStarted, ActorNotExist, ActorAlreadyExist             # <<<<<<<<<<<<<<
 * from ..distributor cimport Distributor
 * from ..core cimport ActorRef, Actor
 */
  __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_ActorPoolNotStarted);
  __Pyx_GIVEREF(__pyx_n_s_ActorPoolNotStarted);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_ActorPoolNotStarted);
  __Pyx_INCREF(__pyx_n_s_ActorNotExist);
  __Pyx_GIVEREF(__pyx_n_s_ActorNotExist);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_ActorNotExist);
  __Pyx_INCREF(__pyx_n_s_ActorAlreadyExist);
  __Pyx_GIVEREF(__pyx_n_s_ActorAlreadyExist);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_ActorAlreadyExist);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_errors, __pyx_t_1, 2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __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_ActorPoolNotStarted); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ActorPoolNotStarted, __pyx_t_1) < 0) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ActorNotExist); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ActorNotExist, __pyx_t_1) < 0) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ActorAlreadyExist); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ActorAlreadyExist, __pyx_t_1) < 0) __PYX_ERR(0, 40, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":50
 *     unpack_message_type_value, unpack_message_type, unpack_message_id, read_remote_message, \
 *     get_index, MessageType
 * from .messages import write_remote_message             # <<<<<<<<<<<<<<
 * from .utils cimport new_actor_id
 * from .utils import create_actor_ref
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_write_remote_message);
  __Pyx_GIVEREF(__pyx_n_s_write_remote_message);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_write_remote_message);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_messages, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __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_write_remote_message); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_write_remote_message, __pyx_t_2) < 0) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":52
 * from .messages import write_remote_message
 * from .utils cimport new_actor_id
 * from .utils import create_actor_ref             # <<<<<<<<<<<<<<
 * 
 * gevent_init_tblib()
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_create_actor_ref);
  __Pyx_GIVEREF(__pyx_n_s_create_actor_ref);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_create_actor_ref);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_utils, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 52, __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_create_actor_ref); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_actor_ref, __pyx_t_1) < 0) __PYX_ERR(0, 52, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":54
 * from .utils import create_actor_ref
 * 
 * gevent_init_tblib()             # <<<<<<<<<<<<<<
 * 
 * cdef int REMOTE_FROM_INDEX = -2
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gevent_init_tblib); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 54, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __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;

  /* "mars/actors/pool/gevent_pool.pyx":56
 * gevent_init_tblib()
 * 
 * cdef int REMOTE_FROM_INDEX = -2             # <<<<<<<<<<<<<<
 * cdef int UNKNOWN_TO_INDEX = -1
 * cpdef int REMOTE_DEFAULT_PARALLEL = 50  # parallel connection at most
 */
  __pyx_v_4mars_6actors_4pool_11gevent_pool_REMOTE_FROM_INDEX = -2;

  /* "mars/actors/pool/gevent_pool.pyx":57
 * 
 * cdef int REMOTE_FROM_INDEX = -2
 * cdef int UNKNOWN_TO_INDEX = -1             # <<<<<<<<<<<<<<
 * cpdef int REMOTE_DEFAULT_PARALLEL = 50  # parallel connection at most
 * cpdef int REMOTE_MAX_CONNECTION = 200  # most connections
 */
  __pyx_v_4mars_6actors_4pool_11gevent_pool_UNKNOWN_TO_INDEX = -1;

  /* "mars/actors/pool/gevent_pool.pyx":58
 * cdef int REMOTE_FROM_INDEX = -2
 * cdef int UNKNOWN_TO_INDEX = -1
 * cpdef int REMOTE_DEFAULT_PARALLEL = 50  # parallel connection at most             # <<<<<<<<<<<<<<
 * cpdef int REMOTE_MAX_CONNECTION = 200  # most connections
 * 
 */
  __pyx_v_4mars_6actors_4pool_11gevent_pool_REMOTE_DEFAULT_PARALLEL = 50;

  /* "mars/actors/pool/gevent_pool.pyx":59
 * cdef int UNKNOWN_TO_INDEX = -1
 * cpdef int REMOTE_DEFAULT_PARALLEL = 50  # parallel connection at most
 * cpdef int REMOTE_MAX_CONNECTION = 200  # most connections             # <<<<<<<<<<<<<<
 * 
 * _inaction_encoder = _inaction_decoder = None
 */
  __pyx_v_4mars_6actors_4pool_11gevent_pool_REMOTE_MAX_CONNECTION = 0xC8;

  /* "mars/actors/pool/gevent_pool.pyx":61
 * cpdef int REMOTE_MAX_CONNECTION = 200  # most connections
 * 
 * _inaction_encoder = _inaction_decoder = None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_inaction_encoder, Py_None) < 0) __PYX_ERR(0, 61, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_inaction_decoder, Py_None) < 0) __PYX_ERR(0, 61, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":187
 * 
 *     @staticmethod
 *     def sleep(seconds):             # <<<<<<<<<<<<<<
 *         gevent.sleep(seconds)
 * 
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_12ActorContext_15sleep, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext->tp_dict, __pyx_n_s_sleep, __pyx_t_1) < 0) __PYX_ERR(0, 187, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext);

  /* "mars/actors/pool/gevent_pool.pyx":186
 *                                wait=wait, callback=callback)
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def sleep(seconds):
 *         gevent.sleep(seconds)
 */
  __Pyx_GetNameInClass(__pyx_t_1, (PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext, __pyx_n_s_sleep); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext->tp_dict, __pyx_n_s_sleep, __pyx_t_2) < 0) __PYX_ERR(0, 187, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext);

  /* "mars/actors/pool/gevent_pool.pyx":191
 * 
 *     @staticmethod
 *     def fileobject(fobj, mode='rb', bufsize=-1, close=True):             # <<<<<<<<<<<<<<
 *         return gevent.fileobject.FileObject(fobj, mode=mode, bufsize=bufsize, close=close)
 * 
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_12ActorContext_17fileobject, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext->tp_dict, __pyx_n_s_fileobject, __pyx_t_2) < 0) __PYX_ERR(0, 191, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext);

  /* "mars/actors/pool/gevent_pool.pyx":190
 *         gevent.sleep(seconds)
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def fileobject(fobj, mode='rb', bufsize=-1, close=True):
 *         return gevent.fileobject.FileObject(fobj, mode=mode, bufsize=bufsize, close=close)
 */
  __Pyx_GetNameInClass(__pyx_t_2, (PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext, __pyx_n_s_fileobject); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext->tp_dict, __pyx_n_s_fileobject, __pyx_t_1) < 0) __PYX_ERR(0, 191, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext);

  /* "mars/actors/pool/gevent_pool.pyx":195
 * 
 *     @staticmethod
 *     def popen(*args, **kwargs):             # <<<<<<<<<<<<<<
 *         return gevent.subprocess.Popen(*args, **kwargs)
 * 
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_12ActorContext_19popen, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext->tp_dict, __pyx_n_s_popen, __pyx_t_1) < 0) __PYX_ERR(0, 195, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext);

  /* "mars/actors/pool/gevent_pool.pyx":194
 *         return gevent.fileobject.FileObject(fobj, mode=mode, bufsize=bufsize, close=close)
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def popen(*args, **kwargs):
 *         return gevent.subprocess.Popen(*args, **kwargs)
 */
  __Pyx_GetNameInClass(__pyx_t_1, (PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext, __pyx_n_s_popen); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext->tp_dict, __pyx_n_s_popen, __pyx_t_2) < 0) __PYX_ERR(0, 195, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext);

  /* "mars/actors/pool/gevent_pool.pyx":199
 * 
 *     @staticmethod
 *     def threadpool(num_threads):             # <<<<<<<<<<<<<<
 *         return ThreadPool(num_threads)
 * 
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_12ActorContext_21threadpool, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext->tp_dict, __pyx_n_s_threadpool, __pyx_t_2) < 0) __PYX_ERR(0, 199, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext);

  /* "mars/actors/pool/gevent_pool.pyx":198
 *         return gevent.subprocess.Popen(*args, **kwargs)
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def threadpool(num_threads):
 *         return ThreadPool(num_threads)
 */
  __Pyx_GetNameInClass(__pyx_t_2, (PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext, __pyx_n_s_threadpool); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext->tp_dict, __pyx_n_s_threadpool, __pyx_t_1) < 0) __PYX_ERR(0, 199, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorContext);

  /* "mars/actors/pool/gevent_pool.pyx":334
 * 
 * 
 * class Connections(object):             # <<<<<<<<<<<<<<
 *     global_lock = gevent.lock.Semaphore()
 *     addrs = 0
 */
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__55); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_tuple__55, __pyx_n_s_Connections, __pyx_n_s_Connections, (PyObject *) NULL, __pyx_n_s_mars_actors_pool_gevent_pool, (PyObject *) NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "mars/actors/pool/gevent_pool.pyx":335
 * 
 * class Connections(object):
 *     global_lock = gevent.lock.Semaphore()             # <<<<<<<<<<<<<<
 *     addrs = 0
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_gevent); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_lock); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_Semaphore); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && 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);
    }
  }
  __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_global_lock, __pyx_t_3) < 0) __PYX_ERR(0, 335, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":336
 * class Connections(object):
 *     global_lock = gevent.lock.Semaphore()
 *     addrs = 0             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, address):
 */
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_addrs, __pyx_int_0) < 0) __PYX_ERR(0, 336, __pyx_L1_error)

  /* "mars/actors/pool/gevent_pool.pyx":338
 *     addrs = 0
 * 
 *     def __init__(self, address):             # <<<<<<<<<<<<<<
 *         if isinstance(address, six.string_types):
 *             self.address = address.split(':', 1)
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_11Connections_1__init__, 0, __pyx_n_s_Connections___init, NULL, __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__57)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_init, __pyx_t_3) < 0) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":351
 * 
 *     @property
 *     def conn(self):             # <<<<<<<<<<<<<<
 *         return [conn_lock[0] for conn_lock in six.itervalues(self.conn_locks)]
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_11Connections_3conn, 0, __pyx_n_s_Connections_conn, NULL, __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__59)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "mars/actors/pool/gevent_pool.pyx":350
 *         self.conn_locks = OrderedDict()
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def conn(self):
 *         return [conn_lock[0] for conn_lock in six.itervalues(self.conn_locks)]
 */
  __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_property, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_conn, __pyx_t_4) < 0) __PYX_ERR(0, 351, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":354
 *         return [conn_lock[0] for conn_lock in six.itervalues(self.conn_locks)]
 * 
 *     def _connect(self, conn, lock):             # <<<<<<<<<<<<<<
 *         return Connection(conn, lock)
 * 
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_11Connections_5_connect, 0, __pyx_n_s_Connections__connect, NULL, __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__61)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_connect, __pyx_t_4) < 0) __PYX_ERR(0, 354, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":357
 *         return Connection(conn, lock)
 * 
 *     def got_broken_pipe(self, fd):             # <<<<<<<<<<<<<<
 *         del self.conn_locks[fd]
 * 
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_11Connections_7got_broken_pipe, 0, __pyx_n_s_Connections_got_broken_pipe, NULL, __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__63)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 357, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_got_broken_pipe, __pyx_t_4) < 0) __PYX_ERR(0, 357, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":360
 *         del self.conn_locks[fd]
 * 
 *     def connect(self):             # <<<<<<<<<<<<<<
 *         cdef int maxlen
 *         cdef object conn
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_11Connections_9connect, 0, __pyx_n_s_Connections_connect, NULL, __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__65)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 360, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_connect_2, __pyx_t_4) < 0) __PYX_ERR(0, 360, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":402
 *             return self._connect(conn, lock)
 * 
 *     def __del__(self):             # <<<<<<<<<<<<<<
 *         for c, _ in self.conn_locks.values():
 *             try:
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_11Connections_11__del__, 0, __pyx_n_s_Connections___del, NULL, __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__68)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_del, __pyx_t_4) < 0) __PYX_ERR(0, 402, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":334
 * 
 * 
 * class Connections(object):             # <<<<<<<<<<<<<<
 *     global_lock = gevent.lock.Semaphore()
 *     addrs = 0
 */
  __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_Connections, __pyx_tuple__55, __pyx_t_2, NULL, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Connections, __pyx_t_4) < 0) __PYX_ERR(0, 334, __pyx_L1_error)
  __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;

  /* "mars/actors/pool/gevent_pool.pyx":417
 *     An ActorRemoteHelper instance can be hold by Communicator and ActorClient.
 *     """
 *     index = REMOTE_FROM_INDEX  # means remote             # <<<<<<<<<<<<<<
 * 
 *     cdef object _parallel
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_4mars_6actors_4pool_11gevent_pool_REMOTE_FROM_INDEX); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper->tp_dict, __pyx_n_s_index, __pyx_t_1) < 0) __PYX_ERR(0, 417, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorRemoteHelper);

  /* "mars/actors/pool/gevent_pool.pyx":1377
 * 
 * 
 * class ActorStreamServer(gevent.server.StreamServer):             # <<<<<<<<<<<<<<
 *     def __init__(self, listener, handler):
 *         super(ActorStreamServer, self).__init__(listener, handler)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_gevent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_server); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_StreamServer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_2, __pyx_n_s_ActorStreamServer, __pyx_n_s_ActorStreamServer, (PyObject *) NULL, __pyx_n_s_mars_actors_pool_gevent_pool, (PyObject *) NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "mars/actors/pool/gevent_pool.pyx":1378
 * 
 * class ActorStreamServer(gevent.server.StreamServer):
 *     def __init__(self, listener, handler):             # <<<<<<<<<<<<<<
 *         super(ActorStreamServer, self).__init__(listener, handler)
 *         self._socks = []
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer_1__init__, 0, __pyx_n_s_ActorStreamServer___init, NULL, __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__70)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1378, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_init, __pyx_t_3) < 0) __PYX_ERR(0, 1378, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1383
 *         handler.set_server(self)
 * 
 *     def add_sock(self, sock):             # <<<<<<<<<<<<<<
 *         self._socks.append(sock)
 * 
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer_3add_sock, 0, __pyx_n_s_ActorStreamServer_add_sock, NULL, __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__72)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_add_sock, __pyx_t_3) < 0) __PYX_ERR(0, 1383, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1386
 *         self._socks.append(sock)
 * 
 *     def close(self):             # <<<<<<<<<<<<<<
 *         super(ActorStreamServer, self).close()
 *         [sock.close() for sock in self._socks]
 */
  __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_17ActorStreamServer_5close, 0, __pyx_n_s_ActorStreamServer_close, NULL, __pyx_n_s_mars_actors_pool_gevent_pool, __pyx_d, ((PyObject *)__pyx_codeobj__74)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_SetNameInClass(__pyx_t_4, __pyx_n_s_close, __pyx_t_3) < 0) __PYX_ERR(0, 1386, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1377
 * 
 * 
 * class ActorStreamServer(gevent.server.StreamServer):             # <<<<<<<<<<<<<<
 *     def __init__(self, listener, handler):
 *         super(ActorStreamServer, self).__init__(listener, handler)
 */
  __pyx_t_3 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_ActorStreamServer, __pyx_t_2, __pyx_t_4, NULL, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ActorStreamServer, __pyx_t_3) < 0) __PYX_ERR(0, 1377, __pyx_L1_error)
  __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;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1407
 * 
 * 
 * def start_local_pool(int index, ClusterInfo cluster_info,             # <<<<<<<<<<<<<<
 *                      object pipe=None, Distributor distributor=None,
 *                      object parallel=None, bint join=False):
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_3start_local_pool, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_start_local_pool, __pyx_t_2) < 0) __PYX_ERR(0, 1407, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1429
 * 
 * 
 * def close_pipe(p):             # <<<<<<<<<<<<<<
 *     if p is None:
 *         return
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_5close_pipe, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_close_pipe, __pyx_t_2) < 0) __PYX_ERR(0, 1429, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1588
 * 
 *     @staticmethod
 *     def sleep(seconds):             # <<<<<<<<<<<<<<
 *         gevent.sleep(seconds)
 * 
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_9ActorPool_17sleep, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1588, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorPool->tp_dict, __pyx_n_s_sleep, __pyx_t_2) < 0) __PYX_ERR(0, 1588, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorPool);

  /* "mars/actors/pool/gevent_pool.pyx":1587
 *         self._started = True
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def sleep(seconds):
 *         gevent.sleep(seconds)
 */
  __Pyx_GetNameInClass(__pyx_t_2, (PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorPool, __pyx_n_s_sleep); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1588, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1587, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorPool->tp_dict, __pyx_n_s_sleep, __pyx_t_1) < 0) __PYX_ERR(0, 1588, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorPool);

  /* "mars/actors/pool/gevent_pool.pyx":1640
 * 
 *     @staticmethod
 *     def sleep(seconds):             # <<<<<<<<<<<<<<
 *         gevent.sleep(seconds)
 * 
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_11ActorClient_11sleep, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1640, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorClient->tp_dict, __pyx_n_s_sleep, __pyx_t_1) < 0) __PYX_ERR(0, 1640, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorClient);

  /* "mars/actors/pool/gevent_pool.pyx":1639
 *         return ref
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def sleep(seconds):
 *         gevent.sleep(seconds)
 */
  __Pyx_GetNameInClass(__pyx_t_1, (PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorClient, __pyx_n_s_sleep); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1640, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1639, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorClient->tp_dict, __pyx_n_s_sleep, __pyx_t_2) < 0) __PYX_ERR(0, 1640, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorClient);

  /* "mars/actors/pool/gevent_pool.pyx":1644
 * 
 *     @staticmethod
 *     def threadpool(num_threads):             # <<<<<<<<<<<<<<
 *         return ThreadPool(num_threads)
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_11ActorClient_13threadpool, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1644, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorClient->tp_dict, __pyx_n_s_threadpool, __pyx_t_2) < 0) __PYX_ERR(0, 1644, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorClient);

  /* "mars/actors/pool/gevent_pool.pyx":1643
 *         gevent.sleep(seconds)
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def threadpool(num_threads):
 *         return ThreadPool(num_threads)
 */
  __Pyx_GetNameInClass(__pyx_t_2, (PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorClient, __pyx_n_s_threadpool); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1644, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1643, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorClient->tp_dict, __pyx_n_s_threadpool, __pyx_t_1) < 0) __PYX_ERR(0, 1644, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_4mars_6actors_4pool_11gevent_pool_ActorClient);

  /* "(tree fragment)":1
 * def __pyx_unpickle_MessageContext(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_7__pyx_unpickle_MessageContext, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_MessageContext, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle_MessageContext__set_state(<MessageContext> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_MessageContext__set_state(MessageContext __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.async_result = __pyx_state[0]; __pyx_result.message = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_9__pyx_unpickle_ActorExecutionContext, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_ActorExecutionCon, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_ThreadPool(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_11__pyx_unpickle_ThreadPool, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_ThreadPool, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle_ThreadPool__set_state(<ThreadPool> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ThreadPool__set_state(ThreadPool __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._pool = __pyx_state[0]
 *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_13__pyx_unpickle_ActorContext, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_ActorContext, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_LocalActorPool(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_15__pyx_unpickle_LocalActorPool, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_LocalActorPool, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle_LocalActorPool__set_state(<LocalActorPool> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_LocalActorPool__set_state(LocalActorPool __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.actors = __pyx_state[0]; __pyx_result.address = __pyx_state[1]; __pyx_result.comm_proxy = __pyx_state[2]; __pyx_result.index = __pyx_state[3]
 *     if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_17__pyx_unpickle_AsyncHandler, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_AsyncHandler, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Connection(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_19__pyx_unpickle_Connection, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Connection, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle_Connection__set_state(<Connection> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Connection__set_state(Connection __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.conn = __pyx_state[0]; __pyx_result.lock = __pyx_state[1]
 *     if len(__pyx_state) > 2 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_21__pyx_unpickle_ActorRemoteHelper, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_ActorRemoteHelper, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Communicator(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_23__pyx_unpickle_Communicator, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Communicator, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle_Communicator__set_state(<Communicator> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Communicator__set_state(Communicator __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result._handlers = __pyx_state[0]; __pyx_result.async_results = __pyx_state[1]; __pyx_result.cluster_info = __pyx_state[2]; __pyx_result.distributor = __pyx_state[3]; __pyx_result.index = __pyx_state[4]; __pyx_result.pipe = __pyx_state[5]; __pyx_result.pool = __pyx_state[6]; __pyx_result.remote_handler = __pyx_state[7]; __pyx_result.running = __pyx_state[8]
 *     if len(__pyx_state) > 9 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_25__pyx_unpickle_Dispatcher, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Dispatcher, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_ActorServerHandler(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_27__pyx_unpickle_ActorServerHandler, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_ActorServerHandle, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle_ActorServerHandler__set_state(<ActorServerHandler> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ActorServerHandler__set_state(ActorServerHandler __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.multi_process = __pyx_state[0]; __pyx_result.sender = __pyx_state[1]; __pyx_result.server = __pyx_state[2]
 *     if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_29__pyx_unpickle_ActorPool, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_ActorPool, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_ActorClient(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4mars_6actors_4pool_11gevent_pool_31__pyx_unpickle_ActorClient, NULL, __pyx_n_s_mars_actors_pool_gevent_pool); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_ActorClient, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "mars/actors/pool/gevent_pool.pyx":1
 * #!/usr/bin/env python             # <<<<<<<<<<<<<<
 * # -*- coding: utf-8 -*-
 * # Copyright 1999-2017 Alibaba Group Holding Ltd.
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "../../Python36-x64/lib/site-packages/Cython/Includes/numpy/__init__.pxd":1046
 *         raise ImportError("numpy.core.umath failed to import")
 * 
 * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         _import_umath()
 */

  /*--- Wrapped vars code ---*/

  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);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init mars.actors.pool.gevent_pool", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_CLEAR(__pyx_m);
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init mars.actors.pool.gevent_pool");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #elif PY_MAJOR_VERSION >= 3
  return __pyx_m;
  #else
  return;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule(modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, "RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* PyObjectGetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
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);
}
#endif

/* GetBuiltinName */
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;
}

/* RaiseDoubleKeywords */
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
}

/* ParseKeywords */
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;
}

/* RaiseArgTupleInvalid */
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);
}

/* GetModuleGlobalName */
#if CYTHON_USE_DICT_VERSIONS
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
#else
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
#endif
{
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
    result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    } else if (unlikely(PyErr_Occurred())) {
        return NULL;
    }
#else
    result = PyDict_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
#endif
#else
    result = PyObject_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
    PyErr_Clear();
#endif
    return __Pyx_GetBuiltinName(name);
}

/* PyFunctionFastCall */
#if CYTHON_FAST_PYCALL
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
                                               PyObject *globals) {
    PyFrameObject *f;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif
#endif

/* PyObjectCall */
#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

/* PyObjectCallMethO */
#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

/* PyObjectCallNoArg */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
#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

/* PyCFunctionFastCall */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    int flags = PyCFunction_GET_FLAGS(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
    assert(nargs >= 0);
    assert(nargs == 0 || args != NULL);
    /* _PyCFunction_FastCallDict() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!PyErr_Occurred());
    if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
        return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
    }
}
#endif

/* PyObjectCallOneArg */
#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) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, &arg, 1);
    }
#endif
    if (likely(PyCFunction_Check(func))) {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
        } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

/* PyErrExceptionMatches */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
    PyObject *exc_type = tstate->curexc_type;
    if (exc_type == err) return 1;
    if (unlikely(!exc_type)) return 0;
    if (unlikely(PyTuple_Check(err)))
        return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
    return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
}
#endif

/* PyErrFetchRestore */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    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);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* GetAttr */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_USE_TYPE_SLOTS
#if PY_MAJOR_VERSION >= 3
    if (likely(PyUnicode_Check(n)))
#else
    if (likely(PyString_Check(n)))
#endif
        return __Pyx_PyObject_GetAttrStr(o, n);
#endif
    return PyObject_GetAttr(o, n);
}

/* GetAttr3 */
static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        return NULL;
    __Pyx_PyErr_Clear();
    Py_INCREF(d);
    return d;
}
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = __Pyx_GetAttr(o, n);
    return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
}

/* PyObjectCall2Args */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
    PyObject *args, *result = NULL;
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyFunction_FastCall(function, args, 2);
    }
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyCFunction_FastCall(function, args, 2);
    }
    #endif
    args = PyTuple_New(2);
    if (unlikely(!args)) goto done;
    Py_INCREF(arg1);
    PyTuple_SET_ITEM(args, 0, arg1);
    Py_INCREF(arg2);
    PyTuple_SET_ITEM(args, 1, arg2);
    Py_INCREF(function);
    result = __Pyx_PyObject_Call(function, args, NULL);
    Py_DECREF(args);
    Py_DECREF(function);
done:
    return result;
}

/* ExtTypeTest */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(__Pyx_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

/* GetTopmostException */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
{
    _PyErr_StackItem *exc_info = tstate->exc_info;
    while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
           exc_info->previous_item != NULL)
    {
        exc_info = exc_info->previous_item;
    }
    return exc_info;
}
#endif

/* SaveResetException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
    *type = exc_info->exc_type;
    *value = exc_info->exc_value;
    *tb = exc_info->exc_traceback;
    #else
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    #endif
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = type;
    exc_info->exc_value = value;
    exc_info->exc_traceback = tb;
    #else
    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;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* GetException */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
#endif
{
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_FAST_THREAD_STATE
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    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_FAST_THREAD_STATE
    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_FAST_THREAD_STATE
    #if CYTHON_USE_EXC_INFO_STACK
    {
        _PyErr_StackItem *exc_info = tstate->exc_info;
        tmp_type = exc_info->exc_type;
        tmp_value = exc_info->exc_value;
        tmp_tb = exc_info->exc_traceback;
        exc_info->exc_type = local_type;
        exc_info->exc_value = local_value;
        exc_info->exc_traceback = local_tb;
    }
    #else
    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;
    #endif
    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;
}

/* RaiseTooManyValuesToUnpack */
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);
}

/* RaiseNeedMoreValuesToUnpack */
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");
}

/* IterFinish */
static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_FAST_THREAD_STATE
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(__Pyx_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
}

/* UnpackItemEndCheck */
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;
}

/* WriteUnraisableException */
static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_PyThreadState_declare
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#ifdef _MSC_VER
    else state = (PyGILState_STATE)-1;
#endif
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#endif
}

/* ArgTypeTest */
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    else if (exact) {
        #if PY_MAJOR_VERSION == 2
        if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(__Pyx_TypeCheck(obj, type))) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

/* None */
static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

/* PyObjectSetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
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);
}
#endif

/* UnpackUnboundCMethod */
static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
    PyObject *method;
    method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
    if (unlikely(!method))
        return -1;
    target->method = method;
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION >= 3
    if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
    #endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
        target->func = descr->d_method->ml_meth;
        target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
    }
#endif
    return 0;
}

/* CallUnboundCMethod2 */
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1
static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
    if (likely(cfunc->func)) {
        PyObject *args[2] = {arg1, arg2};
        if (cfunc->flag == METH_FASTCALL) {
            #if PY_VERSION_HEX >= 0x030700A0
            return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, args, 2);
            #else
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL);
            #endif
        }
        #if PY_VERSION_HEX >= 0x030700A0
        if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL);
        #endif
    }
    return __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg1);
        PyTuple_SET_ITEM(args, 0, arg1);
        Py_INCREF(arg2);
        PyTuple_SET_ITEM(args, 1, arg2);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(3);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg1);
        PyTuple_SET_ITEM(args, 1, arg1);
        Py_INCREF(arg2);
        PyTuple_SET_ITEM(args, 2, arg2);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(3, self, arg1, arg2);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* CallUnboundCMethod1 */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) {
    if (likely(cfunc->func)) {
        int flag = cfunc->flag;
        if (flag == METH_O) {
            return (*(cfunc->func))(self, arg);
        } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) {
            if (PY_VERSION_HEX >= 0x030700A0) {
                return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, &arg, 1);
            } else {
                return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
            }
        } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
        }
    }
    return __Pyx__CallUnboundCMethod1(cfunc, self, arg);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 0, arg);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        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);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(2, self, arg);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* py_dict_pop */
static CYTHON_INLINE PyObject *__Pyx_PyDict_Pop(PyObject *d, PyObject *key, PyObject *default_value) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030600B3
    if ((1)) {
        return _PyDict_Pop(d, key, default_value);
    } else
#endif
    if (default_value) {
        return __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_pop, d, key, default_value);
    } else {
        return __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_pop, d, key);
    }
}

/* FetchCommonType */
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;
}

/* CythonFunction */
#include <structmember.h>
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, CYTHON_UNUSED void *context)
{
    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, CYTHON_UNUSED void *context)
{
    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, CYTHON_UNUSED void *context)
{
    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, CYTHON_UNUSED void *context)
{
    Py_INCREF(op->func_qualname);
    return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
{
    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, CYTHON_UNUSED void *context)
{
    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, CYTHON_UNUSED void *context)
{
    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, CYTHON_UNUSED void *context)
{
    Py_INCREF(op->func_globals);
    return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
    int result = 0;
    PyObject *res = op->defaults_getter((PyObject *) op);
    if (unlikely(!res))
        return -1;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    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);
    #else
    op->defaults_tuple = PySequence_ITEM(res, 0);
    if (unlikely(!op->defaults_tuple)) result = -1;
    else {
        op->defaults_kwdict = PySequence_ITEM(res, 1);
        if (unlikely(!op->defaults_kwdict)) result = -1;
    }
    #endif
    Py_DECREF(res);
    return result;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
    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, CYTHON_UNUSED void *context) {
    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, CYTHON_UNUSED void *context) {
    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, CYTHON_UNUSED void *context) {
    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, CYTHON_UNUSED void *context) {
    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, CYTHON_UNUSED void *context) {
    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(PyCFunctionObject, 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]);
        PyObject_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    if (__Pyx_CyFunction_weakreflist(m) != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    __Pyx__CyFunction_dealloc(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
}
static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = f->m_ml->ml_meth;
    Py_ssize_t size;
    switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
    case METH_VARARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0))
            return (*meth)(self, arg);
        break;
    case METH_VARARGS | METH_KEYWORDS:
        return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw);
    case METH_NOARGS:
        if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
            size = PyTuple_GET_SIZE(arg);
            if (likely(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 (likely(size == 1)) {
                PyObject *result, *arg0;
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                arg0 = PyTuple_GET_ITEM(arg, 0);
                #else
                arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
                #endif
                result = (*meth)(self, arg0);
                #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
                Py_DECREF(arg0);
                #endif
                return result;
            }
            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;
}
static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
}
static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
    PyObject *result;
    __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
    if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
        Py_ssize_t argc;
        PyObject *new_args;
        PyObject *self;
        argc = PyTuple_GET_SIZE(args);
        new_args = PyTuple_GetSlice(args, 1, argc);
        if (unlikely(!new_args))
            return NULL;
        self = PyTuple_GetItem(args, 0);
        if (unlikely(!self)) {
            Py_DECREF(new_args);
            return NULL;
        }
        result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
        Py_DECREF(new_args);
    } else {
        result = __Pyx_CyFunction_Call(func, args, kw);
    }
    return result;
}
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_CallAsMethod,
    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) {
    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
    if (unlikely(__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 = PyObject_Malloc(size);
    if (unlikely(!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);
}

/* KeywordStringCheck */
static int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
#if CYTHON_COMPILING_IN_PYPY
    if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
        goto invalid_keyword;
    return 1;
#else
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_Check(key)))
        #endif
            if (unlikely(!PyUnicode_Check(key)))
                goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    return 0;
#endif
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
    return 0;
}

/* DictGetItem */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred()) {
            if (unlikely(PyTuple_Check(key))) {
                PyObject* args = PyTuple_Pack(1, key);
                if (likely(args)) {
                    PyErr_SetObject(PyExc_KeyError, args);
                    Py_DECREF(args);
                }
            } else {
                PyErr_SetObject(PyExc_KeyError, key);
            }
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#endif

/* GetItemInt */
static 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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyList_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, wrapped_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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyTuple_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, wrapped_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_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely(__Pyx_is_valid_index(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(__Pyx_is_valid_index(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))
                        return NULL;
                    PyErr_Clear();
                }
            }
            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));
}

/* RaiseException */
#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    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_PyThreadState_assign
    __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 (cause) {
        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 = __Pyx_PyThreadState_Current;
        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

/* PyIntBinop */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) {
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("add", return NULL)
            result = ((double)a) + (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif

/* IterNext */
static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) {
    PyObject* exc_type;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    exc_type = __Pyx_PyErr_Occurred();
    if (unlikely(exc_type)) {
        if (!defval || unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
            return NULL;
        __Pyx_PyErr_Clear();
        Py_INCREF(defval);
        return defval;
    }
    if (defval) {
        Py_INCREF(defval);
        return defval;
    }
    __Pyx_PyErr_SetNone(PyExc_StopIteration);
    return NULL;
}
static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) {
    PyErr_Format(PyExc_TypeError,
        "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
}
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
    PyObject* next;
    iternextfunc iternext = Py_TYPE(iterator)->tp_iternext;
    if (likely(iternext)) {
#if CYTHON_USE_TYPE_SLOTS
        next = iternext(iterator);
        if (likely(next))
            return next;
        #if PY_VERSION_HEX >= 0x02070000
        if (unlikely(iternext == &_PyObject_NextNotImplemented))
            return NULL;
        #endif
#else
        next = PyIter_Next(iterator);
        if (likely(next))
            return next;
#endif
    } else if (CYTHON_USE_TYPE_SLOTS || unlikely(!PyIter_Check(iterator))) {
        __Pyx_PyIter_Next_ErrorNoIterator(iterator);
        return NULL;
    }
#if !CYTHON_USE_TYPE_SLOTS
    else {
        next = PyIter_Next(iterator);
        if (likely(next))
            return next;
    }
#endif
    return __Pyx_PyIter_Next2Default(defval);
}

/* ObjectGetItem */
#if CYTHON_USE_TYPE_SLOTS
static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
    PyObject *runerr;
    Py_ssize_t key_value;
    PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
    if (unlikely(!(m && m->sq_item))) {
        PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
        return NULL;
    }
    key_value = __Pyx_PyIndex_AsSsize_t(index);
    if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
        return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
    }
    if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
        PyErr_Clear();
        PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
    }
    return NULL;
}
static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
    PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
    if (likely(m && m->mp_subscript)) {
        return m->mp_subscript(obj, key);
    }
    return __Pyx_PyObject_GetIndex(obj, key);
}
#endif

/* FastTypeChecks */
#if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = a->tp_base;
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
    PyObject *exception, *value, *tb;
    int res;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&exception, &value, &tb);
    res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
    if (unlikely(res == -1)) {
        PyErr_WriteUnraisable(err);
        res = 0;
    }
    if (!res) {
        res = PyObject_IsSubclass(err, exc_type2);
        if (unlikely(res == -1)) {
            PyErr_WriteUnraisable(err);
            res = 0;
        }
    }
    __Pyx_ErrRestore(exception, value, tb);
    return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
    if (!res) {
        res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
    return res;
}
#endif
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    assert(PyExceptionClass_Check(exc_type));
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        PyObject *t = PyTuple_GET_ITEM(tuple, i);
        #if PY_MAJOR_VERSION < 3
        if (likely(exc_type == t)) return 1;
        #endif
        if (likely(PyExceptionClass_Check(t))) {
            if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
        } else {
        }
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        if (likely(PyExceptionClass_Check(exc_type))) {
            return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
        } else if (likely(PyTuple_Check(exc_type))) {
            return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
        } else {
        }
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    assert(PyExceptionClass_Check(exc_type1));
    assert(PyExceptionClass_Check(exc_type2));
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* SliceObject */
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_USE_TYPE_SLOTS
    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))
                    goto bad;
                PyErr_Clear();
            }
        }
        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_USE_TYPE_SLOTS
        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;
}

/* BytesEquals */
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;
#if CYTHON_USE_UNICODE_INTERNALS
            Py_hash_t hash1, hash2;
            hash1 = ((PyBytesObject*)s1)->ob_shash;
            hash2 = ((PyBytesObject*)s2)->ob_shash;
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                return (equals == Py_NE);
            }
#endif
            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
}

/* UnicodeEquals */
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;
        }
#if CYTHON_USE_UNICODE_INTERNALS
        {
            Py_hash_t hash1, hash2;
        #if CYTHON_PEP393_ENABLED
            hash1 = ((PyASCIIObject*)s1)->hash;
            hash2 = ((PyASCIIObject*)s2)->hash;
        #else
            hash1 = ((PyUnicodeObject*)s1)->hash;
            hash2 = ((PyUnicodeObject*)s2)->hash;
        #endif
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                goto return_ne;
            }
        }
#endif
        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_MAJOR_VERSION < 3
        Py_XDECREF(owned_ref);
        #endif
        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
}

/* SliceTupleAndList */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE void __Pyx_crop_slice(Py_ssize_t* _start, Py_ssize_t* _stop, Py_ssize_t* _length) {
    Py_ssize_t start = *_start, stop = *_stop, length = *_length;
    if (start < 0) {
        start += length;
        if (start < 0)
            start = 0;
    }
    if (stop < 0)
        stop += length;
    else if (stop > length)
        stop = length;
    *_length = stop - start;
    *_start = start;
    *_stop = stop;
}
static CYTHON_INLINE void __Pyx_copy_object_array(PyObject** CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
    PyObject *v;
    Py_ssize_t i;
    for (i = 0; i < length; i++) {
        v = dest[i] = src[i];
        Py_INCREF(v);
    }
}
static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(
            PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
    PyObject* dest;
    Py_ssize_t length = PyList_GET_SIZE(src);
    __Pyx_crop_slice(&start, &stop, &length);
    if (unlikely(length <= 0))
        return PyList_New(0);
    dest = PyList_New(length);
    if (unlikely(!dest))
        return NULL;
    __Pyx_copy_object_array(
        ((PyListObject*)src)->ob_item + start,
        ((PyListObject*)dest)->ob_item,
        length);
    return dest;
}
static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(
            PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
    PyObject* dest;
    Py_ssize_t length = PyTuple_GET_SIZE(src);
    __Pyx_crop_slice(&start, &stop, &length);
    if (unlikely(length <= 0))
        return PyTuple_New(0);
    dest = PyTuple_New(length);
    if (unlikely(!dest))
        return NULL;
    __Pyx_copy_object_array(
        ((PyTupleObject*)src)->ob_item + start,
        ((PyTupleObject*)dest)->ob_item,
        length);
    return dest;
}
#endif

/* RaiseNoneIterError */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

/* PyObjectGetMethod */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
    PyObject *attr;
#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
    PyTypeObject *tp = Py_TYPE(obj);
    PyObject *descr;
    descrgetfunc f = NULL;
    PyObject **dictptr, *dict;
    int meth_found = 0;
    assert (*method == NULL);
    if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
        attr = __Pyx_PyObject_GetAttrStr(obj, name);
        goto try_unpack;
    }
    if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
        return 0;
    }
    descr = _PyType_Lookup(tp, name);
    if (likely(descr != NULL)) {
        Py_INCREF(descr);
#if PY_MAJOR_VERSION >= 3
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
        #endif
#else
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr)))
        #endif
#endif
        {
            meth_found = 1;
        } else {
            f = Py_TYPE(descr)->tp_descr_get;
            if (f != NULL && PyDescr_IsData(descr)) {
                attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
                Py_DECREF(descr);
                goto try_unpack;
            }
        }
    }
    dictptr = _PyObject_GetDictPtr(obj);
    if (dictptr != NULL && (dict = *dictptr) != NULL) {
        Py_INCREF(dict);
        attr = __Pyx_PyDict_GetItemStr(dict, name);
        if (attr != NULL) {
            Py_INCREF(attr);
            Py_DECREF(dict);
            Py_XDECREF(descr);
            goto try_unpack;
        }
        Py_DECREF(dict);
    }
    if (meth_found) {
        *method = descr;
        return 1;
    }
    if (f != NULL) {
        attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
        Py_DECREF(descr);
        goto try_unpack;
    }
    if (descr != NULL) {
        *method = descr;
        return 0;
    }
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(name));
#endif
    return 0;
#else
    attr = __Pyx_PyObject_GetAttrStr(obj, name);
    goto try_unpack;
#endif
try_unpack:
#if CYTHON_UNPACK_METHODS
    if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
        PyObject *function = PyMethod_GET_FUNCTION(attr);
        Py_INCREF(function);
        Py_DECREF(attr);
        *method = function;
        return 1;
    }
#endif
    *method = attr;
    return 0;
}

/* PyObjectCallMethod1 */
static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
    PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
    Py_DECREF(method);
    return result;
}
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method = NULL, *result;
    int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
    if (likely(is_method)) {
        result = __Pyx_PyObject_Call2Args(method, obj, arg);
        Py_DECREF(method);
        return result;
    }
    if (unlikely(!method)) return NULL;
    return __Pyx__PyObject_CallMethod1(method, arg);
}

/* append */
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;
}

/* Import */
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_MAJOR_VERSION < 3
    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, '.')) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_MAJOR_VERSION < 3
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* SetItemInt */
static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
                                               CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
        if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) {
            PyObject* old = PyList_GET_ITEM(o, n);
            Py_INCREF(v);
            PyList_SET_ITEM(o, n, v);
            Py_DECREF(old);
            return 1;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_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))
                        return -1;
                    PyErr_Clear();
                }
            }
            return m->sq_ass_item(o, i, v);
        }
    }
#else
#if CYTHON_COMPILING_IN_PYPY
    if (is_list || (PySequence_Check(o) && !PyDict_Check(o)))
#else
    if (is_list || PySequence_Check(o))
#endif
    {
        return PySequence_SetItem(o, i, v);
    }
#endif
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

/* SwapException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = *type;
    exc_info->exc_value = *value;
    exc_info->exc_traceback = *tb;
    #else
    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;
    #endif
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#endif

/* dict_getitem_default */
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);
    if ((1));
#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);
    }
#endif
    else {
        if (default_value == Py_None)
            value = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_get, d, key);
        else
            value = __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_get, d, key, default_value);
    }
    return value;
}

/* ImportFrom */
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;
}

/* HasAttr */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
    PyObject *r;
    if (unlikely(!__Pyx_PyBaseString_Check(n))) {
        PyErr_SetString(PyExc_TypeError,
                        "hasattr(): attribute name must be string");
        return -1;
    }
    r = __Pyx_GetAttr(o, n);
    if (unlikely(!r)) {
        PyErr_Clear();
        return 0;
    } else {
        Py_DECREF(r);
        return 1;
    }
}

/* PyObject_GenericGetAttrNoDict */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, attr_name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(attr_name));
#endif
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
    PyObject *descr;
    PyTypeObject *tp = Py_TYPE(obj);
    if (unlikely(!PyString_Check(attr_name))) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    assert(!tp->tp_dictoffset);
    descr = _PyType_Lookup(tp, attr_name);
    if (unlikely(!descr)) {
        return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
    }
    Py_INCREF(descr);
    #if PY_MAJOR_VERSION < 3
    if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
    #endif
    {
        descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
        if (unlikely(f)) {
            PyObject *res = f(descr, obj, (PyObject *)tp);
            Py_DECREF(descr);
            return res;
        }
    }
    return descr;
}
#endif

/* PyObject_GenericGetAttr */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
    if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
}
#endif

/* SetVTable */
static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

/* SetupReduce */
static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  int ret;
  PyObject *name_attr;
  name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
  if (likely(name_attr)) {
      ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  } else {
      ret = -1;
  }
  if (unlikely(ret < 0)) {
      PyErr_Clear();
      ret = 0;
  }
  Py_XDECREF(name_attr);
  return ret;
}
static int __Pyx_setup_reduce(PyObject* type_obj) {
    int ret = 0;
    PyObject *object_reduce = NULL;
    PyObject *object_reduce_ex = NULL;
    PyObject *reduce = NULL;
    PyObject *reduce_ex = NULL;
    PyObject *reduce_cython = NULL;
    PyObject *setstate = NULL;
    PyObject *setstate_cython = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
    if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD;
#else
    if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD;
#endif
#if CYTHON_USE_PYTYPE_LOOKUP
    object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
#else
    object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
#endif
    reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD;
    if (reduce_ex == object_reduce_ex) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
#else
        object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
#endif
        reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD;
        if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
            reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD;
            ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD;
            ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD;
            setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
            if (!setstate) PyErr_Clear();
            if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
                setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD;
                ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD;
                ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD;
            }
            PyType_Modified((PyTypeObject*)type_obj);
        }
    }
    goto GOOD;
BAD:
    if (!PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
    ret = -1;
GOOD:
#if !CYTHON_USE_PYTYPE_LOOKUP
    Py_XDECREF(object_reduce);
    Py_XDECREF(object_reduce_ex);
#endif
    Py_XDECREF(reduce);
    Py_XDECREF(reduce_ex);
    Py_XDECREF(reduce_cython);
    Py_XDECREF(setstate);
    Py_XDECREF(setstate_cython);
    return ret;
}

/* TypeImport */
#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
    size_t size, enum __Pyx_ImportType_CheckSize check_size)
{
    PyObject *result = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    result = PyObject_GetAttrString(module, class_name);
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if ((size_t)basicsize < size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(result);
    return NULL;
}
#endif

/* GetVTable */
static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

/* GetNameInClass */
static PyObject *__Pyx_GetGlobalNameAfterAttributeLookup(PyObject *name) {
    PyObject *result;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        return NULL;
    __Pyx_PyErr_Clear();
    __Pyx_GetModuleGlobalNameUncached(result, name);
    return result;
}
static PyObject *__Pyx__GetNameInClass(PyObject *nmspace, PyObject *name) {
    PyObject *result;
    result = __Pyx_PyObject_GetAttrStr(nmspace, name);
    if (!result) {
        result = __Pyx_GetGlobalNameAfterAttributeLookup(name);
    }
    return result;
}

/* CalculateMetaclass */
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;
}

/* Py3ClassCreate */
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;
}

/* CLineInTraceback */
#ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
    PyObject *use_cline;
    PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict;
#endif
    if (unlikely(!__pyx_cython_runtime)) {
        return c_line;
    }
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
        __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
            use_cline, *cython_runtime_dict,
            __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
    } else
#endif
    {
      PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
      if (use_cline_obj) {
        use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
        Py_DECREF(use_cline_obj);
      } else {
        PyErr_Clear();
        use_cline = NULL;
      }
    }
    if (!use_cline) {
        c_line = 0;
        PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
        c_line = 0;
    }
    __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
    return c_line;
}
#endif

/* CodeObjectCache */
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 - start) / 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);
}

/* AddTraceback */
#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;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(tstate, c_line);
    }
    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(
        tstate,            /*PyThreadState *tstate,*/
        py_code,           /*PyCodeObject *code,*/
        __pyx_d,    /*PyObject *globals,*/
        0                  /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
    const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

/* CIntFromPyVerify */
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        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 (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 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);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_4mars_6actors_4pool_8messages_MessageType(enum __pyx_t_4mars_6actors_4pool_8messages_MessageType value) {
    const enum __pyx_t_4mars_6actors_4pool_8messages_MessageType neg_one = (enum __pyx_t_4mars_6actors_4pool_8messages_MessageType) ((enum __pyx_t_4mars_6actors_4pool_8messages_MessageType) 0 - (enum __pyx_t_4mars_6actors_4pool_8messages_MessageType) 1), const_zero = (enum __pyx_t_4mars_6actors_4pool_8messages_MessageType) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(enum __pyx_t_4mars_6actors_4pool_8messages_MessageType) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum __pyx_t_4mars_6actors_4pool_8messages_MessageType) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_4mars_6actors_4pool_8messages_MessageType) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(enum __pyx_t_4mars_6actors_4pool_8messages_MessageType) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum __pyx_t_4mars_6actors_4pool_8messages_MessageType) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(enum __pyx_t_4mars_6actors_4pool_8messages_MessageType),
                                     little, !is_unsigned);
    }
}

/* Declarations */
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return ::std::complex< float >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return x + y*(__pyx_t_float_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      __pyx_t_float_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

/* Arithmetic */
#if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    #if 1
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        if (b.imag == 0) {
            return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else if (fabsf(b.real) >= fabsf(b.imag)) {
            if (b.real == 0 && b.imag == 0) {
                return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag);
            } else {
                float r = b.imag / b.real;
                float s = 1.0 / (b.real + b.imag * r);
                return __pyx_t_float_complex_from_parts(
                    (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
            }
        } else {
            float r = b.real / b.imag;
            float s = 1.0 / (b.imag + b.real * r);
            return __pyx_t_float_complex_from_parts(
                (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
        }
    }
    #else
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        if (b.imag == 0) {
            return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else {
            float denom = b.real * b.real + b.imag * b.imag;
            return __pyx_t_float_complex_from_parts(
                (a.real * b.real + a.imag * b.imag) / denom,
                (a.imag * b.real - a.real * b.imag) / denom);
        }
    }
    #endif
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
    #if 1
        static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) {
          #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
            return sqrtf(z.real*z.real + z.imag*z.imag);
          #else
            return hypotf(z.real, z.imag);
          #endif
        }
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
            __pyx_t_float_complex z;
            float r, lnr, theta, z_r, z_theta;
            if (b.imag == 0 && b.real == (int)b.real) {
                if (b.real < 0) {
                    float denom = a.real * a.real + a.imag * a.imag;
                    a.real = a.real / denom;
                    a.imag = -a.imag / denom;
                    b.real = -b.real;
                }
                switch ((int)b.real) {
                    case 0:
                        z.real = 1;
                        z.imag = 0;
                        return z;
                    case 1:
                        return a;
                    case 2:
                        z = __Pyx_c_prod_float(a, a);
                        return __Pyx_c_prod_float(a, a);
                    case 3:
                        z = __Pyx_c_prod_float(a, a);
                        return __Pyx_c_prod_float(z, a);
                    case 4:
                        z = __Pyx_c_prod_float(a, a);
                        return __Pyx_c_prod_float(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                } else if (b.imag == 0) {
                    z.real = powf(a.real, b.real);
                    z.imag = 0;
                    return z;
                } else if (a.real > 0) {
                    r = a.real;
                    theta = 0;
                } else {
                    r = -a.real;
                    theta = atan2f(0, -1);
                }
            } else {
                r = __Pyx_c_abs_float(a);
                theta = atan2f(a.imag, a.real);
            }
            lnr = logf(r);
            z_r = expf(lnr * b.real - theta * b.imag);
            z_theta = theta * b.real + lnr * b.imag;
            z.real = z_r * cosf(z_theta);
            z.imag = z_r * sinf(z_theta);
            return z;
        }
    #endif
#endif

/* Declarations */
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return ::std::complex< double >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return x + y*(__pyx_t_double_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      __pyx_t_double_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

/* Arithmetic */
#if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    #if 1
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        if (b.imag == 0) {
            return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else if (fabs(b.real) >= fabs(b.imag)) {
            if (b.real == 0 && b.imag == 0) {
                return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
            } else {
                double r = b.imag / b.real;
                double s = 1.0 / (b.real + b.imag * r);
                return __pyx_t_double_complex_from_parts(
                    (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
            }
        } else {
            double r = b.real / b.imag;
            double s = 1.0 / (b.imag + b.real * r);
            return __pyx_t_double_complex_from_parts(
                (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
        }
    }
    #else
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        if (b.imag == 0) {
            return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else {
            double denom = b.real * b.real + b.imag * b.imag;
            return __pyx_t_double_complex_from_parts(
                (a.real * b.real + a.imag * b.imag) / denom,
                (a.imag * b.real - a.real * b.imag) / denom);
        }
    }
    #endif
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
    #if 1
        static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
          #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
            return sqrt(z.real*z.real + z.imag*z.imag);
          #else
            return hypot(z.real, z.imag);
          #endif
        }
        static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
            __pyx_t_double_complex z;
            double r, lnr, theta, z_r, z_theta;
            if (b.imag == 0 && b.real == (int)b.real) {
                if (b.real < 0) {
                    double denom = a.real * a.real + a.imag * a.imag;
                    a.real = a.real / denom;
                    a.imag = -a.imag / denom;
                    b.real = -b.real;
                }
                switch ((int)b.real) {
                    case 0:
                        z.real = 1;
                        z.imag = 0;
                        return z;
                    case 1:
                        return a;
                    case 2:
                        z = __Pyx_c_prod_double(a, a);
                        return __Pyx_c_prod_double(a, a);
                    case 3:
                        z = __Pyx_c_prod_double(a, a);
                        return __Pyx_c_prod_double(z, a);
                    case 4:
                        z = __Pyx_c_prod_double(a, a);
                        return __Pyx_c_prod_double(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                } else if (b.imag == 0) {
                    z.real = pow(a.real, b.real);
                    z.imag = 0;
                    return z;
                } else if (a.real > 0) {
                    r = a.real;
                    theta = 0;
                } else {
                    r = -a.real;
                    theta = atan2(0, -1);
                }
            } else {
                r = __Pyx_c_abs_double(a);
                theta = atan2(a.imag, a.real);
            }
            lnr = log(r);
            z_r = exp(lnr * b.real - theta * b.imag);
            z_theta = theta * b.real + lnr * b.imag;
            z.real = z_r * cos(z_theta);
            z.imag = z_r * sin(z_theta);
            return z;
        }
    #endif
#endif

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) {
    const enum NPY_TYPES neg_one = (enum NPY_TYPES) ((enum NPY_TYPES) 0 - (enum NPY_TYPES) 1), const_zero = (enum NPY_TYPES) 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(enum NPY_TYPES) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(enum NPY_TYPES) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 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_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#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_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#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_IntOrLong(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_IntOrLong(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;
}

/* CIntFromPy */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 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_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#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_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#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_IntOrLong(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_IntOrLong(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;
}

/* CIntFromPy */
static CYTHON_INLINE npy_int32 __Pyx_PyInt_As_npy_int32(PyObject *x) {
    const npy_int32 neg_one = (npy_int32) ((npy_int32) 0 - (npy_int32) 1), const_zero = (npy_int32) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(npy_int32) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(npy_int32, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (npy_int32) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (npy_int32) 0;
                case  1: __PYX_VERIFY_RETURN_INT(npy_int32, digit, digits[0])
                case 2:
                    if (8 * sizeof(npy_int32) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) >= 2 * PyLong_SHIFT) {
                            return (npy_int32) (((((npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(npy_int32) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) >= 3 * PyLong_SHIFT) {
                            return (npy_int32) (((((((npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(npy_int32) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) >= 4 * PyLong_SHIFT) {
                            return (npy_int32) (((((((((npy_int32)digits[3]) << PyLong_SHIFT) | (npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0]));
                        }
                    }
                    break;
            }
#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 (npy_int32) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(npy_int32) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(npy_int32, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(npy_int32) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(npy_int32, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (npy_int32) 0;
                case -1: __PYX_VERIFY_RETURN_INT(npy_int32, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(npy_int32,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(npy_int32) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) - 1 > 2 * PyLong_SHIFT) {
                            return (npy_int32) (((npy_int32)-1)*(((((npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(npy_int32) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) - 1 > 2 * PyLong_SHIFT) {
                            return (npy_int32) ((((((npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(npy_int32) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) - 1 > 3 * PyLong_SHIFT) {
                            return (npy_int32) (((npy_int32)-1)*(((((((npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(npy_int32) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) - 1 > 3 * PyLong_SHIFT) {
                            return (npy_int32) ((((((((npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(npy_int32) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) - 1 > 4 * PyLong_SHIFT) {
                            return (npy_int32) (((npy_int32)-1)*(((((((((npy_int32)digits[3]) << PyLong_SHIFT) | (npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(npy_int32) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(npy_int32, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(npy_int32) - 1 > 4 * PyLong_SHIFT) {
                            return (npy_int32) ((((((((((npy_int32)digits[3]) << PyLong_SHIFT) | (npy_int32)digits[2]) << PyLong_SHIFT) | (npy_int32)digits[1]) << PyLong_SHIFT) | (npy_int32)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(npy_int32) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(npy_int32, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(npy_int32) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(npy_int32, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            npy_int32 val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(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 (npy_int32) -1;
        }
    } else {
        npy_int32 val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (npy_int32) -1;
        val = __Pyx_PyInt_As_npy_int32(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to npy_int32");
    return (npy_int32) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to npy_int32");
    return (npy_int32) -1;
}

/* CoroutineBase */
#include <structmember.h>
#include <frameobject.h>
#define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) {
    PyObject *et, *ev, *tb;
    PyObject *value = NULL;
    __Pyx_ErrFetch(&et, &ev, &tb);
    if (!et) {
        Py_XDECREF(tb);
        Py_XDECREF(ev);
        Py_INCREF(Py_None);
        *pvalue = Py_None;
        return 0;
    }
    if (likely(et == PyExc_StopIteration)) {
        if (!ev) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#if PY_VERSION_HEX >= 0x030300A0
        else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
            value = ((PyStopIterationObject *)ev)->value;
            Py_INCREF(value);
            Py_DECREF(ev);
        }
#endif
        else if (unlikely(PyTuple_Check(ev))) {
            if (PyTuple_GET_SIZE(ev) >= 1) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                value = PyTuple_GET_ITEM(ev, 0);
                Py_INCREF(value);
#else
                value = PySequence_ITEM(ev, 0);
#endif
            } else {
                Py_INCREF(Py_None);
                value = Py_None;
            }
            Py_DECREF(ev);
        }
        else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
            value = ev;
        }
        if (likely(value)) {
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = value;
            return 0;
        }
    } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    PyErr_NormalizeException(&et, &ev, &tb);
    if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    Py_XDECREF(tb);
    Py_DECREF(et);
#if PY_VERSION_HEX >= 0x030300A0
    value = ((PyStopIterationObject *)ev)->value;
    Py_INCREF(value);
    Py_DECREF(ev);
#else
    {
        PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
        Py_DECREF(ev);
        if (likely(args)) {
            value = PySequence_GetItem(args, 0);
            Py_DECREF(args);
        }
        if (unlikely(!value)) {
            __Pyx_ErrRestore(NULL, NULL, NULL);
            Py_INCREF(Py_None);
            value = Py_None;
        }
    }
#endif
    *pvalue = value;
    return 0;
}
static CYTHON_INLINE
void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) {
    PyObject *t, *v, *tb;
    t = exc_state->exc_type;
    v = exc_state->exc_value;
    tb = exc_state->exc_traceback;
    exc_state->exc_type = NULL;
    exc_state->exc_value = NULL;
    exc_state->exc_traceback = NULL;
    Py_XDECREF(t);
    Py_XDECREF(v);
    Py_XDECREF(tb);
}
#define __Pyx_Coroutine_AlreadyRunningError(gen)  (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
    const char *msg;
    if ((0)) {
    #ifdef __Pyx_Coroutine_USED
    } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
        msg = "coroutine already executing";
    #endif
    #ifdef __Pyx_AsyncGen_USED
    } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
        msg = "async generator already executing";
    #endif
    } else {
        msg = "generator already executing";
    }
    PyErr_SetString(PyExc_ValueError, msg);
}
#define __Pyx_Coroutine_NotStartedError(gen)  (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
    const char *msg;
    if ((0)) {
    #ifdef __Pyx_Coroutine_USED
    } else if (__Pyx_Coroutine_Check(gen)) {
        msg = "can't send non-None value to a just-started coroutine";
    #endif
    #ifdef __Pyx_AsyncGen_USED
    } else if (__Pyx_AsyncGen_CheckExact(gen)) {
        msg = "can't send non-None value to a just-started async generator";
    #endif
    } else {
        msg = "can't send non-None value to a just-started generator";
    }
    PyErr_SetString(PyExc_TypeError, msg);
}
#define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing)  (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL)
static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) {
    #ifdef __Pyx_Coroutine_USED
    if (!closing && __Pyx_Coroutine_Check(gen)) {
        PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
    } else
    #endif
    if (value) {
        #ifdef __Pyx_AsyncGen_USED
        if (__Pyx_AsyncGen_CheckExact(gen))
            PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
        else
        #endif
        PyErr_SetNone(PyExc_StopIteration);
    }
}
static
PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) {
    __Pyx_PyThreadState_declare
    PyThreadState *tstate;
    __Pyx_ExcInfoStruct *exc_state;
    PyObject *retval;
    assert(!self->is_running);
    if (unlikely(self->resume_label == 0)) {
        if (unlikely(value && value != Py_None)) {
            return __Pyx_Coroutine_NotStartedError((PyObject*)self);
        }
    }
    if (unlikely(self->resume_label == -1)) {
        return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
    }
#if CYTHON_FAST_THREAD_STATE
    __Pyx_PyThreadState_assign
    tstate = __pyx_tstate;
#else
    tstate = __Pyx_PyThreadState_Current;
#endif
    exc_state = &self->gi_exc_state;
    if (exc_state->exc_type) {
        #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
        #else
        if (exc_state->exc_traceback) {
            PyTracebackObject *tb = (PyTracebackObject *) exc_state->exc_traceback;
            PyFrameObject *f = tb->tb_frame;
            Py_XINCREF(tstate->frame);
            assert(f->f_back == NULL);
            f->f_back = tstate->frame;
        }
        #endif
    }
#if CYTHON_USE_EXC_INFO_STACK
    exc_state->previous_item = tstate->exc_info;
    tstate->exc_info = exc_state;
#else
    if (exc_state->exc_type) {
        __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
    } else {
        __Pyx_Coroutine_ExceptionClear(exc_state);
        __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
    }
#endif
    self->is_running = 1;
    retval = self->body((PyObject *) self, tstate, value);
    self->is_running = 0;
#if CYTHON_USE_EXC_INFO_STACK
    exc_state = &self->gi_exc_state;
    tstate->exc_info = exc_state->previous_item;
    exc_state->previous_item = NULL;
    __Pyx_Coroutine_ResetFrameBackpointer(exc_state);
#endif
    return retval;
}
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) {
    PyObject *exc_tb = exc_state->exc_traceback;
    if (likely(exc_tb)) {
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
#else
        PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
        PyFrameObject *f = tb->tb_frame;
        Py_CLEAR(f->f_back);
#endif
    }
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) {
    if (unlikely(!retval)) {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        if (!__Pyx_PyErr_Occurred()) {
            PyObject *exc = PyExc_StopIteration;
            #ifdef __Pyx_AsyncGen_USED
            if (__Pyx_AsyncGen_CheckExact(gen))
                exc = __Pyx_PyExc_StopAsyncIteration;
            #endif
            __Pyx_PyErr_SetNone(exc);
        }
    }
    return retval;
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
    PyObject *ret;
    PyObject *val = NULL;
    __Pyx_Coroutine_Undelegate(gen);
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
    ret = __Pyx_Coroutine_SendEx(gen, val, 0);
    Py_XDECREF(val);
    return ret;
}
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
    PyObject *retval;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_Check(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_AsyncGen_USED
        if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
            ret = __Pyx_async_gen_asend_send(yf, value);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyGen_CheckExact(yf)) {
            ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyCoro_CheckExact(yf)) {
            ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
        } else
        #endif
        {
            if (value == Py_None)
                ret = Py_TYPE(yf)->tp_iternext(yf);
            else
                ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
        }
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        retval = __Pyx_Coroutine_FinishDelegation(gen);
    } else {
        retval = __Pyx_Coroutine_SendEx(gen, value, 0);
    }
    return __Pyx_Coroutine_MethodReturn(self, retval);
}
static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
    PyObject *retval = NULL;
    int err = 0;
    #ifdef __Pyx_Generator_USED
    if (__Pyx_Generator_CheckExact(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    #endif
    #ifdef __Pyx_Coroutine_USED
    if (__Pyx_Coroutine_Check(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    if (__Pyx_CoroutineAwait_CheckExact(yf)) {
        retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf, NULL);
        if (!retval)
            return -1;
    } else
    #endif
    #ifdef __Pyx_AsyncGen_USED
    if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
        retval = __Pyx_async_gen_asend_close(yf, NULL);
    } else
    if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
        retval = __Pyx_async_gen_athrow_close(yf, NULL);
    } else
    #endif
    {
        PyObject *meth;
        gen->is_running = 1;
        meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close);
        if (unlikely(!meth)) {
            if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                PyErr_WriteUnraisable(yf);
            }
            PyErr_Clear();
        } else {
            retval = PyObject_CallFunction(meth, NULL);
            Py_DECREF(meth);
            if (!retval)
                err = -1;
        }
        gen->is_running = 0;
    }
    Py_XDECREF(retval);
    return err;
}
static PyObject *__Pyx_Generator_Next(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Generator_Next(yf);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyGen_CheckExact(yf)) {
            ret = _PyGen_Send((PyGenObject*)yf, NULL);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_Check(yf)) {
            ret = __Pyx_Coroutine_Send(yf, Py_None);
        } else
        #endif
            ret = Py_TYPE(yf)->tp_iternext(yf);
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        return __Pyx_Coroutine_FinishDelegation(gen);
    }
    return __Pyx_Coroutine_SendEx(gen, Py_None, 0);
}
static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, CYTHON_UNUSED PyObject *arg) {
    return __Pyx_Coroutine_Close(self);
}
static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *retval, *raised_exception;
    PyObject *yf = gen->yieldfrom;
    int err = 0;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        Py_INCREF(yf);
        err = __Pyx_Coroutine_CloseIter(gen, yf);
        __Pyx_Coroutine_Undelegate(gen);
        Py_DECREF(yf);
    }
    if (err == 0)
        PyErr_SetNone(PyExc_GeneratorExit);
    retval = __Pyx_Coroutine_SendEx(gen, NULL, 1);
    if (unlikely(retval)) {
        const char *msg;
        Py_DECREF(retval);
        if ((0)) {
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_Coroutine_Check(self)) {
            msg = "coroutine ignored GeneratorExit";
        #endif
        #ifdef __Pyx_AsyncGen_USED
        } else if (__Pyx_AsyncGen_CheckExact(self)) {
#if PY_VERSION_HEX < 0x03060000
            msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)";
#else
            msg = "async generator ignored GeneratorExit";
#endif
        #endif
        } else {
            msg = "generator ignored GeneratorExit";
        }
        PyErr_SetString(PyExc_RuntimeError, msg);
        return NULL;
    }
    raised_exception = PyErr_Occurred();
    if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) {
        if (raised_exception) PyErr_Clear();
        Py_INCREF(Py_None);
        return Py_None;
    }
    return NULL;
}
static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
                                        PyObject *args, int close_on_genexit) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        Py_INCREF(yf);
        if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
            int err = __Pyx_Coroutine_CloseIter(gen, yf);
            Py_DECREF(yf);
            __Pyx_Coroutine_Undelegate(gen);
            if (err < 0)
                return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
            goto throw_here;
        }
        gen->is_running = 1;
        if (0
        #ifdef __Pyx_Generator_USED
            || __Pyx_Generator_CheckExact(yf)
        #endif
        #ifdef __Pyx_Coroutine_USED
            || __Pyx_Coroutine_Check(yf)
        #endif
            ) {
            ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
            ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
        #endif
        } else {
            PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
            if (unlikely(!meth)) {
                Py_DECREF(yf);
                if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                    gen->is_running = 0;
                    return NULL;
                }
                PyErr_Clear();
                __Pyx_Coroutine_Undelegate(gen);
                gen->is_running = 0;
                goto throw_here;
            }
            if (likely(args)) {
                ret = PyObject_CallObject(meth, args);
            } else {
                ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
            }
            Py_DECREF(meth);
        }
        gen->is_running = 0;
        Py_DECREF(yf);
        if (!ret) {
            ret = __Pyx_Coroutine_FinishDelegation(gen);
        }
        return __Pyx_Coroutine_MethodReturn(self, ret);
    }
throw_here:
    __Pyx_Raise(typ, val, tb, NULL);
    return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
}
static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
    PyObject *typ;
    PyObject *val = NULL;
    PyObject *tb = NULL;
    if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
        return NULL;
    return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
}
static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) {
    Py_VISIT(exc_state->exc_type);
    Py_VISIT(exc_state->exc_value);
    Py_VISIT(exc_state->exc_traceback);
    return 0;
}
static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
    Py_VISIT(gen->closure);
    Py_VISIT(gen->classobj);
    Py_VISIT(gen->yieldfrom);
    return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg);
}
static int __Pyx_Coroutine_clear(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    Py_CLEAR(gen->closure);
    Py_CLEAR(gen->classobj);
    Py_CLEAR(gen->yieldfrom);
    __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
    }
#endif
    Py_CLEAR(gen->gi_code);
    Py_CLEAR(gen->gi_name);
    Py_CLEAR(gen->gi_qualname);
    Py_CLEAR(gen->gi_modulename);
    return 0;
}
static void __Pyx_Coroutine_dealloc(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject_GC_UnTrack(gen);
    if (gen->gi_weakreflist != NULL)
        PyObject_ClearWeakRefs(self);
    if (gen->resume_label >= 0) {
        PyObject_GC_Track(self);
#if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE
        if (PyObject_CallFinalizerFromDealloc(self))
#else
        Py_TYPE(gen)->tp_del(self);
        if (self->ob_refcnt > 0)
#endif
        {
            return;
        }
        PyObject_GC_UnTrack(self);
    }
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        /* We have to handle this case for asynchronous generators
           right here, because this code has to be between UNTRACK
           and GC_Del. */
        Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
    }
#endif
    __Pyx_Coroutine_clear(self);
    PyObject_GC_Del(gen);
}
static void __Pyx_Coroutine_del(PyObject *self) {
    PyObject *error_type, *error_value, *error_traceback;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    __Pyx_PyThreadState_declare
    if (gen->resume_label < 0) {
        return;
    }
#if !CYTHON_USE_TP_FINALIZE
    assert(self->ob_refcnt == 0);
    self->ob_refcnt = 1;
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
        PyObject *finalizer = agen->ag_finalizer;
        if (finalizer && !agen->ag_closed) {
            PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
            if (unlikely(!res)) {
                PyErr_WriteUnraisable(self);
            } else {
                Py_DECREF(res);
            }
            __Pyx_ErrRestore(error_type, error_value, error_traceback);
            return;
        }
    }
#endif
    if (unlikely(gen->resume_label == 0 && !error_value)) {
#ifdef __Pyx_Coroutine_USED
#ifdef __Pyx_Generator_USED
    if (!__Pyx_Generator_CheckExact(self))
#endif
        {
        PyObject_GC_UnTrack(self);
#if PY_MAJOR_VERSION >= 3  || defined(PyErr_WarnFormat)
        if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
            PyErr_WriteUnraisable(self);
#else
        {PyObject *msg;
        char *cmsg;
        #if CYTHON_COMPILING_IN_PYPY
        msg = NULL;
        cmsg = (char*) "coroutine was never awaited";
        #else
        char *cname;
        PyObject *qualname;
        qualname = gen->gi_qualname;
        cname = PyString_AS_STRING(qualname);
        msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname);
        if (unlikely(!msg)) {
            PyErr_Clear();
            cmsg = (char*) "coroutine was never awaited";
        } else {
            cmsg = PyString_AS_STRING(msg);
        }
        #endif
        if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
            PyErr_WriteUnraisable(self);
        Py_XDECREF(msg);}
#endif
        PyObject_GC_Track(self);
        }
#endif
    } else {
        PyObject *res = __Pyx_Coroutine_Close(self);
        if (unlikely(!res)) {
            if (PyErr_Occurred())
                PyErr_WriteUnraisable(self);
        } else {
            Py_DECREF(res);
        }
    }
    __Pyx_ErrRestore(error_type, error_value, error_traceback);
#if !CYTHON_USE_TP_FINALIZE
    assert(self->ob_refcnt > 0);
    if (--self->ob_refcnt == 0) {
        return;
    }
    {
        Py_ssize_t refcnt = self->ob_refcnt;
        _Py_NewReference(self);
        self->ob_refcnt = refcnt;
    }
#if CYTHON_COMPILING_IN_CPYTHON
    assert(PyType_IS_GC(self->ob_type) &&
           _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
    _Py_DEC_REFTOTAL;
#endif
#ifdef COUNT_ALLOCS
    --Py_TYPE(self)->tp_frees;
    --Py_TYPE(self)->tp_allocs;
#endif
#endif
}
static PyObject *
__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
{
    PyObject *name = self->gi_name;
    if (unlikely(!name)) name = Py_None;
    Py_INCREF(name);
    return name;
}
static int
__Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
{
    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 = self->gi_name;
    Py_INCREF(value);
    self->gi_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
{
    PyObject *name = self->gi_qualname;
    if (unlikely(!name)) name = Py_None;
    Py_INCREF(name);
    return name;
}
static int
__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
{
    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 = self->gi_qualname;
    Py_INCREF(value);
    self->gi_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static __pyx_CoroutineObject *__Pyx__Coroutine_New(
            PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
    if (unlikely(!gen))
        return NULL;
    return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
}
static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    gen->body = body;
    gen->closure = closure;
    Py_XINCREF(closure);
    gen->is_running = 0;
    gen->resume_label = 0;
    gen->classobj = NULL;
    gen->yieldfrom = NULL;
    gen->gi_exc_state.exc_type = NULL;
    gen->gi_exc_state.exc_value = NULL;
    gen->gi_exc_state.exc_traceback = NULL;
#if CYTHON_USE_EXC_INFO_STACK
    gen->gi_exc_state.previous_item = NULL;
#endif
    gen->gi_weakreflist = NULL;
    Py_XINCREF(qualname);
    gen->gi_qualname = qualname;
    Py_XINCREF(name);
    gen->gi_name = name;
    Py_XINCREF(module_name);
    gen->gi_modulename = module_name;
    Py_XINCREF(code);
    gen->gi_code = code;
    PyObject_GC_Track(gen);
    return gen;
}

/* PatchModuleWithCoroutine */
static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    int result;
    PyObject *globals, *result_obj;
    globals = PyDict_New();  if (unlikely(!globals)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_coroutine_type",
    #ifdef __Pyx_Coroutine_USED
        (PyObject*)__pyx_CoroutineType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_generator_type",
    #ifdef __Pyx_Generator_USED
        (PyObject*)__pyx_GeneratorType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
    result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
    if (unlikely(!result_obj)) goto ignore;
    Py_DECREF(result_obj);
    Py_DECREF(globals);
    return module;
ignore:
    Py_XDECREF(globals);
    PyErr_WriteUnraisable(module);
    if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
        Py_DECREF(module);
        module = NULL;
    }
#else
    py_code++;
#endif
    return module;
}

/* PatchGeneratorABC */
#ifndef CYTHON_REGISTER_ABCS
#define CYTHON_REGISTER_ABCS 1
#endif
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
static PyObject* __Pyx_patch_abc_module(PyObject *module);
static PyObject* __Pyx_patch_abc_module(PyObject *module) {
    module = __Pyx_Coroutine_patch_module(
        module, ""
"if _cython_generator_type is not None:\n"
"    try: Generator = _module.Generator\n"
"    except AttributeError: pass\n"
"    else: Generator.register(_cython_generator_type)\n"
"if _cython_coroutine_type is not None:\n"
"    try: Coroutine = _module.Coroutine\n"
"    except AttributeError: pass\n"
"    else: Coroutine.register(_cython_coroutine_type)\n"
    );
    return module;
}
#endif
static int __Pyx_patch_abc(void) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    static int abc_patched = 0;
    if (CYTHON_REGISTER_ABCS && !abc_patched) {
        PyObject *module;
        module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
        if (!module) {
            PyErr_WriteUnraisable(NULL);
            if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
                    ((PY_MAJOR_VERSION >= 3) ?
                        "Cython module failed to register with collections.abc module" :
                        "Cython module failed to register with collections module"), 1) < 0)) {
                return -1;
            }
        } else {
            module = __Pyx_patch_abc_module(module);
            abc_patched = 1;
            if (unlikely(!module))
                return -1;
            Py_DECREF(module);
        }
        module = PyImport_ImportModule("backports_abc");
        if (module) {
            module = __Pyx_patch_abc_module(module);
            Py_XDECREF(module);
        }
        if (!module) {
            PyErr_Clear();
        }
    }
#else
    if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL);
#endif
    return 0;
}

/* Generator */
static PyMethodDef __pyx_Generator_methods[] = {
    {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
     (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
    {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
     (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
    {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS,
     (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
    {0, 0, 0, 0}
};
static PyMemberDef __pyx_Generator_memberlist[] = {
    {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
    {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
     (char*) PyDoc_STR("object being iterated by 'yield from', or None")},
    {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
    {0, 0, 0, 0, 0}
};
static PyGetSetDef __pyx_Generator_getsets[] = {
    {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
     (char*) PyDoc_STR("name of the generator"), 0},
    {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
     (char*) PyDoc_STR("qualified name of the generator"), 0},
    {0, 0, 0, 0, 0}
};
static PyTypeObject __pyx_GeneratorType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "generator",
    sizeof(__pyx_CoroutineObject),
    0,
    (destructor) __Pyx_Coroutine_dealloc,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
    0,
    (traverseproc) __Pyx_Coroutine_traverse,
    0,
    0,
    offsetof(__pyx_CoroutineObject, gi_weakreflist),
    0,
    (iternextfunc) __Pyx_Generator_Next,
    __pyx_Generator_methods,
    __pyx_Generator_memberlist,
    __pyx_Generator_getsets,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if CYTHON_USE_TP_FINALIZE
    0,
#else
    __Pyx_Coroutine_del,
#endif
    0,
#if CYTHON_USE_TP_FINALIZE
    __Pyx_Coroutine_del,
#elif PY_VERSION_HEX >= 0x030400a1
    0,
#endif
};
static int __pyx_Generator_init(void) {
    __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
    __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
    __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
    if (unlikely(!__pyx_GeneratorType)) {
        return -1;
    }
    return 0;
}

/* CheckBinaryVersion */
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;
}

/* FunctionImport */
#ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C function %.200s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

/* InitStrings */
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;
        if (PyObject_Hash(*t->p) == -1)
            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 const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    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
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(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
#endif
static CYTHON_INLINE const 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)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    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 int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
    int retval;
    if (unlikely(!x)) return -1;
    retval = __Pyx_PyObject_IsTrue(x);
    Py_DECREF(x);
    return retval;
}
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type %.200s).  "
                "The ability to return an instance of a strict subclass of int "
                "is deprecated, and may be removed in a future version of Python.",
                Py_TYPE(result)->tp_name)) {
            Py_DECREF(result);
            return NULL;
        }
        return result;
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "__%.4s__ returned non-%.4s (type %.200s)",
                 type_name, type_name, Py_TYPE(result)->tp_name);
    Py_DECREF(result);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
  if (likely(PyLong_Check(x)))
#endif
    return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
  m = Py_TYPE(x)->tp_as_number;
  #if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = m->nb_int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = m->nb_long(x);
  }
  #else
  if (likely(m && m->nb_int)) {
    name = "int";
    res = m->nb_int(x);
  }
  #endif
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
    res = PyNumber_Int(x);
  }
#endif
  if (likely(res)) {
#if PY_MAJOR_VERSION < 3
    if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
    if (unlikely(!PyLong_CheckExact(res))) {
#endif
        return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
    }
  }
  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))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(b);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #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_PyBool_FromLong(long b) {
  return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
