Skip to content

Commit 395eeab

Browse files
committed
interface for releasing parser resources
1 parent e83d58f commit 395eeab

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/hyperbase/parsers/parser.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ def install_repl(self, session: Any) -> None: # noqa: ANN401
116116
object. The default implementation is a no-op.
117117
"""
118118

119+
def close(self) -> None:
120+
"""Release any resources held by this parser (subprocess pools, open
121+
files, GPU contexts, ...).
122+
123+
The default is a no-op. Drivers that run to completion and then exit
124+
hard (e.g. via ``os._exit``, which skips atexit and ``__del__``) should
125+
call this first, so a parser's worker subprocesses are shut down rather
126+
than orphaned. Implementations must be idempotent.
127+
"""
128+
119129
def get_sentences(self, text: str) -> list[str]:
120130
raise NotImplementedError
121131

0 commit comments

Comments
 (0)