-
Notifications
You must be signed in to change notification settings - Fork 96
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
Use of threading.local in lock.py can cause token leakage #119
Comments
@eirikur-grid Thanks for bug report, i will check it and give my feedback as soon as possible. |
@eirikur-grid I am afraid you are right, different coroutines share the same thread, which will break the safety of thread local mechanism. In Python 3.7 i can use contextvars to fix this, i will see if there is a good solution in Python 3.6 |
@eirikur-grid |
Excellent. |
@eirikur-grid The fix is finished, would you like to see it ? It will be merged If there is no other problem :-) |
@eirikur-grid Merged, thanks again for bug report~ |
Sorry for the late reply. I somehow missed the e-mail notification. I'll take a post-merge look and attempt to verify the fix. |
@NoneGG I have verified that the fix works as intended. However, I noticed that the newly added test is failing. See: https://github.com/NoneGG/aredis/pull/120/files#r317581785 |
The use of
threading.local()
in lock.py appears to have been ported directly from redis-py over to this project. As far as I can tell, this can lead to tokens leaking between asynchronous tasks executed within the same event loop (i.e. on the same thread).Let's consider the following scenario:
a
and a timeout of 3 secondsblocking=True
andblocking_timeout=None
b
, which is placed in thread local storageb
from thread local storage and is successful in releasing the lock, as opposed to getting aLockError
due to a token mismatch as would be the correct behavior.The text was updated successfully, but these errors were encountered: