Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rados.py: remove Rados.__del__(); it just causes problems #3119

Merged
2 commits merged into from
Dec 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions PendingReleaseNotes
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ v0.90

* The 'rados create <objectname> [category]' optional category argument is no
longer supported or recognized.

* rados.py's Rados class no longer has a __del__ method; it was causing
problems on interpreter shutdown and use of threads. If your code has
Rados objects with limited lifetimes and you're concerned about locked
resources, call Rados.shutdown() explicitly.
6 changes: 5 additions & 1 deletion src/ceph.in
Original file line number Diff line number Diff line change
Expand Up @@ -877,4 +877,8 @@ def main():
return 0

if __name__ == '__main__':
sys.exit(main())
retval = main()
# shutdown explicitly; Rados() does not
if cluster_handle:
cluster_handle.shutdown()
sys.exit(retval)
8 changes: 3 additions & 5 deletions src/pybind/rados.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ def __init__(self, rados_id=None, name=None, clustername=None,

def shutdown(self):
"""
Disconnects from the cluster.
Disconnects from the cluster. Call this explicitly when a
Rados.connect()ed object is no longer used.
"""
if (self.__dict__.has_key("state") and self.state != "shutdown"):
run_in_thread(self.librados.rados_shutdown, (self.cluster,))
Expand All @@ -273,9 +274,6 @@ def __exit__(self, type_, value, traceback):
self.shutdown()
return False

def __del__(self):
self.shutdown()

def version(self):
"""
Get the version number of the ``librados`` C library.
Expand Down Expand Up @@ -424,7 +422,7 @@ def ping_monitor(self, mon_id):

def connect(self, timeout=0):
"""
Connect to the cluster.
Connect to the cluster. Use shutdown() to release resources.
"""
self.require_state("configuring")
ret = run_in_thread(self.librados.rados_connect, (self.cluster,),
Expand Down