Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError when heartbeat is enabled #49

Closed
amackera opened this issue Oct 15, 2013 · 2 comments
Closed

AttributeError when heartbeat is enabled #49

amackera opened this issue Oct 15, 2013 · 2 comments

Comments

@amackera
Copy link

Hello all,

When I have heartbeat enabled in my client settings, I occasionally see AttributeError: 'NoneType' object has no attribute 'write' in my error logs.

Here's the stack trace:

Traceback (most recent call last):

 ... My Code ...

  File "/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/client.py", line 19, in wrapper
    p = method(*args, **kwargs)
  File "/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/machine.py", line 216, in queue_declare
    t = conn.promises.new(_queue_declare)
  File "/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/promise.py", line 21, in new
    promise = Promise(self.conn, number, on_channel, **kwargs)
  File "/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/promise.py", line 62, in __init__
    self.conn.channels.allocate(self, self._on_channel)
  File "/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/channel.py", line 45, in allocate
    machine.channel_open(promise, on_channel)
  File "/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/machine.py", line 207, in channel_open
    t.send_frames( spec.encode_channel_open('') )
  File "/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/promise.py", line 99, in send_frames
    self.conn._send_frames(self.channel.number, frames)
  File "/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/connection.py", line 185, in _send_frames
    for frame_type, payload in frames]) )
  File "/home/vagrant/.virtualenvs/thm/local/lib/python2.7/site-packages/puka/connection.py", line 177, in _send
    self.send_buf.write(data)
AttributeError: 'NoneType' object has no attribute 'write'

Looks 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.

I've disabled heartbeats for now

@amackera
Copy link
Author

As an update, after disabling heartbeats, my blocking implementation using puka has been performing perfectly.

@majek
Copy link
Owner

majek commented Nov 26, 2013

Yeah, support for heartbeats is a hack. I don't think that self.send_buf is ever Null except when the connection died, can you confirm it happens in your case?

Less ideal, but you can try using TCP keepalives (and delegate the work the operating system).

@majek majek closed this as completed May 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants