Skip to content

Commit c306d61

Browse files
Set default local_dc in distance in DCAwareRoundRobinPolicy
If `distance` is called before `on_add/up` then we would end up with null `local_dc` value if the value wasn't specified in the constructor.
1 parent c381c19 commit c306d61

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

cassandra/policies.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ def populate(self, cluster, hosts):
264264

265265
def distance(self, host):
266266
dc = self._dc(host)
267+
if not self.local_dc:
268+
self.local_dc = dc
269+
return HostDistance.LOCAL
267270
if dc == self.local_dc:
268271
return HostDistance.LOCAL
269272

0 commit comments

Comments
 (0)