LT-14761: Fix infinite loop when called with invalid project

Check for timeout at each loop iteration.

Change-Id: I3b0622972c335d13f78e871aa1002f1522c95c95