it seems that when reactor is running, it won't receive new event any more.
This isn't the case. Events only happen when the reactor is running!
You didn't share the version of the code that uses addErrback
, so I can't see if there was a problem in how you were using it. However, since you're already using deferredGenerator
, a more idiomatic approach would be:
page = None
for i in range(numRetries):
wfd = defer.waitForDeferred(getPage(url,timeout=10))
yield wfd
try:
page = wfd.getResult()
except TimeoutError:
# Do nothing, let the loop continue
pass
else:
# Success, exit the loop
break
if page is None:
# Handle the timeout for real
...
else:
# Continue processing
...