Hi! I have the function which gets file from s3 bucket
async def get_object(self, file_path: str) -> Optional[bytes]:
async with self.session.client(self.SERVICE_NAME) as s3:
try:
s3_object = await s3.get_object(Bucket=self.BUCKET_NAME, Key=file_path)
except ClientError:
return
async with s3_object["Body"] as stream:
file_data = await stream.read()
return file_data
When my endpoint returned file data and everything is ok, then I get this error
Exception in callback SanicProtocol.abort()
handle: <TimerHandle when=23043869.405625403 SanicProtocol.abort() created at /usr/local/lib/python3.8/site-packages/sanic/server/protocols/base_protocol.py:93>
source_traceback: Object created at (most recent call last):
File “/usr/local/lib/python3.8/site-packages/sanic/server/runners.py”, line 199, in serve_single
serve(**server_settings)
File “/usr/local/lib/python3.8/site-packages/sanic/server/runners.py”, line 150, in serve
loop.run_forever()
File “/usr/local/lib/python3.8/asyncio/base_events.py”, line 570, in run_forever
self._run_once()
File “/usr/local/lib/python3.8/asyncio/base_events.py”, line 1851, in _run_once
handle._run()
File “/usr/local/lib/python3.8/asyncio/events.py”, line 81, in _run
self._context.run(self._callback, *self._args)
File “connection_task”, line 35, in connection_task
# request config
File “/usr/local/lib/python3.8/site-packages/sanic/server/protocols/base_protocol.py”, line 93, in close
self.loop.call_later(timeout, self.abort)
Traceback (most recent call last):
File “/usr/local/lib/python3.8/asyncio/events.py”, line 81, in _run
self._context.run(self._callback, *self._args)
File “/usr/local/lib/python3.8/site-packages/sanic/server/protocols/base_protocol.py”, line 101, in abort
self.transport.abort()
File “/usr/local/lib/python3.8/asyncio/selector_events.py”, line 672, in abort
self._force_close(None)
File “/usr/local/lib/python3.8/asyncio/selector_events.py”, line 723, in _force_close
self._loop.call_soon(self._call_connection_lost, exc)
AttributeError: ‘NoneType’ object has no attribute ‘call_soon’
What it can be? How can I avoid this error?