mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-08-27 12:30:13 +03:00
feat(tests): increase maximum open file descriptors for test runs on Unix
This commit is contained in:
parent
2b949b1a77
commit
c010be1a02
@ -8,6 +8,8 @@ import uuid
|
||||
import configparser
|
||||
import base64
|
||||
import stat
|
||||
import resource
|
||||
import platform
|
||||
|
||||
from fastapi import FastAPI
|
||||
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
|
||||
@ -35,6 +37,19 @@ sys._called_from_test = True
|
||||
sys.original_platform = sys.platform
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
"""
|
||||
Increases the maximum number of open file descriptors before running tests (Unix only).
|
||||
"""
|
||||
|
||||
if platform.system() != "Windows":
|
||||
soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
|
||||
# Set soft limit to hard limit, or a safe high number like 4096
|
||||
new_soft = min(4096, hard)
|
||||
if soft < new_soft:
|
||||
resource.setrlimit(resource.RLIMIT_NOFILE, (new_soft, hard))
|
||||
|
||||
|
||||
@pytest_asyncio.fixture(loop_scope="class", scope="class")
|
||||
async def app() -> AsyncGenerator[Any, Any]:
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user