mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 12:32:30 +08:00
Fix: Change allocate_container_blocking Calculate Time by async time (#8206)
### What problem does this PR solve? Change allocate_container_blocking Calculate Time by async time ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --------- Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
@ -16,7 +16,6 @@
|
||||
import asyncio
|
||||
import contextlib
|
||||
import os
|
||||
import time
|
||||
from queue import Empty, Queue
|
||||
from threading import Lock
|
||||
|
||||
@ -165,11 +164,10 @@ async def release_container(name: str, language: SupportLanguage):
|
||||
|
||||
async def allocate_container_blocking(language: SupportLanguage, timeout=10) -> str:
|
||||
"""Asynchronously allocate an available container"""
|
||||
start_time = time.time()
|
||||
while time.time() - start_time < timeout:
|
||||
start_time = asyncio.get_running_loop().time()
|
||||
while asyncio.get_running_loop().time() - start_time < timeout:
|
||||
try:
|
||||
name = _CONTAINER_QUEUES[language].get_nowait()
|
||||
|
||||
with _CONTAINER_LOCK:
|
||||
if not await container_is_running(name) and not await recreate_container(name, language):
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user