{"action":"created","issue":{"url":"https://api.github.com/repos/pika/pika/issues/660","labels_url":"https://api.github.com/repos/pika/pika/issues/660/labels{/name}","comments_url":"https://api.github.com/repos/pika/pika/issues/660/comments","events_url":"https://api.github.com/repos/pika/pika/issues/660/events","html_url":"https://github.com/pika/pika/pull/660","id":113427630,"number":660,"title":"Fix: Improper KeyError when channel created on a BlockingConnection whose server was shutdown","user":{"login":"gst","id":38055,"avatar_url":"https://avatars.githubusercontent.com/u/38055?v=3","gravatar_id":"","url":"https://api.github.com/users/gst","html_url":"https://github.com/gst","followers_url":"https://api.github.com/users/gst/followers","following_url":"https://api.github.com/users/gst/following{/other_user}","gists_url":"https://api.github.com/users/gst/gists{/gist_id}","starred_url":"https://api.github.com/users/gst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gst/subscriptions","organizations_url":"https://api.github.com/users/gst/orgs","repos_url":"https://api.github.com/users/gst/repos","events_url":"https://api.github.com/users/gst/events{/privacy}","received_events_url":"https://api.github.com/users/gst/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-26T19:02:09Z","updated_at":"2015-12-20T20:31:17Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pika/pika/pulls/660","html_url":"https://github.com/pika/pika/pull/660","diff_url":"https://github.com/pika/pika/pull/660.diff","patch_url":"https://github.com/pika/pika/pull/660.patch"},"body":"\r\nMore specifically:\r\n\r\n    return self._channels[channel_number]\r\n\r\nwill raise KeyError in such case because the channel will have already been removed from the connection _channels dict.\r\n\r\nUsing this fix you'll more correctly get ConnectionClosed exception."},"comment":{"url":"https://api.github.com/repos/pika/pika/issues/comments/166151845","html_url":"https://github.com/pika/pika/pull/660#issuecomment-166151845","issue_url":"https://api.github.com/repos/pika/pika/issues/660","id":166151845,"user":{"login":"vitaly-krugl","id":1441066,"avatar_url":"https://avatars.githubusercontent.com/u/1441066?v=3","gravatar_id":"","url":"https://api.github.com/users/vitaly-krugl","html_url":"https://github.com/vitaly-krugl","followers_url":"https://api.github.com/users/vitaly-krugl/followers","following_url":"https://api.github.com/users/vitaly-krugl/following{/other_user}","gists_url":"https://api.github.com/users/vitaly-krugl/gists{/gist_id}","starred_url":"https://api.github.com/users/vitaly-krugl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vitaly-krugl/subscriptions","organizations_url":"https://api.github.com/users/vitaly-krugl/orgs","repos_url":"https://api.github.com/users/vitaly-krugl/repos","events_url":"https://api.github.com/users/vitaly-krugl/events{/privacy}","received_events_url":"https://api.github.com/users/vitaly-krugl/received_events","type":"User","site_admin":false},"created_at":"2015-12-20T20:31:17Z","updated_at":"2015-12-20T20:31:17Z","body":"@gst, I am beginning to think that there is a deeper problem here that is perhaps tied to pika on python 3.x or on the different platform than I am running. By the way, what is your environment? Are you running on Unix or Linux and on which version?\r\n\r\nWould you mind reproducing the failure with DEBUG logging turned on and posting pika's complete log here? Turn on DEBUG logging before creating the pika connection\r\n```\r\nimport logging\r\nLOG_FORMAT = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) '\r\n              '-35s %(lineno) -5d: %(message)s')\r\nlogging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)\r\n```\r\n\r\n\r\nI am running on Mac OS X Yosemite 10.10.5 with python 2.7.10, and here is what I get (note my modified command that stops rabbitmq inline):\r\n\r\n```\r\n$ python -c 'import pika; print(pika); c = pika.BlockingConnection(); import subprocess; subprocess.check_call([\"rabbitmqctl\", \"stop\"]); c.channel()'\r\n<module 'pika' from '/Users/vkruglikov/ossdev/pika/pika/__init__.pyc'>\r\nStopping and halting node rabbit@localhost ...\r\nTraceback (most recent call last):\r\n  File \"<string>\", line 1, in <module>\r\n  File \"/Users/vkruglikov/ossdev/pika/pika/adapters/blocking_connection.py\", line 707, in channel\r\n    channel._flush_output(opened_args.is_ready)\r\n  File \"/Users/vkruglikov/ossdev/pika/pika/adapters/blocking_connection.py\", line 1183, in _flush_output\r\n    *waiters)\r\n  File \"/Users/vkruglikov/ossdev/pika/pika/adapters/blocking_connection.py\", line 422, in _flush_output\r\n    result.reason_text)\r\npika.exceptions.ConnectionClosed: (320, \"CONNECTION_FORCED - broker forced connection closure with reason 'shutdown'\")\r\n```\r\n\r\n"}}