-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Description
Version: redis==2.10.6
Platform: Python 3.7 on Ubuntu 18.04
Description:
I encountered the same question with the link: celery/celery#4363
I reproduce the error by inserting time.sleep() in Connection.connect which is trying to initialize self._sock, then start two thread, make both pass self._sock existence check and run into Connection._on_connect (apprently Connection.connnect without any thread-lock).
So when one thread in on_connect() call read_response
, it maybe get another thread's response, then raise the error.
def on_connect(self):
"Initialize the connection, authenticate and select a database"
self._parser.on_connect(self)
# if a password is specified, authenticate
if self.password:
self.send_command('AUTH', self.password)
if nativestr(self.read_response()) != 'OK':
raise AuthenticationError('Invalid Password')
# if a database is specified, switch to it
if self.db:
self.send_command('SELECT', self.db)
res = self.read_response()
if nativestr(res) != 'OK':
raise ConnectionError('Invalid Database')
Is this a bug or something I don't get?
Metadata
Metadata
Assignees
Labels
No labels