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
Show 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,23 +571,32 @@ cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]:
...
@@ -577,23 +571,32 @@ 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)
return self._ptr.sigfd
property origflags:
#endif
def __get__(self):
@property
def origflags(self):
_check_loop(self)
_check_loop(self)
return _flags_to_list(self._ptr.origflags)
return _flags_to_list(self._ptr.origflags)
property origflags_int:
@property
def origflags_int(self):
def __get__(self):
_check_loop(self)
_check_loop(self)
return self._ptr.origflags
return self._ptr.origflags
...
@@ -623,9 +626,8 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
...
@@ -623,9 +626,8 @@ 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):
...
@@ -670,12 +672,12 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
...
@@ -670,12 +672,12 @@ 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 \
\
\
def __set__(self, object value): \
@ref.setter \
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: \
...
@@ -691,12 +693,12 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
...
@@ -691,12 +693,12 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
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 \
\
\
def __set__(self, object callback): \
@callback.setter \
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 \
...
@@ -713,12 +715,12 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
...
@@ -713,12 +715,12 @@ 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): \
def __get__(self): \
return libev.ev_priority(&self._watcher) \
return libev.ev_priority(&self._watcher) \
\
\
def __set__(self, int priority): \
@priority.setter \
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") \
libev.ev_set_priority(&self._watcher, priority) \
libev.ev_set_priority(&self._watcher, priority) \
...
@@ -731,9 +733,9 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
...
@@ -731,9 +733,9 @@ 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): \
...
@@ -748,9 +750,8 @@ cdef public class callback [object PyGeventCallbackObject, type PyGeventCallback
...
@@ -748,9 +750,8 @@ 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,31 +871,30 @@ cdef public class io(watcher) [object PyGeventIOObject, type PyGeventIO_Type]:
...
@@ -870,31 +871,30 @@ 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):
@fd.setter
def fd(self, long fd):
if libev.ev_is_active(&self._watcher):
if libev.ev_is_active(&self._watcher):
raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active")
raise AttributeError("'io' watcher attribute 'fd' is read-only while watcher is active")
cdef int vfd = libev.vfd_open(fd)
cdef int vfd = libev.vfd_open(fd)
libev.vfd_free(self._watcher.fd)
libev.vfd_free(self._watcher.fd)
libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, vfd, self._watcher.events)
libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, vfd, self._watcher.events)
property events:
@property
def events(self):
def __get__(self):
return self._watcher.events
return self._watcher.events
def __set__(self, int events):
@events.setter
def events(self, int events):
if libev.ev_is_active(&self._watcher):
if libev.ev_is_active(&self._watcher):
raise AttributeError("'io' watcher attribute 'events' is read-only while watcher is active")
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)
libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, self._watcher.fd, events)
property events_str:
@property
def events_str(self):
def __get__(self):
return _events_to_str(self._watcher.events)
return _events_to_str(self._watcher.events)
def _format(self):
def _format(self):
...
@@ -947,9 +947,8 @@ cdef public class timer(watcher) [object PyGeventTimerObject, type PyGeventTimer
...
@@ -947,9 +947,8 @@ 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,9 +1022,9 @@ cdef public class async_(watcher) [object PyGeventAsyncObject, type PyGeventAsyn
...
@@ -1023,9 +1022,9 @@ 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,25 +1056,24 @@ cdef public class child(watcher) [object PyGeventChildObject, type PyGeventChild
...
@@ -1057,25 +1056,24 @@ 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:
@property
def rpid(self):
def __get__(self):
return self._watcher.rpid
return self._watcher.rpid
def __set__(self, int value):
@rpid.setter
def rpid(self, int value):
self._watcher.rpid = value
self._watcher.rpid = value
property rstatus:
@property
def rstatus(self):
def __get__(self):
return self._watcher.rstatus
return self._watcher.rstatus
def __set__(self, int value):
@rstatus.setter
def rstatus(self, int value):
self._watcher.rstatus = value
self._watcher.rstatus = value
#endif
#endif
...
@@ -1108,23 +1106,20 @@ cdef public class stat(watcher) [object PyGeventStatObject, type PyGeventStat_Ty
...
@@ -1108,23 +1106,20 @@ 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 prev:
@property
def prev(self):
def __get__(self):
if not self._watcher.prev.st_nlink:
if not self._watcher.prev.st_nlink:
return
return
return _pystat_fromstructstat(&self._watcher.prev)
return _pystat_fromstructstat(&self._watcher.prev)
property interval:
@property
def interval(self):
def __get__(self):
return self._watcher.interval
return self._watcher.interval
...
...
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