Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor: replace gevent threadpool with ProcessPoolExecutor in GPT2Tokenizer (#12316)
-LAN-6f5a8a33d9de
diff --git a/api/core/model_runtime/model_providers/__base/tokenizers/gpt2_tokenzier.py b/api/core/model_runtime/model_providers/__base/tokenizers/gpt2_tokenzier.pyindex ab45a958033..72d9b7163c9 100644--- a/api/core/model_runtime/model_providers/__base/tokenizers/gpt2_tokenzier.py+++ b/api/core/model_runtime/model_providers/__base/tokenizers/gpt2_tokenzier.py@@ -1,13 +1,13 @@+from concurrent.futures import ProcessPoolExecutorfrom os.path import abspath, dirname, joinfrom threading import Lockfrom typing import Any, cast-import gevent.threadpool # type: ignorefrom transformers import GPT2Tokenizer as TransformerGPT2Tokenizer # type: ignore_tokenizer: Any = None_lock = Lock()-_pool = gevent.threadpool.ThreadPool(1)+_executor = ProcessPoolExecutor(max_workers=1)class GPT2Tokenizer:@@ -22,8 +22,8 @@ class GPT2Tokenizer:@staticmethoddef get_num_tokens(text: str) -> int:- future = _pool.spawn(GPT2Tokenizer._get_num_tokens_by_gpt2, text)- result = future.get(block=True)+ future = _executor.submit(GPT2Tokenizer._get_num_tokens_by_gpt2, text)+ result = future.result()return cast(int, result)@staticmethod