Drop the `node`. Remove the node from the cache and, if it has no more references, close it.
(self, node: Node, check_unregistered: bool = True)
| 469 | self.cache.pop(nodepath, None) |
| 470 | |
| 471 | def drop_node(self, node: Node, check_unregistered: bool = True) -> None: |
| 472 | """Drop the `node`. |
| 473 | |
| 474 | Remove the node from the cache and, if it has no more references, |
| 475 | close it. |
| 476 | |
| 477 | """ |
| 478 | # Remove all references to the node. |
| 479 | nodepath = node._v_pathname |
| 480 | |
| 481 | self.drop_from_cache(nodepath) |
| 482 | |
| 483 | if nodepath in self.registry: |
| 484 | if not node._v_isopen: |
| 485 | del self.registry[nodepath] |
| 486 | elif check_unregistered: |
| 487 | # If the node is not in the registry (this should never happen) |
| 488 | # we close it forcibly since it is not ensured that the __del__ |
| 489 | # method is called for object that are still alive when the |
| 490 | # interpreter is shut down |
| 491 | if node._v_isopen: |
| 492 | warnings.warn( |
| 493 | "dropping a node that is not in the registry: " |
| 494 | "``%s``" % nodepath |
| 495 | ) |
| 496 | |
| 497 | node._g_pre_kill_hook() |
| 498 | node._f_close() |
| 499 | |
| 500 | def flush_nodes(self) -> None: |
| 501 | """Flush all nodes.""" |
no test coverage detected