xxxxxxxxxx
Keep the notebook active
The easiest way to prevent Colab from disconnecting is to keep the notebook active. This means you must interact with the notebook every few minutes to keep the VM alive. One way to do this is to run a loop that prints a message every few minutes. For example, you can run the following code to print a message every 10 minutes:
import time
while True:
print("Still running...")
time.sleep(600)
xxxxxxxxxx
CTRL+SHIFT+I
function ClickConnect(){
console.log("Clicked on connect button");
document.querySelector("colab-connect-button").click()
}
setInterval(ClickConnect,60000)
xxxxxxxxxx
#Set a javascript interval to click on the connect button every 60 seconds.
#Open developer-settings (in your web-browser) with Ctrl+Shift+I then click
#on console tab and type this on the console prompt.
#(for mac press Option+Command+I)
function ConnectButton(){
console.log("Connect pushed");
document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#connect").click()
}
setInterval(ConnectButton,60000);
xxxxxxxxxx
setInterval(() => {
document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#connect-icon").shadowRoot.querySelector("paper-button").click()
console.log('click!')
}, 60000)
xxxxxxxxxx
function ClickConnect(){
console.log("Working");
document.querySelector("#comments > span").click()
}
setInterval(ClickConnect,5000)
xxxxxxxxxx
function ClickConnect(){
console.log("코랩 연결 끊김 방지");
document.querySelector("colab-toolbar-button#connect").click()
}
setInterval(ClickConnect, 60 * 1000)