kragniz / python-etcd3

Python client for the etcd API v3
Apache License 2.0
430 stars 184 forks source link

leader ID None #111

Open yueyongyue opened 7 years ago

yueyongyue commented 7 years ago

python-etcd3 version 0.5.2 client.py

336 for m in self.members: 337 if m.id == status_response.leader: 338 leader = m 339 else: 340 # raise exception? 341 leader = None

leader maybe return None in most cases

kragniz commented 7 years ago

The error handling here is a bit suspect, but if leader is None in most cases, something is probably going wrong with your etcd cluster.

yueyongyue commented 7 years ago
    for m in self.members:
        if m.id == status_response.leader:
            leader = m
        else:
            # raise exception?
            leader = None

Only the last cycle ,m.id == status_response.leader ,leader is not None Other conditions leader is None