kragniz / kragniz/python-etcd3
Deadlock when adding watch callback in a callback
- Dominant language
- Python
- Stars
- 450
- Forks
- 194
- PR merge metrics
- No merged PRs in 30d
Description
The current implementation of method `Etcd3Client.add_watch_callback` will trigger deadlock (block indefinitely) if it is invoked in a watch callback function.
For example:
```python
import time
import etcd3
etcd = etcd3.client(host='localhost')
def callback(event):
print 'Callback begins.'
etcd.add_watch_callback('/123', callback=callback)
print 'Callback done.'
callback(None) # Add the callback
print "Putting new key..."
etcd.put('/123', '123') # Trigger the added callback
print "New key was uploaded."
while True:
time.sleep(1) # Prevent the daemon watcher from being stopped
```
The second `"Callback done."` can never be printed if you run this code.
This problem is applicable to other methods which invoke `add_watch_callback`, including `watch`, `watch_once`, `watch_prefix` and `watch_prefix_once`.
Contributor guide
Research direction
Start by reading the implementation of Etcd3Client.add_watch_callback and the related watch, watch_once, watch_prefix, and watch_prefix_once methods named in the issue. Run the provided reproduction against a local etcd instance; done means adding a watch from inside a watch callback returns and the callback can continue without blocking indefinitely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100