ipnbdoctest: attempt to restart when the kernel dies
* tests/python/ipnbdoctest.py: Catch kernel deaths, wait a random number of seconds, and try again up to three times.
This commit is contained in:
parent
9d70eeef97
commit
5dc6da0b20
1 changed files with 18 additions and 2 deletions
|
|
@ -18,6 +18,7 @@ import time
|
|||
import base64
|
||||
import re
|
||||
import pprint
|
||||
import random
|
||||
from difflib import unified_diff as diff
|
||||
|
||||
from collections import defaultdict
|
||||
|
|
@ -324,5 +325,20 @@ def test_notebook(ipynb):
|
|||
|
||||
if __name__ == '__main__':
|
||||
for ipynb in sys.argv[1:]:
|
||||
tries=3
|
||||
while tries:
|
||||
print("testing %s" % ipynb)
|
||||
try:
|
||||
test_notebook(ipynb)
|
||||
break
|
||||
except RuntimeError as e:
|
||||
# If the Kernel dies, try again. It seems we have spurious
|
||||
# failures when multiple instances of jupyter start in parallel.
|
||||
if 'Kernel died' in str(e):
|
||||
tries -= 1
|
||||
if tries:
|
||||
s = random.randint(1, 5)
|
||||
print("trying again in", s, "seconds...")
|
||||
time.sleep(s)
|
||||
else:
|
||||
raise e
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue