]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind: rados cleanup 7692/head
authorMehdi Abaakouk <sileht@redhat.com>
Thu, 18 Feb 2016 09:14:01 +0000 (10:14 +0100)
committerMehdi Abaakouk <sileht@redhat.com>
Thu, 18 Feb 2016 10:26:26 +0000 (11:26 +0100)
This change uses:
* a pystring to store ioctx state like other state attributes and like
  previous binding
* use __dealloc__ instead of __del__ to ensure Object are freed correctly

Signed-off-by: Mehdi Abaakouk <sileht@redhat.com>
src/pybind/rados/rados.pxd
src/pybind/rados/rados.pyx

index d9ca4b4e692474f16a5052debf8da4c0bf07e7f8..619543d685617537a822f9fcb81476eb32b94e03 100644 (file)
@@ -26,7 +26,7 @@ cdef class Ioctx(object):
     cdef:
         rados_ioctx_t io
         public char *name
-        public char *state
+        public object state
         public object locator_key
         public object nspace
 
index 81fd1dc21d2cca59a761e726e823e64d4d31009a..c6677586055c1f7b81ad1ca524d29e4ef10ea7e4 100644 (file)
@@ -1280,7 +1280,7 @@ cdef class OmapIterator(object):
     cdef public Ioctx ioctx
     cdef rados_omap_iter_t ctx
 
-    def __init__(self, Ioctx ioctx):
+    def __cinit__(self, Ioctx ioctx):
         self.ioctx = ioctx
 
     def __iter__(self):
@@ -1312,7 +1312,7 @@ cdef class OmapIterator(object):
             val = val_[:len_]
         return (key, val)
 
-    def __del__(self):
+    def __dealloc__(self):
         with nogil:
             rados_omap_get_end(self.ctx)
 
@@ -1362,7 +1362,7 @@ cdef class ObjectIterator(object):
         nspace = decode_cstr(nspace_) if nspace_ != NULL else None
         return Object(self.ioctx, key, locator, nspace)
 
-    def __del__(self):
+    def __dealloc__(self):
         with nogil:
             rados_nobjects_list_close(self.ctx)
 
@@ -1415,7 +1415,7 @@ in '%s'" % self.oid)
         val = val_[:len_]
         return (name, val)
 
-    def __del__(self):
+    def __dealloc__(self):
         with nogil:
             rados_getxattrs_end(self.it)
 
@@ -1616,7 +1616,7 @@ cdef class Completion(object):
             ret = rados_aio_get_return_value(self.rados_comp)
         return ret
 
-    def __del__(self):
+    def __dealloc__(self):
         """
         Release a completion
 
@@ -2120,7 +2120,7 @@ cdef class Ioctx(object):
         requests on it, but you should not use an io context again after
         calling this function on it.
         """
-        if self.state == b"open":
+        if self.state == "open":
             self.require_ioctx_open()
             with nogil:
                 rados_ioctx_destroy(self.io)