The code after "await" is not executed #805
Answered
by
agronholm
FabienLariviere
asked this question in
Q&A
-
Why does my "job" complete immediately after executing one "await"? async def main(queue_name):
async def on_message(message: DeliveredMessage):
...
try:
await bot.send_message(msg.phone, msg.message)
# exit
# print('some') - do not work
except RPCError as rpc:
...
finally:
# do not work
connection = await aiormq.connect("amqp://guest:guest@localhost/")
async with connection:
channel = await connection.channel()
declare_queue = await channel.queue_declare(queue_name)
await channel.basic_consume(
declare_queue.queue, on_message, no_ack=True
)
...
# code is working
await channel.basic_publish(...)
# print('some') next code do not work again
if __name__ == '__main__':
scheduler = AsyncIOScheduler()
scheduler.add_job(main, "interval", args=('test_queue',), seconds=10)
scheduler.start() |
Beta Was this translation helpful? Give feedback.
Answered by
agronholm
Oct 20, 2023
Replies: 1 comment 7 replies
-
There is nothing here keeping an event loop running, so I don't really understand how this would work at all. |
Beta Was this translation helpful? Give feedback.
7 replies
Answer selected by
FabienLariviere
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is nothing here keeping an event loop running, so I don't really understand how this would work at all.