{"action":"closed","issue":{"url":"https://api.github.com/repos/majek/puka/issues/49","labels_url":"https://api.github.com/repos/majek/puka/issues/49/labels{/name}","comments_url":"https://api.github.com/repos/majek/puka/issues/49/comments","events_url":"https://api.github.com/repos/majek/puka/issues/49/events","html_url":"https://github.com/majek/puka/issues/49","id":21026888,"number":49,"title":"AttributeError when heartbeat is enabled","user":{"login":"amackera","id":32489,"avatar_url":"https://avatars.githubusercontent.com/u/32489?v=3","gravatar_id":"","url":"https://api.github.com/users/amackera","html_url":"https://github.com/amackera","followers_url":"https://api.github.com/users/amackera/followers","following_url":"https://api.github.com/users/amackera/following{/other_user}","gists_url":"https://api.github.com/users/amackera/gists{/gist_id}","starred_url":"https://api.github.com/users/amackera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amackera/subscriptions","organizations_url":"https://api.github.com/users/amackera/orgs","repos_url":"https://api.github.com/users/amackera/repos","events_url":"https://api.github.com/users/amackera/events{/privacy}","received_events_url":"https://api.github.com/users/amackera/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2013-10-15T16:15:35Z","updated_at":"2015-05-13T21:50:36Z","closed_at":"2015-05-13T21:50:36Z","body":"Hello all,\r\n\r\nWhen I have heartbeat enabled in my client settings, I occasionally see `AttributeError: 'NoneType' object has no attribute 'write'` in my error logs.\r\n\r\nHere's the stack trace:\r\n```\r\nTraceback (most recent call last):\r\n \r\n ... My Code ...\r\n\r\n  File \"/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/client.py\", line 19, in wrapper\r\n    p = method(*args, **kwargs)\r\n  File \"/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/machine.py\", line 216, in queue_declare\r\n    t = conn.promises.new(_queue_declare)\r\n  File \"/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/promise.py\", line 21, in new\r\n    promise = Promise(self.conn, number, on_channel, **kwargs)\r\n  File \"/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/promise.py\", line 62, in __init__\r\n    self.conn.channels.allocate(self, self._on_channel)\r\n  File \"/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/channel.py\", line 45, in allocate\r\n    machine.channel_open(promise, on_channel)\r\n  File \"/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/machine.py\", line 207, in channel_open\r\n    t.send_frames( spec.encode_channel_open('') )\r\n  File \"/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/promise.py\", line 99, in send_frames\r\n    self.conn._send_frames(self.channel.number, frames)\r\n  File \"/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/connection.py\", line 185, in _send_frames\r\n    for frame_type, payload in frames]) )\r\n  File \"/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/connection.py\", line 177, in _send\r\n    self.send_buf.write(data)\r\nAttributeError: 'NoneType' object has no attribute 'write'\r\n```\r\n\r\nLooks to me like the way that heartbeats work in puka don't work very well with blocking architectures. A simple fix is to check if `self.send_buf == None` before writing, but I'm not sure what else that could break.\r\n\r\nI've disabled heartbeats for now"}}