我需要从aiohttp服务向SQS队列发送消息。 我阅读了aiobotocore的文档和所有示例,但没有看到如何从aipg发送example与postgres相同的消息。
async def pg_engine(app):
app['pg_engine'] = await create_engine(
user='postgre',
database='postgre',
host='localhost',
port=5432,
password=''
)
yield
app['pg_engine'].close()
await app['pg_engine'].wait_closed()
app.cleanup_ctx.append(pg_engine)
UPD 解决方法是
async def sqs_client(app):
session = get_session(loop=app.loop)
app['sqs'] = session.create_client('sqs',
endpoint_url=SQS_QUEUE_URL,
region_name=SQS_REGION)
yield
# close connection after finish
await app['sqs'].close()
app.cleanup_ctx.append(sqs_client)