Describe the bug
This bug is only introduced when I upgrade my server to 19.9.0 from 19.6.3.
Although the server still returns the response, it freezes during teardown of any test cases.
ERROR sanic.error:app.py:991 Exception occurred in one of response middleware handlers
Traceback (most recent call last):
File "/Users/son/.local/share/virtualenvs/ora-backend-SVHRxsY1/lib/python3.7/site-packages/sanic/app.py", line 983, in handle_request
request, response
File "/Users/son/.local/share/virtualenvs/ora-backend-SVHRxsY1/lib/python3.7/site-packages/spf/framework.py", line 571, in _run_response_middleware
_response = await _response
File "/Users/son/.local/share/virtualenvs/ora-backend-SVHRxsY1/lib/python3.7/site-packages/gino/ext/sanic.py", line 91, in on_response
conn = request.pop('connection', None)
AttributeError: 'Request' object has no attribute 'pop'
Environment (please complete the following information):
can you post a code snippet to help us try and replicate?
This seems to be an issue with Gino library. Could you please let me know the changes from 19.6.3 to 19.9.0 that may result in this behavior ? I will create an issue to let them know.
Version:
Gino: 0.8.3
from sanic import Sanic
from sanic.response import json
from gino.ext.sanic import Gino
db = Gino()
app = Sanic(__name__)
DB_CONFIG = {
"DB_HOST": "localhost",
"DB_PORT": "54320",
"DB_USER": "postgres",
"DB_DATABASE": "postgres",
"DB_POOL_MIN_SIZE": 5,
"DB_POOL_MAX_SIZE": 10,
}
SANIC_CONFIG = {**DB_CONFIG, "KEEP_ALIVE_TIMEOUT": 10}
app.config.update(SANIC_CONFIG)
db.init_app(app)
@app.route('/')
async def test(request):
return json({'hello': 'world'})
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000)
You need to be using request.ctx now because the dict API on request is no longer (fully) supported. https://sanic.readthedocs.io/en/latest/sanic/middleware.html#modifying-the-request-or-response
Issue is this line in Gino's sanic extension:
https://github.com/fantix/gino/blob/2c233e9fcf80637ef24f9d16d8652d27d14bddf7/gino/ext/sanic.py#L91
Because this is an issue within a different project, I'm closing this, but have opened the issue with Gino here: https://github.com/fantix/gino/issues/581
Most helpful comment
Issue is this line in Gino's sanic extension:
https://github.com/fantix/gino/blob/2c233e9fcf80637ef24f9d16d8652d27d14bddf7/gino/ext/sanic.py#L91
Because this is an issue within a different project, I'm closing this, but have opened the issue with Gino here: https://github.com/fantix/gino/issues/581