运行以下代码:
async def generate_url(self, ding_id):
data = await self.s3.generate_presigned_url(
ClientMethod='get_object',
Params={
'Bucket': '...',
'Key': '{}.mp4'.format(ding_id)
}
)
return data
def convert_to_json(self, data):
loop = asyncio.get_event_loop()
for ding in dings:
tasks.append(self.generate_url(ding))
video_ids = loop.run_until_complete(asyncio.gather(*tasks))
loop.close()
导致错误:
'Key': '{}.mp4'.format(ding_id)
TypeError: object str can't be used in 'await' expression`
我使用异步请求库aiohttp
。如何解决这个问题?