Commit 4324fad0 authored by Jason Madden's avatar Jason Madden

Minor cleanups and comments during debugging of #1126

parent 0d12a273
...@@ -223,8 +223,7 @@ class AbstractCallbacks(object): ...@@ -223,8 +223,7 @@ class AbstractCallbacks(object):
# NOTE: Raising exceptions here does nothing, they're swallowed by CFFI. # NOTE: Raising exceptions here does nothing, they're swallowed by CFFI.
# Since the C level passed in a null pointer, even dereferencing the handle # Since the C level passed in a null pointer, even dereferencing the handle
# will just produce some exceptions. # will just produce some exceptions.
if GEVENT_DEBUG_LEVEL < CRITICAL: return
return
_dbg("python_stop: stopping watcher with handle", handle) _dbg("python_stop: stopping watcher with handle", handle)
watcher = self.from_handle(handle) watcher = self.from_handle(handle)
watcher.stop() watcher.stop()
......
...@@ -157,15 +157,15 @@ def wait(io, timeout=None, timeout_exc=_NONE): ...@@ -157,15 +157,15 @@ def wait(io, timeout=None, timeout_exc=_NONE):
""" """
if io.callback is not None: if io.callback is not None:
raise ConcurrentObjectUseError('This socket is already used by another greenlet: %r' % (io.callback, )) raise ConcurrentObjectUseError('This socket is already used by another greenlet: %r' % (io.callback, ))
if timeout is not None: timeout = Timeout._start_new_or_dummy(
timeout_exc = timeout_exc if timeout_exc is not _NONE else _timeout_error('timed out') timeout,
timeout = Timeout.start_new(timeout, timeout_exc) (timeout_exc
if timeout_exc is not _NONE or timeout is None
else _timeout_error('timed out')))
try:
with timeout:
return get_hub().wait(io) return get_hub().wait(io)
finally:
if timeout is not None:
timeout.cancel()
# rename "io" to "watcher" because wait() works with any watcher # rename "io" to "watcher" because wait() works with any watcher
......
...@@ -164,6 +164,8 @@ typedef struct uv_fs_event_s uv_fs_event_t; ...@@ -164,6 +164,8 @@ typedef struct uv_fs_event_s uv_fs_event_t;
typedef struct uv_fs_poll_s uv_fs_poll_t; typedef struct uv_fs_poll_s uv_fs_poll_t;
size_t uv_handle_size(uv_handle_type);
// callbacks with the same signature // callbacks with the same signature
// XXX: Note that these, and all callbacks, are defined to take // XXX: Note that these, and all callbacks, are defined to take
// a void* or handle* instead of the more specific, correct, // a void* or handle* instead of the more specific, correct,
...@@ -338,6 +340,8 @@ int uv_fs_poll_start(void*, uv_fs_poll_cb, const char* path, unsigned int); ...@@ -338,6 +340,8 @@ int uv_fs_poll_start(void*, uv_fs_poll_cb, const char* path, unsigned int);
int uv_fs_poll_stop(void*); int uv_fs_poll_stop(void*);
/* Standard library */
void* memset(void *b, int c, size_t len);
/* gevent callbacks */ /* gevent callbacks */
......
#include <string.h>
#include "uv.h" #include "uv.h"
static int python_callback(void* handle, int revents); static int python_callback(void* handle, int revents);
......
...@@ -120,7 +120,7 @@ class watcher(_base.watcher): ...@@ -120,7 +120,7 @@ class watcher(_base.watcher):
# Instead, this is arranged as a callback to GC when the # Instead, this is arranged as a callback to GC when the
# watcher class dies. Obviously it's important to keep the ffi # watcher class dies. Obviously it's important to keep the ffi
# watcher alive. # watcher alive.
_dbg("Request to close handle", ffi_watcher) _dbg("Request to close handle", ffi.cast('void*', ffi_watcher), ffi_watcher)
# We can pass in "subclasses" if uv_handle_t that line up at the C level, # We can pass in "subclasses" if uv_handle_t that line up at the C level,
# but that don't in CFFI without a cast. But be careful what we use the cast # but that don't in CFFI without a cast. But be careful what we use the cast
# for, don't pass it back to C. # for, don't pass it back to C.
...@@ -725,7 +725,6 @@ class idle(_base.IdleMixin, watcher): ...@@ -725,7 +725,6 @@ class idle(_base.IdleMixin, watcher):
class check(_base.CheckMixin, watcher): class check(_base.CheckMixin, watcher):
pass pass
class OneShotCheck(check): class OneShotCheck(check):
_watcher_skip_ffi = True _watcher_skip_ffi = True
...@@ -733,8 +732,8 @@ class OneShotCheck(check): ...@@ -733,8 +732,8 @@ class OneShotCheck(check):
def __make_cb(self, func): def __make_cb(self, func):
stop = self.stop stop = self.stop
@functools.wraps(func) @functools.wraps(func)
def cb(*args, _stop=stop): def cb(*args):
_stop() stop()
return func(*args) return func(*args)
return cb return cb
......
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