Reputation: 824
I want to restart current runtime (Ctrl+M) using code. Something like:
!restart_runtime
Is there such an option?
Upvotes: 5
Views: 8789
Reputation: 21
You can only delete runtime using this code:
from google.colab import runtime
runtime.unassign()
Place runtime.unassign()
command at the end of your script. It will disconnect and delete runtime.
After runtime deleting you should restart this manually or, maybe, using Selenium for automatically browser menu clicking.
Upvotes: 0
Reputation: 38579
The runtime process will restart automatically when halted. So, one way to implement restart_runtime
would be:
import os
def restart_runtime():
os.kill(os.getpid(), 9)
Upvotes: 10