MCPcopy Create free account
hub / github.com/PyTables/PyTables / _f_close

Method _f_close

tables/node.py:467–503  ·  view source on GitHub ↗

Close this node in the tree. This releases all resources held by the node, so it should not be used again. On nodes with data, it may be flushed to disk. You should not need to close nodes manually because they are automatically opened/closed when they are loaded/e

(self)

Source from the content-addressed store, hash-verified

465 self._v_attrs._g_update_node_location(self)
466
467 def _f_close(self) -> None:
468 """Close this node in the tree.
469
470 This releases all resources held by the node, so it should not
471 be used again. On nodes with data, it may be flushed to disk.
472
473 You should not need to close nodes manually because they are
474 automatically opened/closed when they are loaded/evicted from
475 the integrated LRU cache.
476
477 """
478 # After calling ``_f_close()``, two conditions are met:
479 #
480 # 1. The node object is detached from the tree.
481 # 2. *Every* attribute of the node is removed.
482 #
483 # Thus, cleanup operations used in ``_f_close()`` in sub-classes
484 # must be run *before* calling the method in the superclass.
485
486 if not self._v_isopen:
487 return # the node is already closed
488
489 dict_ = self.__dict__
490
491 # Close the associated `AttributeSet`
492 # only if it has already been placed in the object's dictionary.
493 if "_v_attrs" in dict_:
494 self._v_attrs._g_close()
495
496 # Detach the node from the tree if necessary.
497 self._g_del_location()
498
499 # Finally, clear all remaining attributes from the object.
500 dict_.clear()
501
502 # Just add a final flag to signal that the node is closed:
503 self._v_isopen = False
504
505 def _g_remove(self, recursive: bool, force: bool) -> None:
506 """Remove this node from the hierarchy.

Callers 3

__init__Method · 0.95
__del__Method · 0.95
_g_removeMethod · 0.95

Calls 3

_g_del_locationMethod · 0.95
clearMethod · 0.80
_g_closeMethod · 0.45

Tested by

no test coverage detected