Python 3.x Python异步CanceledError(),无详细信息

Python 3.x Python异步CanceledError(),无详细信息,python-3.x,python-asyncio,Python 3.x,Python Asyncio,下面的代码失败,我无法得到实际的错误,我只是得到了大量的CanceledError消息 import aiobotocore, asyncio async def replicate_to_region(chunks, region): session = aiobotocore.get_session() client = session.create_client('dynamodb', region_name=region) start = 0 while

下面的代码失败,我无法得到实际的错误,我只是得到了大量的CanceledError消息

import aiobotocore, asyncio

async def replicate_to_region(chunks, region):
    session = aiobotocore.get_session()
    client = session.create_client('dynamodb', region_name=region)
    start = 0
    while True:
        chunk = chunks[start]
        item = {'my_table': chunk}
        response = await client.batch_write_item(RequestItems=item)

async def main():
    asyncio.gather(*(replicate_to_region(payloads, region) for region in regions))

asyncio.run(main())
我得到以下错误

client_session: <aiohttp.client.ClientSession object at 0x7f6fb65a34a8>
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f6fb64c82b0>
_GatheringFuture exception was never retrieved
future: <_GatheringFuture finished exception=CancelledError()>
concurrent.futures._base.CancelledError
_GatheringFuture exception was never retrieved
future: <_GatheringFuture finished exception=CancelledError()>
我已经尝试了相当多的replicate_to_region函数的变体,但是它们都失败了,出现了上面相同的错误。只要能够看到实际的错误是什么就很有用了

async def main():
    asyncio.gather(...)
这是一个值得期待的时刻:

可等待的asyncio.gather*aws,loop=None,return\u exceptions=False

这意味着您在处理时应使用wait:

async def main():
    await asyncio.gather(*(replicate_to_region(payloads, region) for region in regions))
离题:

我没有与aiobotocore合作,也不确定它是否重要,但最好按照文档中的说明进行。尤其是在创建客户机时,您可能应该使用async with

这是一个值得期待的时刻:

可等待的asyncio.gather*aws,loop=None,return\u exceptions=False

这意味着您在处理时应使用wait:

async def main():
    await asyncio.gather(*(replicate_to_region(payloads, region) for region in regions))
离题:


我没有与aiobotocore合作,也不确定它是否重要,但最好按照文档中的说明进行。尤其是在创建客户机时,您可能应该使用async with

这就是问题所在。我是在从头开始后自己发现的。谢谢这就是问题所在。我是在从头开始后自己发现的。谢谢