Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
045afd00
Commit
045afd00
authored
Jan 22, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drop use of LOOP_PROPERTY and update all the deprecated property: syntax to @property
parent
dc75cf9d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
128 additions
and
133 deletions
+128
-133
src/gevent/libev/corecext.ppyx
src/gevent/libev/corecext.ppyx
+128
-133
No files found.
src/gevent/libev/corecext.ppyx
View file @
045afd00
...
@@ -253,12 +253,6 @@ cdef bint _check_loop(loop loop) except -1:
...
@@ -253,12 +253,6 @@ cdef bint _check_loop(loop loop) except -1:
raise ValueError('operation on destroyed loop')
raise ValueError('operation on destroyed loop')
return 1
return 1
#define LOOP_PROPERTY(NAME) property NAME: \
\
def __get__(self): \
_check_loop(self) \
return self._ptr.NAME
cdef bint _default_loop_destroyed = False
cdef bint _default_loop_destroyed = False
...
@@ -577,25 +571,34 @@ cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]:
...
@@ -577,25 +571,34 @@ cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]:
if fd >= 0:
if fd >= 0:
return fd
return fd
LOOP_PROPERTY(activecnt)
@property
def activecnt(self):
_check_loop(self)
return self._ptr.activecnt
@property
def sig_pending(self):
_check_loop(self)
return self._ptr.sig_pending
LOOP_PROPERTY(sig_pending)
#if EV_USE_SIGNALFD
#if EV_USE_SIGNALFD
LOOP_PROPERTY(sigfd)
@property
#endif
def sigfd(self):
_check_loop(self)
property origflags:
return self._ptr.sigfd
def __get__(self):
#endif
_check_loop(self)
return _flags_to_list(self._ptr.origflags)
property origflags_int:
@property
def origflags(self):
_check_loop(self)
return _flags_to_list(self._ptr.origflags)
def __get__(self):
@property
_check_loop(self)
def origflags_int(self):
return self._ptr.origflags
_check_loop(self)
return self._ptr.origflags
#endif
#endif
...
@@ -623,10 +626,9 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
...
@@ -623,10 +626,9 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
# it's nonzero if it's pending or currently executing
# it's nonzero if it's pending or currently executing
return self.args is not None
return self.args is not None
property pending:
@property
def pending(self):
def __get__(self):
return self.callback is not None
return self.callback is not None
def __repr__(self):
def __repr__(self):
if Py_ReprEnter(<PyObjectPtr>self) != 0:
if Py_ReprEnter(<PyObjectPtr>self) != 0:
...
@@ -670,36 +672,36 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
...
@@ -670,36 +672,36 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
cdef readonly int _flags \
cdef readonly int _flags \
cdef libev.ev_##TYPE _watcher \
cdef libev.ev_##TYPE _watcher \
\
\
property ref:
\
@property
\
\
def ref(self):
\
def __get__(self):
\
return False if self._flags & 4 else True
\
return False if self._flags & 4 else True
\
\
\
@ref.setter
\
def __set__(self, object value):
\
def ref(self, object value):
\
_check_loop(self.loop) \
_check_loop(self.loop) \
if value: \
if value: \
if not self._flags & 4: \
if not self._flags & 4: \
return # ref is already True \
return # ref is already True \
if self._flags & 2: # ev_unref was called, undo \
if self._flags & 2: # ev_unref was called, undo \
libev.ev_ref(self.loop._ptr) \
libev.ev_ref(self.loop._ptr) \
self._flags &= ~6 # do not want unref, no outstanding unref \
self._flags &= ~6 # do not want unref, no outstanding unref \
else: \
else: \
if self._flags & 4: \
if self._flags & 4: \
return # ref is already False \
return # ref is already False \
self._flags |= 4 \
self._flags |= 4 \
if not self._flags & 2 and libev.ev_is_active(&self._watcher): \
if not self._flags & 2 and libev.ev_is_active(&self._watcher): \
libev.ev_unref(self.loop._ptr) \
libev.ev_unref(self.loop._ptr) \
self._flags |= 2 \
self._flags |= 2 \
\
\
property callback:
\
@property
\
\
def callback(self):
\
def __get__(self):
\
return self._callback
\
return self._callback
\
\
\
@callback.setter
\
def __set__(self, object callback):
\
def callback(self, object callback):
\
if not PyCallable_Check(<PyObjectPtr>callback) and callback is not None: \
if not PyCallable_Check(<PyObjectPtr>callback) and callback is not None: \
raise TypeError("Expected callable, not %r" % (callback, )) \
raise TypeError("Expected callable, not %r" % (callback, )) \
self._callback = callback \
self._callback = callback \
\
\
def stop(self): \
def stop(self): \
_check_loop(self.loop) \
_check_loop(self.loop) \
...
@@ -713,15 +715,15 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
...
@@ -713,15 +715,15 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
Py_DECREF(<PyObjectPtr>self) \
Py_DECREF(<PyObjectPtr>self) \
self._flags &= ~1 \
self._flags &= ~1 \
\
\
property priority: \
@property \
def priority(self): \
return libev.ev_priority(&self._watcher) \
\
\
def __get__(self): \
@priority.setter \
return libev.ev_priority(&self._watcher) \
def priority(self, int priority): \
\
if libev.ev_is_active(&self._watcher): \
def __set__(self, int priority): \
raise AttributeError("Cannot set priority of an active watcher") \
if libev.ev_is_active(&self._watcher): \
libev.ev_set_priority(&self._watcher, priority) \
raise AttributeError("Cannot set priority of an active watcher") \
libev.ev_set_priority(&self._watcher, priority) \
\
\
def feed(self, int revents, object callback, *args): \
def feed(self, int revents, object callback, *args): \
_check_loop(self.loop) \
_check_loop(self.loop) \
...
@@ -731,10 +733,10 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
...
@@ -731,10 +733,10 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) \
libev.ev_feed_event(self.loop._ptr, &self._watcher, revents) \
PYTHON_INCREF
PYTHON_INCREF
#define ACTIVE
property active:
\
#define ACTIVE \
\
@property
\
def __get__
(self): \
def active
(self): \
return True if libev.ev_is_active(&self._watcher) else False
return True if libev.ev_is_active(&self._watcher) else False
#define START(TYPE) def start(self, object callback, *args): \
#define START(TYPE) def start(self, object callback, *args): \
_check_loop(self.loop) \
_check_loop(self.loop) \
...
@@ -748,10 +750,9 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
...
@@ -748,10 +750,9 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
#define PENDING \
#define PENDING \
property pending: \
@property \
\
def pending(self): \
def __get__(self): \
return True if libev.ev_is_pending(&self._watcher) else False
return True if libev.ev_is_pending(&self._watcher) else False
...
@@ -870,32 +871,31 @@ cdef public class io(watcher) [object PyGeventIOObject, type PyGeventIO_Type]:
...
@@ -870,32 +871,31 @@ cdef public class io(watcher) [object PyGeventIOObject, type PyGeventIO_Type]:
#endif
#endif
property fd:
@property
def fd(self):
def __get__(self):
return libev.vfd_get(self._watcher.fd)
return libev.vfd_get(self._watcher.fd)
def __set__(self, long fd):
if libev.ev_is_active(&self._watcher):
raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active")
cdef int vfd = libev.vfd_open(fd)
libev.vfd_free(self._watcher.fd)
libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, vfd, self._watcher.events)
property events:
def __get__(self):
@fd.setter
return self._watcher.events
def fd(self, long fd):
if libev.ev_is_active(&self._watcher):
raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active")
cdef int vfd = libev.vfd_open(fd)
libev.vfd_free(self._watcher.fd)
libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, vfd, self._watcher.events)
def __set__(self, int events):
@property
if libev.ev_is_active(&self._watcher):
def events(self):
raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active")
return self._watcher.events
libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, self._watcher.fd, events)
property events_str:
@events.setter
def events(self, int events):
if libev.ev_is_active(&self._watcher):
raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active")
libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, self._watcher.fd, events)
def __get__(self):
@property
return _events_to_str(self._watcher.events)
def events_str(self):
return _events_to_str(self._watcher.events)
def _format(self):
def _format(self):
return ' fd=%s events=%s' % (self.fd, self.events_str)
return ' fd=%s events=%s' % (self.fd, self.events_str)
...
@@ -947,10 +947,9 @@ cdef public class timer(watcher) [object PyGeventTimerObject, type PyGeventTimer
...
@@ -947,10 +947,9 @@ cdef public class timer(watcher) [object PyGeventTimerObject, type PyGeventTimer
if priority is not None:
if priority is not None:
libev.ev_set_priority(&self._watcher, priority)
libev.ev_set_priority(&self._watcher, priority)
property at:
@property
def at(self):
def __get__(self):
return self._watcher.at
return self._watcher.at
# QQQ: add 'after' and 'repeat' properties?
# QQQ: add 'after' and 'repeat' properties?
...
@@ -1023,10 +1022,10 @@ cdef public class async_(watcher) [object PyGeventAsyncObject, type PyGeventAsyn
...
@@ -1023,10 +1022,10 @@ cdef public class async_(watcher) [object PyGeventAsyncObject, type PyGeventAsyn
ACTIVE
ACTIVE
property pending:
@property
def pending(self):
def __get__(self):
# Note the use of ev_async_pending instead of ev_is_pending
return True if libev.ev_async_pending(&self._watcher) else False
return True if libev.ev_async_pending(&self._watcher) else False
INIT(async,,)
INIT(async,,)
...
@@ -1057,26 +1056,25 @@ cdef public class child(watcher) [object PyGeventChildObject, type PyGeventChild
...
@@ -1057,26 +1056,25 @@ cdef public class child(watcher) [object PyGeventChildObject, type PyGeventChild
def _format(self):
def _format(self):
return ' pid=%r rstatus=%r' % (self.pid, self.rstatus)
return ' pid=%r rstatus=%r' % (self.pid, self.rstatus)
property pid:
@property
def pid(self):
def __get__(self):
return self._watcher.pid
return self._watcher.pid
property rpid:
def __get__(self):
return self._watcher.rpid
def __set__(self, int value):
@property
self._watcher.rpid = value
def rpid(self):
return self._watcher.rpid
property rstatus:
@rpid.setter
def rpid(self, int value):
self._watcher.rpid = value
def __get__(self):
@property
return self._watcher.rstatus
def rstatus(self):
return self._watcher.rstatus
def __set__(self, int value):
@rstatus.setter
self._watcher.rstatus = value
def rstatus(self, int value):
self._watcher.rstatus = value
#endif
#endif
...
@@ -1108,24 +1106,21 @@ cdef public class stat(watcher) [object PyGeventStatObject, type PyGeventStat_Ty
...
@@ -1108,24 +1106,21 @@ cdef public class stat(watcher) [object PyGeventStatObject, type PyGeventStat_Ty
if priority is not None:
if priority is not None:
libev.ev_set_priority(&self._watcher, priority)
libev.ev_set_priority(&self._watcher, priority)
property attr:
@property
def attr(self):
def __get__(self):
if not self._watcher.attr.st_nlink:
if not self._watcher.attr.st_nlink:
return
return
return _pystat_fromstructstat(&self._watcher.attr)
return _pystat_fromstructstat(&self._watcher.attr)
@property
property prev:
def prev(self):
if not self._watcher.prev.st_nlink:
def __get__(self):
return
if not self._watcher.prev.st_nlink:
return _pystat_fromstructstat(&self._watcher.prev)
return
return _pystat_fromstructstat(&self._watcher.prev)
@property
def interval(self):
property interval:
return self._watcher.interval
def __get__(self):
return self._watcher.interval
__SYSERR_CALLBACK = None
__SYSERR_CALLBACK = None
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment