Skip to content

Commit

Permalink
Enable configuration for executor pool size
Browse files Browse the repository at this point in the history
  • Loading branch information
hoshiyosan committed Nov 25, 2021
1 parent 62e5776 commit ab2e538
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
15 changes: 13 additions & 2 deletions pytest_agent/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess

import click
Expand All @@ -23,9 +24,19 @@ def cli():
type=int,
help="Specify port of host machine on which service is going to listen",
)
def start_pytest_agent(host: str, port: int):
@click.option(
"--workers",
default=2,
type=int,
help="Defines max number of workers that can process tests simultaneously",
)
def start_pytest_agent(host: str, port: int, workers: int):
environment = os.environ.copy()
environment["MAX_WORKER_PROCESSES"] = str(workers)

subprocess.call(
["uvicorn", "pytest_agent.api:api", "--host", host, "--port", str(port)]
["uvicorn", "pytest_agent.api:api", "--host", host, "--port", str(port)],
env=environment
)


Expand Down
8 changes: 7 additions & 1 deletion pytest_agent/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
"""
Defines configuration constants.
"""
import os
import logging

LOGGER = logging.getLogger("uvicorn")

SQLALCHEMY_DATABASE_URL = "sqlite:////tmp/pytest_agent.db"
MAX_WORKER_PROCESSES = 4
MAX_WORKER_PROCESSES = int(os.getenv("MAX_WORKER_PROCESSES", 2))
LOGGER.warning(f"Pytest agent starting with {MAX_WORKER_PROCESSES} workers processes")

0 comments on commit ab2e538

Please sign in to comment.