Skip to content
← Back to Community
NEVER have your Python Repls go to sleep again!
Profile icon
h
has Hacker Plan
c4syner

What?

You heard that right! This ₜᵢₙᵧ addition to your program allows is it stay alive and running indefinitely.

Why?

I wanted to be able to have my discord bot stay awake without the use of external ping programs.

How?

Using a small flask server and some threaded pinging loops.

How do I get started?

Add the neverSleep.py file to your project and paste the following code to the top of your main.py:

import neverSleep neverSleep.awake('YOUR AUTO GENERATED WEBSITE URL')

That's it!
If this gets enough popularity I'll add it to PyPi to make it even easier.

Voters
Profile icon
4515384697
Profile icon
Turtle84375
Profile icon
SickBricksBrick
Profile icon
GaubanataRobert
Profile icon
MushyAvocado
Profile icon
MarceloBatista4
Profile icon
shahryarg
Profile icon
LastedApple3
Profile icon
CoffeeGuy
Profile icon
yeetuscleetus
Comments
hotnewtop
Profile icon
CoffeeGuy

does this still work?? :D

Profile icon
c4syner

@CoffeeGuy Had to update it but it appears to be working now! ping me here if you need help setting it up.

Profile icon
CoffeeGuy

@c4syner OK :D

Profile icon
Rockpods

@c4syner There is a more efficient way to do this. REPLIT ENV contains REPL_SLUG and REPL_OWNER which can be used to generate the URL without input.

import os replNeverSleep.awake('https://'+str(os.environ['REPL_SLUG']).lower()+'.'+str(os.environ['REPL_OWNER']).lower()+'.repl.co', True)
Profile icon
c4syner

@Rockpods Haha I forgot about this project! Throwback to my high-school days learning Python. Anyways, that's good to know for anyone looking at this project nowadays. I'll do you one better though:

replNeverSleep.awake(f"https://{str(os.environ['REPL_SLUG']).lower()}.{str(os.environ['REPL_OWNER']).lower()}.repl.co", True)
Profile icon
105303058

I have tried it 10 minutes ago.
Hope this works!
Keep going!
Very appreciate!!

Profile icon
TobiasKosin

This is not working for me, just added the nebersleep file, imported it to my main py and used the awake method at the top. Someone got the same issue or know a working solution?

Profile icon
c4syner

@TobiasKosin Have you made sure to put your program's own url rather than mine?
(The highlighted should be changed with your own code)
image
Checked today, and this is still operational!

Profile icon
SixBeeps

but what about node?

Profile icon
c4syner

@SixBeeps you technically could put in ANY website (including a node.js repl) and have it keep online.

Profile icon
SixBeeps

@c4syner I mean, considering this was written in Python, it wouldn't work. Node.js doesn't do flask.

Profile icon
c4syner

@SixBeeps No no... If you were to use a different programming language other than python. It will work because it's really just a scheduled ping program. The thing to note here is that this is outside of node.

Profile icon
SixBeeps

@c4syner You mentioned that you'd add this to your program to make it work. Do you mean like make another Repl to keep it alive?