Commits

Denis Bilenko  committed 85c3909

add 'backend_fd', 'fdchangecnt', 'timercnt' properties to loop

  • Participants
  • Parent commits 42292da

Comments (0)

Files changed (2)

File gevent/core_.pyx

     return libev.ev_time()
 
 
+m4_define(LOOP_PROPERTY, ``property $1:
+
+        def __get__(self):
+            return self._ptr.$1'')
+
+
 cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]:
     cdef libev.ev_loop* _ptr
     cdef public object error_handler
         libev.ev_now_update(self._ptr)
 
     def __repr__(self):
-        args = (self.__class__.__name__, id(self), self.default, self.backend)
-        result = '<%s at 0x%x default=%r backend=%r' % args
-#ifdef EV_STANDALONE
-        result += ' activecnt=%r' % self.activecnt
-#endif
+        result = '<%s at 0x%x' % (self.__class__.__name__, id(self))
+        result += self._format()
         return result + '>'
 
     property default:
                     return value
             return backend
 
-#ifdef EV_STANDALONE
-    property activecnt:
-
-        def __get__(self):
-            return self._ptr.activecnt
-#endif
-
     def io(self, int fd, int events, ref=True):
         return io(self, fd, events, ref)
 
         result.start(func, *args)
         return result
 
+#ifdef EV_STANDALONE
+    def _format(self):
+        args = (self.default, self.backend, self.activecnt, self.backend_fd, self.fdchangecnt, self.timercnt)
+        return  ' default=%r backend=%r activecnt=%r backend_fd=%r fdchangecnt=%r timercnt=%r' % args
+#else
+    def _format(self):
+        args = (self.default, self.backend)
+        return  ' default=%r backend=%r' % args
+#endif
+
+#ifdef EV_STANDALONE
+    LOOP_PROPERTY(activecnt)
+    LOOP_PROPERTY(backend_fd)
+    LOOP_PROPERTY(fdchangecnt)
+    LOOP_PROPERTY(timercnt)
+#endif
+
+
 m4_define(PYTHON_INCREF, ``if not self._flags & 1:
             Py_INCREF(<PyObjectPtr>self)
             self._flags |= 1'')m4_dnl

File gevent/libev.pxd

 
     struct ev_loop:
         int activecnt
+        int backend_fd
+        int fdchangecnt
+        int timercnt
 
     struct ev_io:
         int fd