Skip to content

Commit

Permalink
Revert "profiling to dev"
Browse files Browse the repository at this point in the history
This reverts commit c127fe1.
  • Loading branch information
extreme4all committed Sep 22, 2023
1 parent c127fe1 commit 6c0e6a1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 23 deletions.
4 changes: 2 additions & 2 deletions notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ git push
## windows
creating a python venv to work in and install the project requirements
```sh
python -m venv .venv
.venv\Scripts\activate
python -m venv .venv-win
.venv-win\Scripts\activate
python -m pip install --upgrade pip
pip install -r requirements.txt
```
Expand Down
1 change: 0 additions & 1 deletion src/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
token = os.environ.get("token")
kafka_url = os.environ.get("kafka_url", "127.0.0.1:9094")
env = os.environ.get("env", "DEV")
profiling = os.environ.get("profiling", 0)

# setup logging
file_handler = logging.FileHandler(filename="./error.log", mode="a")
Expand Down
18 changes: 1 addition & 17 deletions src/core/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from fastapi.exceptions import RequestValidationError
from fastapi.middleware import Middleware
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse, HTMLResponse
from pyinstrument import Profiler
from fastapi.responses import JSONResponse

from src import api
from src.core import config
Expand Down Expand Up @@ -105,18 +104,3 @@ async def startup_event():
logger.info("startup initiated")
highscore_processor = HighscoreProcessor(batch_size=100)
asyncio.ensure_future(highscore_processor.start())


if config.profiling and config.env == "DEV":

@app.middleware("http")
async def profile_request(request: Request, call_next):
profiling = request.query_params.get("profile", False)
if profiling:
profiler = Profiler(interval=0.01, async_mode="enabled")
profiler.start()
await call_next(request)
profiler.stop()
return HTMLResponse(profiler.output_html())
else:
return await call_next(request)
5 changes: 2 additions & 3 deletions src/database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ def __get_engine(self, connection_string) -> AsyncEngine:
poolclass=QueuePool,
pool_pre_ping=True,
pool_size=100,
max_overflow=1000,
pool_recycle=299,
pool_timeout=30,
max_overflow=5000,
pool_recycle=3600,
)
return engine

Expand Down

0 comments on commit 6c0e6a1

Please sign in to comment.