1 year ago
#385495
Vincer
restarting kernel in a loop in python
I am trying to run a code using the api and the problem is it aborts the connection every few times and the only way to fix is to restart the kernel. I was wondering if there is any way in python to restart the kernel in try/except format inside a loop that runs every 5 minutes?
Something like this:
def execution():
try:
main_code()
except:
while check_connection != True:
try:
connection_command (to the api)
break
except:
restart_kernel
main_code()
In the above I am trying to see if the connection to api is good, if not restart the kernel and re-establish the connection.
Is it even possible?
Thank you
python
api
jupyter
restart
0 Answers
Your Answer