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

Minor cleanups and comments during debugging of #1126

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