Refa: improve usability of Node.js/JavaScript code executor (#8979)

### What problem does this PR solve?

Improve usability of Node.js/JavaScript code executor.

### Type of change

- [x] Refactoring

---------

Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
Co-authored-by: writinwaters <93570324+writinwaters@users.noreply.github.com>
This commit is contained in:
Yongteng Lei
2025-07-23 09:26:09 +08:00
committed by GitHub
parent f63ad6b725
commit c3b8d8b4ba
5 changed files with 75 additions and 13 deletions

View File

@ -26,7 +26,7 @@ from core.logger import logger
_CONTAINER_QUEUES: dict[SupportLanguage, Queue] = {}
_CONTAINER_LOCK: asyncio.Lock = asyncio.Lock()
_CONTAINER_EXECUTION_SEMAPHORES:dict[SupportLanguage,asyncio.Semaphore] = {}
_CONTAINER_EXECUTION_SEMAPHORES: dict[SupportLanguage, asyncio.Semaphore] = {}
async def init_containers(size: int) -> tuple[int, int]:
@ -38,7 +38,7 @@ async def init_containers(size: int) -> tuple[int, int]:
_CONTAINER_QUEUES[SupportLanguage.PYTHON].get_nowait()
while not _CONTAINER_QUEUES[SupportLanguage.NODEJS].empty():
_CONTAINER_QUEUES[SupportLanguage.NODEJS].get_nowait()
for language in SupportLanguage:
_CONTAINER_EXECUTION_SEMAPHORES[language] = asyncio.Semaphore(size)