Переглянути джерело

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>
tags/v0.19.1
Stephen Hu 4 місяці тому
джерело
коміт
ce65ea1fc1
Аккаунт користувача з таким Email не знайдено
1 змінених файлів з 2 додано та 4 видалено
  1. 2
    4
      sandbox/executor_manager/core/container.py

+ 2
- 4
sandbox/executor_manager/core/container.py Переглянути файл

@@ -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

Завантаження…
Відмінити
Зберегти