Browse Source

Ignore exceptions during __del__ handlers, which may get called during shutdown

tags/nilmdb-1.10.0
Jim Paris 10 years ago
parent
commit
0a22db3965
2 changed files with 8 additions and 5 deletions
  1. +7
    -4
      nilmdb/utils/mustclose.py
  2. +1
    -1
      nilmdb/utils/serializer.py

+ 7
- 4
nilmdb/utils/mustclose.py View File

@@ -28,10 +28,13 @@ def must_close(errorfile = sys.stderr, wrap_verify = False):

@wrap_class_method
def __del__(orig, self, *args, **kwargs):
if "_must_close" in self.__dict__:
fprintf(errorfile, "error: %s.close() wasn't called!\n",
self.__class__.__name__)
return orig(self, *args, **kwargs)
try:
if "_must_close" in self.__dict__:
fprintf(errorfile, "error: %s.close() wasn't called!\n",
self.__class__.__name__)
return orig(self, *args, **kwargs)
except: # pragma: no cover
pass

@wrap_class_method
def close(orig, self, *args, **kwargs):


+ 1
- 1
nilmdb/utils/serializer.py View File

@@ -120,7 +120,7 @@ def serializer_proxy(obj_or_type):
try:
self.__call_queue.put((None, None, None, None))
self.__thread.join()
except TypeError: # pragma: no cover
except: # pragma: no cover
pass

return SerializerObjectProxy(obj_or_type)

Loading…
Cancel
Save