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

socket.timeout exception when timeouting on PubSub.get_message(timeout=1) #1200

Closed
pvalsecc opened this issue Aug 6, 2019 · 1 comment
Closed

Comments

@pvalsecc
Copy link

pvalsecc commented Aug 6, 2019

Version: 3.3.5

Platform: Python 3.7.3 on Ubuntu 18.04

Description: Since 3.3.5 (was OK in 3.3.4), the polling of messages is raising a socket.timeout exception when no message arrives. In 3.3.4, it was doing nothing and returning None, as documented.

The line of code: https://github.com/camptocamp/c2cwsgiutils/blob/master/c2cwsgiutils/redis_utils.py#L30

Stacktrace:

Traceback (most recent call last):

  File "/opt/c2cwsgiutils/c2cwsgiutils/redis_utils.py", line 30, in run
    pubsub.get_message(ignore_subscribe_messages=True, timeout=1)

  File "/usr/local/lib/python3.7/dist-packages/redis/client.py", line 3283, in get_message
    response = self.parse_response(block=False, timeout=timeout)

  File "/usr/local/lib/python3.7/dist-packages/redis/client.py", line 3169, in parse_response
    if not block and not conn.can_read(timeout=timeout):

  File "/usr/local/lib/python3.7/dist-packages/redis/connection.py", line 674, in can_read
    return self._parser.can_read(timeout)

  File "/usr/local/lib/python3.7/dist-packages/redis/connection.py", line 291, in can_read
    return self._buffer and self._buffer.can_read(timeout)

  File "/usr/local/lib/python3.7/dist-packages/redis/connection.py", line 201, in can_read
    raise_on_timeout=False)

  File "/usr/local/lib/python3.7/dist-packages/redis/connection.py", line 173, in _read_from_socket
    data = recv(self._sock, socket_read_size)

  File "/usr/local/lib/python3.7/dist-packages/redis/_compat.py", line 58, in recv
    return sock.recv(*args, **kwargs)

socket.timeout: timed out
pvalsecc pushed a commit to camptocamp/c2cwsgiutils that referenced this issue Aug 6, 2019
pvalsecc pushed a commit to camptocamp/c2cgeoportal that referenced this issue Aug 6, 2019
pvalsecc pushed a commit to camptocamp/c2cgeoportal that referenced this issue Aug 6, 2019
@andymccurdy
Copy link
Contributor

Yup, you're right. This wasn't adequately tested. I've added a test in the test suite for this condition and fixed the issue. Just released 3.3.6 on PyPI.

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