comparison hgext/zeroconf/Zeroconf.py @ 51701:97d013f48cae

zeroconf: fix boolean return value This was (wrongly) flagged by Pytype as being undefined since it doesn't seem to understand `try` blocks. However, the caller is expecting a boolean and the fix to appease Pytype is simple, so we do both.
author Raphaël Gomès <rgomes@octobus.net>
date Thu, 18 Jul 2024 12:02:01 +0200
parents 7f0cb9ee0534
children 454feddab720
comparison
equal deleted inserted replaced
51700:7f0cb9ee0534 51701:97d013f48cae
1305 """ 1305 """
1306 now = currentTimeMillis() 1306 now = currentTimeMillis()
1307 delay = _LISTENER_TIME 1307 delay = _LISTENER_TIME
1308 next = now + delay 1308 next = now + delay
1309 last = now + timeout 1309 last = now + timeout
1310 result = False
1310 try: 1311 try:
1311 zeroconf.addListener( 1312 zeroconf.addListener(
1312 self, DNSQuestion(self.name, _TYPE_ANY, _CLASS_IN) 1313 self, DNSQuestion(self.name, _TYPE_ANY, _CLASS_IN)
1313 ) 1314 )
1314 while ( 1315 while (
1350 next = now + delay 1351 next = now + delay
1351 delay = delay * 2 1352 delay = delay * 2
1352 1353
1353 zeroconf.wait(min(next, last) - now) 1354 zeroconf.wait(min(next, last) - now)
1354 now = currentTimeMillis() 1355 now = currentTimeMillis()
1355 result = 1 1356 result = True
1356 finally: 1357 finally:
1357 zeroconf.removeListener(self) 1358 zeroconf.removeListener(self)
1358 1359
1359 return result 1360 return result
1360 1361