【Google Colaboratory】Prevent Google Colab from disconnecting

Google Colab notebooks have an idle timeout of 90 minutes and an absolute timeout of 12 hours. This means that if a user does not interact with his Google Colab notebook for more than 90 minutes, its instance will be automatically terminated. Also, the maximum lifetime of a Colab instance is 12 hours.

First, enter the cloud hard drive, Colaboratoryopen a . ipynbfile
insert image description here
, enter the file, press F12to pop up the check page at the bottom ,
insert image description here
switch to , console (控制台)enter the following code and press Enter to prevent Colab from disconnecting
insert image description here

function ClickConnect(){
    
    

console.log("Working"); 
document.querySelector("#comments > span").click() 
}
setInterval(ClickConnect,60000)

If you think the time is too short, you can modify the above code 60000to be larger

这不需要点击连接按钮,只是点击评论按钮来保持我的会话活跃(On the Internet, most of the anti-disconnection operations are realized by clicking the connection button)

Guess you like

Origin blog.csdn.net/weixin_42166222/article/details/123229420