You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sanic no longer allows for item assignment in the request object.
I am using sanic==20.6.3 and sanic-prometheus==0.2.0
ERROR:sanic.root:Exception occurred while handling uri: 'http://localhost:8080/status/ok'
Traceback (most recent call last):
File "/home/test/.local/lib/python3.8/site-packages/sanic/app.py", line 906, in handle_request
response = await self._run_request_middleware(
File "/home/test/.local/lib/python3.8/site-packages/sanic/app.py", line 1265, in _run_request_middleware
response = await response
File "/home/test/.local/lib/python3.8/site-packages/sanic_prometheus/__init__.py", line 120, in before_request
metrics.before_request_handler(request)
File "/home/test/.local/lib/python3.8/site-packages/sanic_prometheus/metrics.py", line 52, in before_request_handler
request['__START_TIME__'] = time.time()
TypeError: 'Request' object does not support item assignment
Traceback (most recent call last):
File "/home/test/.local/lib/python3.8/site-packages/sanic/app.py", line 906, in handle_request
response = await self._run_request_middleware(
File "/home/test/.local/lib/python3.8/site-packages/sanic/app.py", line 1265, in _run_request_middleware
response = await response
File "/home/test/.local/lib/python3.8/site-packages/sanic_prometheus/__init__.py", line 120, in before_request
metrics.before_request_handler(request)
File "/home/test/.local/lib/python3.8/site-packages/sanic_prometheus/metrics.py", line 52, in before_request_handler
request['__START_TIME__'] = time.time()
TypeError: 'Request' object does not support item assignment
The text was updated successfully, but these errors were encountered:
Sanic app and request have slots so normally you can't add extra param there.
But all of this objects have ctx param (context).
And you can add all you want there.
For example current user object or smth else.
request.ctx.user = user
Of course you need to refactor your code to use it, but it's ok I think
Sanic no longer allows for item assignment in the request object.
I am using sanic==20.6.3 and sanic-prometheus==0.2.0
The text was updated successfully, but these errors were encountered: