It's strongly recommended for objects that have references to
external resources (e.g., files) to explicitly release them.
Python doesn't guarantee garbage collection of objects and hence
doesn't guarantee freeing of external resources that occur on
garbage collection.
The __del__() methods in the python mgr modules may not even be
called since garbage collection of objects is not guaranteed in python.
And some of the __del__() methods try to cleanup that seem redundant.
- In volumes/module.py, vc.shutdown() is called in Module.shutdown().
No need to call it again in Module.__del__()
- In telegraf/basesocket.py, BaseSocker.close() is called in
BaseSocket.__exit__(). No need to call it again in
BaseSocket.__del__().
- In mgr_module.py, MgrModuleLoggingMixin._unconfigure_logging() is
called in MgrModule.__init__() and MgrStandbyModule.__init__(). No
need to call it in MgrModule.__del__() and
MgrStandbyModule.__del__().|
- In dashboard/services/cephfs.py, the libcephfs mount is not
shutdown explicitly by the mgr module. However, the cython libcephfs
bindings has a LibCephFS.__dealloc__() finalizer method that calls
LibCephFS.shutdown(). This should unmount and cleanup the ceph mount
handle.
Remove the __del__() of the python mgr modules.
Fixes: https://tracker.ceph.com/issues/63421
Signed-off-by: Ramana Raja <rraja@redhat.com>
self.cfs.mount()
logger.debug("mounted cephfs filesystem")
- def __del__(self):
- logger.debug("shutting down cephfs filesystem")
- self.cfs.shutdown()
-
@contextmanager
def opendir(self, dirpath):
d = None
# for backwards compatibility
self._logger = self.getLogger()
- def __del__(self) -> None:
- self._cleanup()
- self._unconfigure_logging()
-
- def _cleanup(self) -> None:
- pass
-
@classmethod
def _register_options(cls, module_name: str) -> None:
cls.MODULE_OPTIONS.append(
self._db_lock = threading.Lock()
- def __del__(self) -> None:
- self._unconfigure_logging()
-
@classmethod
def _register_options(cls, module_name: str) -> None:
cls.MODULE_OPTIONS.append(
def send(self, data: str, flags: int = 0) -> int:
return self.sock.send(data.encode('utf-8') + b'\n', flags)
- def __del__(self) -> None:
- self.sock.close()
-
def __enter__(self) -> 'BaseSocket':
self.connect()
return self
self.vc = VolumeClient(self)
self.inited = True
- def __del__(self):
- self.vc.shutdown()
-
def shutdown(self):
self.vc.shutdown()