@@ -1568,18 +1568,22 @@ async def _execute(
1568
1568
result .args = (msg ,) + result .args [1 :]
1569
1569
raise result
1570
1570
1571
- default_node = nodes .get (client .get_default_node ().name )
1572
- if default_node is not None :
1573
- # This pipeline execution used the default node, check if we need
1574
- # to replace it.
1575
- # Note: when the error is raised we'll reset the default node in the
1576
- # caller function.
1577
- for cmd in default_node [1 ]:
1578
- # Check if it has a command that failed with a relevant
1579
- # exception
1580
- if type (cmd .result ) in self .__class__ .ERRORS_ALLOW_RETRY :
1581
- client .replace_default_node ()
1582
- break
1571
+ default_cluster_node = client .get_default_node ()
1572
+ if default_cluster_node is not None :
1573
+ # Not sure why default_cluster_node is sometimes None; maybe if the object is being
1574
+ # closed during an execution? Either way, this avoids a potential AttributeError
1575
+ default_node = nodes .get (default_cluster_node .name )
1576
+ if default_node is not None :
1577
+ # This pipeline execution used the default node, check if we need
1578
+ # to replace it.
1579
+ # Note: when the error is raised we'll reset the default node in the
1580
+ # caller function.
1581
+ for cmd in default_node [1 ]:
1582
+ # Check if it has a command that failed with a relevant
1583
+ # exception
1584
+ if type (cmd .result ) in self .__class__ .ERRORS_ALLOW_RETRY :
1585
+ client .replace_default_node ()
1586
+ break
1583
1587
1584
1588
return [cmd .result for cmd in stack ]
1585
1589
0 commit comments