benjamin-hodgson / asynqp

An AMQP library for asyncio
MIT License
84 stars 29 forks source link

Why callback in consume can't be coroutine? #85

Closed purpleP closed 8 years ago

purpleP commented 8 years ago

This defiles all benefits of using this library.

I can't understand how this library works entirely, but It seems that you using callbacks to deliver messages. Why?

Shouldn't the code conceptually be something like a bit while True loop in which you're waiting for something from server, then when it's available you dispatch it to another coroutines?

farefernandez commented 8 years ago

@purpleP I stumbled upon the very same thing in #84

purpleP commented 8 years ago

@farefernandez Wow, thanks. I've tried using create_task from a callback, but it didn't worked for some reason giving me something like 'Can't create tasks when loop is running'. But now it seems to be working.

purpleP commented 8 years ago

I'll close the issue if everything will be alright.