Consider using a time.time() + timeout as deadline and then:
while time.time() < deadline: ......