Skip to content

If we don't want timeouts we must set the socket's timeout to None - #281

Open
thedrow wants to merge 1 commit into
mainfrom
fix-timeouts
Open

If we don't want timeouts we must set the socket's timeout to None#281
thedrow wants to merge 1 commit into
mainfrom
fix-timeouts

Conversation

@thedrow

@thedrow thedrow commented Jun 21, 2019

Copy link
Copy Markdown
Contributor

See https://docs.python.org/3/library/socket.html#socket.socket.settimeout.

This commit was triggered by celery/celery#4876 (comment).
It could fix the issue as well.

@thedrow

thedrow commented Jun 22, 2019

Copy link
Copy Markdown
Contributor Author

With this change, the integration tests hang on Travis.

@matusvalo Any idea why?

@matusvalo

matusvalo commented Jul 1, 2019

Copy link
Copy Markdown
Member

@thedrow, see my comments in the patch. The problem is that when you are using publisher confirm, the publisher checks before publishing if broker sent a message to him. This relies on timeout=0 which this patch has changed semantics to block forever.

@thedrow

thedrow commented Jul 2, 2019

Copy link
Copy Markdown
Contributor Author

So what should we do to fix this issue exactly?

@matusvalo matusvalo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would change on PR is:

  1. remove internal interfaces changes which breaks current code - having_timeout() method.
  2. Fix all timeouts in public interfaces...

py-amqp/amqp/channel.py

Lines 1686 to 1688 in b36bf88

def _basic_publish(self, msg, exchange='', routing_key='',
mandatory=False, immediate=False, timeout=None,
argsig='Bssbb'):

def blocking_read(self, timeout=None):

In this way it should work. Maybe we can add also integration tests for each timeout input?

Comment thread amqp/transport.py
@contextmanager
def having_timeout(self, timeout):
if timeout is None:
if timeout is None or timeout == 0:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line of code breaks the following:

py-amqp/amqp/channel.py

Lines 1764 to 1769 in b36bf88

if capabilities.get('connection.blocked', False):
try:
# Check if an event was sent, such as the out of memory message
self.connection.drain_events(timeout=0)
except socket.timeout:
pass

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The def having_timeout() method should be not changed because:

  1. it is internal API
  2. we are using it as mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants