Commit 5ce46ef5 authored by Jason Madden's avatar Jason Madden

Move the callback property to watcher.

parent cdc1d6dd
...@@ -668,16 +668,7 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback ...@@ -668,16 +668,7 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
#define WATCHER_BASE(TYPE) \ #define WATCHER_BASE(TYPE) \
cdef libev.ev_##TYPE _watcher \ cdef libev.ev_##TYPE _watcher \
\ \
\ \
@property \
def callback(self): \
return self._callback \
\
@callback.setter \
def callback(self, object callback): \
if not PyCallable_Check(<PyObjectPtr>callback) and callback is not None: \
raise TypeError("Expected callable, not %r" % (callback, )) \
self._callback = callback \
\ \
def stop(self): \ def stop(self): \
_check_loop(self.loop) \ _check_loop(self.loop) \
...@@ -691,11 +682,11 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback ...@@ -691,11 +682,11 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
Py_DECREF(<PyObjectPtr>self) \ Py_DECREF(<PyObjectPtr>self) \
self._flags &= ~1 \ self._flags &= ~1 \
\ \
@property \ @property \
def priority(self): \ def priority(self): \
return libev.ev_priority(&self._watcher) \ return libev.ev_priority(&self._watcher) \
\ \
@priority.setter \ @priority.setter \
def priority(self, int priority): \ def priority(self, int priority): \
if libev.ev_is_active(&self._watcher): \ if libev.ev_is_active(&self._watcher): \
raise AttributeError("Cannot set priority of an active watcher") \ raise AttributeError("Cannot set priority of an active watcher") \
...@@ -784,6 +775,15 @@ cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Ty ...@@ -784,6 +775,15 @@ cdef public class watcher [object PyGeventWatcherObject, type PyGeventWatcher_Ty
libev.ev_unref(self.loop._ptr) libev.ev_unref(self.loop._ptr)
self._flags |= 2 self._flags |= 2
@property
def callback(self):
return self._callback
@callback.setter
def callback(self, object callback):
if callback is not None and not callable(callback):
raise TypeError("Expected callable, not %r" % (callback, ))
self._callback = callback
def __repr__(self): def __repr__(self):
if Py_ReprEnter(<PyObjectPtr>self) != 0: if Py_ReprEnter(<PyObjectPtr>self) != 0:
......
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