{"action":"created","issue":{"url":"https://api.github.com/repos/pika/pika/issues/544","labels_url":"https://api.github.com/repos/pika/pika/issues/544/labels{/name}","comments_url":"https://api.github.com/repos/pika/pika/issues/544/comments","events_url":"https://api.github.com/repos/pika/pika/issues/544/events","html_url":"https://github.com/pika/pika/issues/544","id":67374144,"number":544,"title":"No Way To Check if BlockingConnection Generator Has Items","user":{"login":"markcf","id":4062180,"avatar_url":"https://avatars.githubusercontent.com/u/4062180?v=3","gravatar_id":"","url":"https://api.github.com/users/markcf","html_url":"https://github.com/markcf","followers_url":"https://api.github.com/users/markcf/followers","following_url":"https://api.github.com/users/markcf/following{/other_user}","gists_url":"https://api.github.com/users/markcf/gists{/gist_id}","starred_url":"https://api.github.com/users/markcf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markcf/subscriptions","organizations_url":"https://api.github.com/users/markcf/orgs","repos_url":"https://api.github.com/users/markcf/repos","events_url":"https://api.github.com/users/markcf/events{/privacy}","received_events_url":"https://api.github.com/users/markcf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-09T14:27:15Z","updated_at":"2015-04-13T12:22:15Z","closed_at":null,"body":"It would be good if there was a function for the BlockingConnection.consume Generator to check if it has items before calling consume, this way a program could avoid being blocked in the function if there are no items in rabbit.\r\n\r\nI'll gladly write a pull request for this, but I'd like to check if there's a reason to not have this behaviour first.\r\n\r\nI'm imagining something like this:\r\n\r\n'''\r\ndef getWaitingMessages(self):\r\n    return len(self._generator_messages)\r\n'''"},"comment":{"url":"https://api.github.com/repos/pika/pika/issues/comments/92333135","html_url":"https://github.com/pika/pika/issues/544#issuecomment-92333135","issue_url":"https://api.github.com/repos/pika/pika/issues/544","id":92333135,"user":{"login":"markcf","id":4062180,"avatar_url":"https://avatars.githubusercontent.com/u/4062180?v=3","gravatar_id":"","url":"https://api.github.com/users/markcf","html_url":"https://github.com/markcf","followers_url":"https://api.github.com/users/markcf/followers","following_url":"https://api.github.com/users/markcf/following{/other_user}","gists_url":"https://api.github.com/users/markcf/gists{/gist_id}","starred_url":"https://api.github.com/users/markcf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markcf/subscriptions","organizations_url":"https://api.github.com/users/markcf/orgs","repos_url":"https://api.github.com/users/markcf/repos","events_url":"https://api.github.com/users/markcf/events{/privacy}","received_events_url":"https://api.github.com/users/markcf/received_events","type":"User","site_admin":false},"created_at":"2015-04-13T12:22:15Z","updated_at":"2015-04-13T12:22:15Z","body":"Hello,\r\nThat's essentially what I'm thinking.\r\n\r\nNormally I'd agree with you and use an event driven system. \r\n\r\nFor this specific project, performance isn't a huge concern. Especially since the messages in Rabbit tend to be a bit larger, so the time spent polling an in memory list is minimal compared to the time spent processing them.\r\n\r\n The priorities of this system are high reliability and easy maintenance. Polling avoids a lot of potential pitfalls (timing bugs come to mind) and is much simpler to debug if something does come up. In addition, it makes log messages easier to understand and makes the system generally simpler. \r\n\r\nFor this project both options were evaluated, and polling came out on top.\r\n\r\nI understand this is not the general case, and if the general opinion is that such a feature shouldn't be included in order to discourage polling based systems that is reasonable."}}