question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Race condition in connection disconnect

See original GitHub issue

It seems like there is a race condition in the code for Connection.disconnect(). I run redis as a celery broker, so I seem to be running into a situation where I get a TypeError: NoneType has no attribute _close(). It would appear that in one process disconnect() is being called and setting the self._sock to None while another process has already executed the if statement that checks if self._sock is None.

    def disconnect(self):
        "Disconnects from the Redis server"
        self._parser.on_disconnect()
        if self._sock is None:
            return
        try:
            self._sock.shutdown(socket.SHUT_RDWR)
            self._sock.close()
        except socket.error:
            pass
        self._sock = None

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:32 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
pfreixescommented, Jun 3, 2016

Ill be out two days. I will check it then. In any case thanks for your detailed comment.

0reactions
andymccurdycommented, Feb 17, 2019

3.2.0 has just been released and fixes this issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is a Race Condition?
A race condition is an undesirable situation that occurs when a device or system attempts to perform two or more operations at the...
Read more >
Race condition in connection disconnect · Issue #732
The idea is use the shutdown syscall and call it from the pool connection and out of the current disconnect mehod that belongs...
Read more >
PH21216: A RACE CONDITION TO CLOSE A TCP/IP ...
A race condition exists between IBM MQ clients and queue manager when closing down a TCP/IP network connection. The network resource at the...
Read more >
multithreading - What is a race condition?
A race condition occurs when two or more threads can access shared data and they try to change it at the same time....
Read more >
How to Prevent Race Conditions in Web Applications
Another way of putting it is: when the timing of actions impact other actions, events may happen out of sequence, resulting in anomalous ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found