kragniz / kragniz/python-etcd3
How to use keepalive correctly?
- Dominant language
- Python
- Stars
- 450
- Forks
- 194
- PR merge metrics
- No merged PRs in 30d
Description
```
import etcd3
import time
from threading import Thread
def keeper():
client = etcd3.client(host="xx.xxx.xxx.xx", port=2379)
lease = client.lease(ttl=10)
lease.refresh()
client.put('test_key', 'test_keeper', lease=lease.id)
print("lease_id", lease.id)
if __name__ == "__main__":
etcd_keeper = Thread(
target=keeper(), daemon=True)
etcd_keeper.start()
etcd_keeper.join()
time.sleep(300)
```
According to the code, i think refresh() is used for KeepAlive(), but I found that the key expires soon, anyone can advise what's wrong? Thanks``
Contributor guide
Research direction
Start by running the supplied Python snippet with the 10-second lease and observe when the key expires. Read the python-etcd3 lease and threading usage around refresh(), then compare the documented behavior with this example; done means reproducing the expiration and documenting the cause and expected usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100