Skip to content

Commit

Permalink
pybind: rados cleanup
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Mehdi Abaakouk committed Feb 18, 2016
1 parent 037852e commit b32c4cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/pybind/rados/rados.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions src/pybind/rados/rados.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b32c4cf

Please sign in to comment.