Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pythainlp/tokenize/budoux.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def segment(text: str) -> list[str]:
return []

# Thread-safe lazy initialization
global _parser
with _parser_lock:
if _parser is None:
global _parser
_parser = _init_parser()
parser = _parser

Expand Down
2 changes: 1 addition & 1 deletion pythainlp/tokenize/oskut.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def segment(text: str, engine: str = "ws") -> list[str]:
return []

# Thread-safe model loading
global _DEFAULT_ENGINE
with _engine_lock:
if engine != _DEFAULT_ENGINE:
# Need to update global state and reload model
global _DEFAULT_ENGINE
_DEFAULT_ENGINE = engine
oskut.load_model(engine=_DEFAULT_ENGINE)

Expand Down
2 changes: 1 addition & 1 deletion pythainlp/tokenize/sefr_cut.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ def segment(text: str, engine: str = "ws1000") -> list[str]:
return []

# Thread-safe model loading
global _DEFAULT_ENGINE
with _engine_lock:
if engine != _DEFAULT_ENGINE:
# Need to update global state and reload model
global _DEFAULT_ENGINE
_DEFAULT_ENGINE = engine
sefr_cut.load_model(engine=_DEFAULT_ENGINE)

Expand Down
2 changes: 1 addition & 1 deletion pythainlp/tokenize/wtsplit.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def _tokenize(
thread-safety guarantees.
"""
# Thread-safe model loading
global _MODEL, _MODEL_NAME
with _model_lock:
if _MODEL_NAME != model:
global _MODEL, _MODEL_NAME
_MODEL = WtP(model_name_or_model=model)
_MODEL_NAME = model
model_instance = _MODEL
Expand Down
Loading