{"action":"opened","issue":{"url":"https://api.github.com/repos/benjamin-hodgson/asynqp/issues/38","labels_url":"https://api.github.com/repos/benjamin-hodgson/asynqp/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/benjamin-hodgson/asynqp/issues/38/comments","events_url":"https://api.github.com/repos/benjamin-hodgson/asynqp/issues/38/events","html_url":"https://github.com/benjamin-hodgson/asynqp/issues/38","id":106657969,"number":38,"title":"Provide API to \"wait until message arrive and get it\"","user":{"login":"socketpair","id":1157412,"avatar_url":"https://avatars.githubusercontent.com/u/1157412?v=3","gravatar_id":"","url":"https://api.github.com/users/socketpair","html_url":"https://github.com/socketpair","followers_url":"https://api.github.com/users/socketpair/followers","following_url":"https://api.github.com/users/socketpair/following{/other_user}","gists_url":"https://api.github.com/users/socketpair/gists{/gist_id}","starred_url":"https://api.github.com/users/socketpair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/socketpair/subscriptions","organizations_url":"https://api.github.com/users/socketpair/orgs","repos_url":"https://api.github.com/users/socketpair/repos","events_url":"https://api.github.com/users/socketpair/events{/privacy}","received_events_url":"https://api.github.com/users/socketpair/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-15T22:09:35Z","updated_at":"2015-09-15T22:09:35Z","closed_at":null,"body":"`Consumer` pattern is not good in asyncio. Since it is callback-based. Callback-based apps are proven to be bad. What happen if exception raised in `Consumer.callback()`?\r\n\r\nI want to use this pattern:\r\n\r\n```\r\n@asyncio.coroutine\r\ndef some_fun():\r\n    channel = yield from connection.open_channel()\r\n    exchange = yield from channel.declare_exchange('xxx', 'direct')\r\n    queue = yield from channel.declare_queue('test.req_queue')\r\n    yield from req_queue.bind(req_exchange, 'req_key')\r\n    while True:\r\n        msg = yield from queue.wait_and_get() # function name just for example\r\n        try:\r\n            ...\r\n        except Exception:\r\n            msg.reject()\r\n        else:\r\n            msg.ack()\r\n```\r\n\r\nThis pattern gives me full control over process of receiving/handling messages. Even with timeouts if I want. Current API of `queue.Get()` returns immediatelly if there are no messages in queue, so I cannot wait for a message."}}