Skip to content

Instantly share code, notes, and snippets.

@josepdecid
Last active November 2, 2023 10:06
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save josepdecid/7fe5aa9120e176e1fb168ed7c873a550 to your computer and use it in GitHub Desktop.
Save josepdecid/7fe5aa9120e176e1fb168ed7c873a550 to your computer and use it in GitHub Desktop.
Colab Reconnect
// Interval time to check if runtime is disconnected
interval = 1000 * 60;
// Busy/Reconnect button top-right
reloadButton = document.querySelector('#connect > paper-button > span')
setInterval(() => {
if (reloadButton.innerText == 'Reconnect') {
reloadButton.click();
console.log('Restarting');
} else console.log('Keeps working');
}, interval);
@josepdecid
Copy link
Author

Sometimes Google Colab disconnects us from the runtime when the connection with our machine is bad, but the good part is that reconnecting the environment quickly allows us to continue the execution from the same point and not having to start again.

  1. In https://colab.research.google.com write down your code to execute in a session.
  2. Go to Developer options > Console in your browser.
  3. Paste the Gist code and run press Enter.

@josepdecid
Copy link
Author

I'm not sure if this works anymore, just leaving it here as a reference!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment