fix: Prevent double-prefixing of S2A team names and refactor Telegram bot's thread pool usage for non-blocking execution.

This commit is contained in:
2026-02-08 02:21:57 +08:00
parent cb1fb57b53
commit 4c40949696
2 changed files with 10 additions and 11 deletions

View File

@@ -710,7 +710,7 @@ def s2a_create_account_from_oauth(
full_email = name if "@" in name else ""
if name:
payload["name"] = f"team-{name}"
payload["name"] = name if name.startswith("team-") else f"team-{name}"
if proxy_id is not None:
payload["proxy_id"] = proxy_id
@@ -790,8 +790,9 @@ def s2a_add_account(
if token_info.get("email"):
credentials["email"] = token_info.get("email")
s2a_name = name if name.startswith("team-") else f"team-{name}"
payload = {
"name": f"team-{name}",
"name": s2a_name,
"platform": "openai",
"type": "oauth",
"credentials": credentials,

View File

@@ -3985,18 +3985,16 @@ class ProvisionerBot:
if worker_id in current_steps:
del current_steps[worker_id]
# 使用线程池并发执行
# 使用线程池并发执行 (通过 run_in_executor 避免阻塞 event loop)
import concurrent.futures
loop = asyncio.get_event_loop()
with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as executor:
futures = [executor.submit(worker_task, i) for i in range(workers)]
# 等待所有任务完成
for future in concurrent.futures.as_completed(futures):
try:
future.result()
except Exception as e:
log.error(f"Worker 异常: {e}")
async_futures = [loop.run_in_executor(executor, worker_task, i) for i in range(workers)]
results_done = await asyncio.gather(*async_futures, return_exceptions=True)
for r in results_done:
if isinstance(r, Exception):
log.error(f"Worker 异常: {r}")
# 检查是否被停止
stopped = False