Skip to content

Commit

Permalink
[FIX]Fastapi/Sanic middleware does not support lack of SqlAlchemy pac…
Browse files Browse the repository at this point in the history
…kage #229
  • Loading branch information
smurf-U committed Sep 1, 2022
1 parent 2a8438b commit 93aeef2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/pybrake/middleware/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@


try:
from sqlalchemy import future
from sqlalchemy import event
except ImportError:
_sqla_available = False
Expand Down Expand Up @@ -121,7 +120,7 @@ def _sqla_after_cursor_execute(
return _sqla_after_cursor_execute


def init_app(app: FastAPI, sqlEngine: future.Engine = None) -> FastAPI:
def init_app(app, sqlEngine=None) -> FastAPI:
"""
Initiate the pybrake notifier and apply the patch for
error monitoring and APM.
Expand Down
5 changes: 2 additions & 3 deletions src/pybrake/middleware/sanic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

try:
from sqlalchemy import event
from sqlalchemy.ext.asyncio.engine import AsyncEngine
except ImportError:
_sqla_available = False
else:
Expand Down Expand Up @@ -81,7 +80,7 @@ def default(self, request, exception):
return super().default(request, exception)


def init_app(app: Sanic, sqlEngine: AsyncEngine = None) -> Sanic:
def init_app(app, sqlEngine=None) -> Sanic:
if "pybrake" in app.config:
raise ValueError("pybrake is already injected")
if "PYBRAKE" not in app.config:
Expand Down Expand Up @@ -141,7 +140,7 @@ def patch_html(
return app


def _sqla_instrument(notifier: Notifier, sqlEngine: AsyncEngine):
def _sqla_instrument(notifier, sqlEngine):
event.listen(sqlEngine.sync_engine, "before_cursor_execute",
_before_cursor(notifier))
event.listen(sqlEngine.sync_engine, "after_cursor_execute",
Expand Down

0 comments on commit 93aeef2

Please sign in to comment.