Commit 21ff90c5 authored by Denis Bilenko's avatar Denis Bilenko

gevent.core: loop() and dispatch() now raise IOError if corresponding libevent...

gevent.core: loop() and dispatch() now raise IOError if corresponding libevent functions return an error
parent af7c042b
...@@ -34,9 +34,6 @@ cdef extern from "libevent-internal.h": ...@@ -34,9 +34,6 @@ cdef extern from "libevent-internal.h":
cdef extern from "sys/types.h": cdef extern from "sys/types.h":
ctypedef unsigned char u_char ctypedef unsigned char u_char
cdef extern from "stdio.h":
void perror(char *s)
cdef extern from "Python.h": cdef extern from "Python.h":
void Py_INCREF(object o) void Py_INCREF(object o)
void Py_DECREF(object o) void Py_DECREF(object o)
...@@ -72,6 +69,12 @@ cdef extern from "event.h": ...@@ -72,6 +69,12 @@ cdef extern from "event.h":
int EVLOOP_NONBLOCK int EVLOOP_NONBLOCK
char* _EVENT_VERSION char* _EVENT_VERSION
cdef extern from "string.h":
char* strerror(int errnum)
cdef extern from "errno.h":
int errno
IF EVENT_INTERNAL_AVAILABLE: IF EVENT_INTERNAL_AVAILABLE:
cdef extern from "libevent-internal.h": cdef extern from "libevent-internal.h":
...@@ -259,7 +262,7 @@ def dispatch(): ...@@ -259,7 +262,7 @@ def dispatch():
with nogil: with nogil:
ret = event_dispatch() ret = event_dispatch()
if ret < 0: if ret < 0:
perror("event_dispatch failed") raise IOError(errno, strerror(errno))
return ret return ret
def loop(nonblock=False): def loop(nonblock=False):
...@@ -272,7 +275,7 @@ def loop(nonblock=False): ...@@ -272,7 +275,7 @@ def loop(nonblock=False):
with nogil: with nogil:
ret = event_loop(flags) ret = event_loop(flags)
if ret < 0: if ret < 0:
perror("event_loop failed") raise IOError(errno, strerror(errno))
return ret return ret
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment