Is there an existing issue for this?
Describe the bug
When running Sanic as an ASGI application in a test suite where apps are repeatedly started and shutdown, Sanic's touchup logic fails with a KeyError.
Traceback (most recent call last):
File "/home/ryan/Repositories/idom-team/idom/venv/lib/python3.10/site-packages/sanic/asgi.py", line 89, in __call__
await self.startup()
File "/home/ryan/Repositories/idom-team/idom/venv/lib/python3.10/site-packages/sanic/asgi.py", line 60, in startup
await self.asgi_app.sanic_app._startup()
File "/home/ryan/Repositories/idom-team/idom/venv/lib/python3.10/site-packages/sanic/app.py", line 1572, in _startup
TouchUp.run(self)
File "/home/ryan/Repositories/idom-team/idom/venv/lib/python3.10/site-packages/sanic/touchup/service.py", line 24, in run
modified = BaseScheme.build(method, module_globals, app)
File "/home/ryan/Repositories/idom-team/idom/venv/lib/python3.10/site-packages/sanic/touchup/schemes/base.py", line 38, in build
return exec_locals[method.__name__]
KeyError: 'read'
Here are some notable facts:
- This problem does not exist in the last version (v22.9.1).
- The exact
KeyError is random, sometimes its read, but other times it could be something completely different.
- The first usages of Sanic works fine. It's the next usages that fails in this way.
- The server is being run with
uvicorn.
Code snippet
I haven't had time to create a truly isolated example. However, if you install the following:
pip install "idom[sanic,testing]==0.42.0" "uvicorn[standard]==0.20.0"
You can reproduce the error I'm seeing with the following code under sanic==22.12.0:
from asyncio import run
from idom.testing import BackendFixture
from idom.backend import sanic as sanic_backend
async def main():
async with BackendFixture(implementation=sanic_backend):
...
async with BackendFixture(implementation=sanic_backend):
...
run(main())
As mentioned above, running this same code under sanic==22.9.1 works just fine.
Expected Behavior
I should be able to start and stop Sanic servers multiple times without error.
How do you run Sanic?
ASGI
Operating System
Linux (Ubuntu)
Sanic Version
22.12.0
Additional context
No response
Is there an existing issue for this?
Describe the bug
When running Sanic as an ASGI application in a test suite where apps are repeatedly started and shutdown, Sanic's touchup logic fails with a
KeyError.Here are some notable facts:
KeyErroris random, sometimes itsread, but other times it could be something completely different.uvicorn.Code snippet
I haven't had time to create a truly isolated example. However, if you install the following:
You can reproduce the error I'm seeing with the following code under
sanic==22.12.0:As mentioned above, running this same code under
sanic==22.9.1works just fine.Expected Behavior
I should be able to start and stop Sanic servers multiple times without error.
How do you run Sanic?
ASGI
Operating System
Linux (Ubuntu)
Sanic Version
22.12.0
Additional context
No response