forked from retoor/snek
fix: switch compose entrypoint to python module and enable asyncio debug in app.py
- Comment out gunicorn entrypoint in compose.yml and use python -m snek.app instead - Add asyncio import and create async main() function in app.py - Enable asyncio event loop debug mode via loop.set_debug(True) - Replace direct web.run_app call with asyncio.run(main()) for proper async context
This commit is contained in:
+9
-3
@@ -1,5 +1,7 @@
|
||||
import pathlib
|
||||
|
||||
import asyncio
|
||||
|
||||
from aiohttp import web
|
||||
from aiohttp_session import (
|
||||
get_session as session_get,
|
||||
@@ -29,6 +31,7 @@ from snek.view.web import WebView
|
||||
from snek.view.upload import UploadView
|
||||
from snek.view.search_user import SearchUserView
|
||||
|
||||
|
||||
SESSION_KEY = b"c79a0c5fda4b424189c427d28c9f7c34"
|
||||
|
||||
|
||||
@@ -121,8 +124,11 @@ class Application(BaseApplication):
|
||||
return await super().render_template(template, request, context)
|
||||
|
||||
|
||||
app = Application(db_path="sqlite:///snek.db")
|
||||
async def main():
|
||||
app = Application(db_path="sqlite:///snek.db")
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.set_debug(True)
|
||||
await web._run_app(app, port=8081, host="0.0.0.0")
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
web.run_app(app, port=8081, host="0.0.0.0")
|
||||
asyncio.run(main())
|
||||
|
||||
Reference in New Issue
Block a user