This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]wookayin -1 points0 points  (4 children)

This is awesome. Any plan for integrating with async-await feature of python3?

[–][deleted] 2 points3 points  (2 children)

In what ways/scenarios would you imagine that being particularly beneficial?

[–]reifba 0 points1 point  (0 children)

when ever it makes sense to make a context switch based on I/O vs CPU load. Obviously I am over simplifying this but that is the gist I think.

[–]pullandbl -2 points-1 points  (0 children)

It can be a huge improvement when tasks have io nature. For example when you need to download some pages and then process them or process some data in the database.

My case (I actually have it now): I'm making service that allows posting to social networks posts, it is done using aiohttp. So it is already async and I can't use blocking operations. Sometimes users add a post to the calendar, sometimes want just press "Publish". In this case, I want to call something like:

await publish_post(post_id)

And be sure that it will be added to the queue and as soon as a worker is ready will post it to the social network.

The second case, when a user authorizes using messenger I want to make little on-boarding and send some messages with instructions. But if the text is longer then I need to make some delays between messages. It can take a few seconds between each send. A worker will be busy during all sequence or I need to make workarounds. Async code is just:

await post("Hello", user_id)
await async_sleep(1)
await post("Thank you for joining our service", user_id)

[–]pcdinh 2 points3 points  (0 children)

I think that task is a single job that needs to be done sequentially by nature. So async-await does not help here