Jump to content

Error with loop.py script on Riky


georgemo

Recommended Posts

Hello,

 

I have just tried this script posted on this forum  https://www.helionet.org/index/topic/29129-python-script-behavior/?p=132451
But I get an internal error 500:

 

Here is it: http://georgemo.heliohost.org/cgi-bin/loop.py

 

 

 

My intention is to run this script in loop to handle bot messages. So I would also like to get 

module telepot

 implemened

import telepot
import time
from telepot.loop import MessageLoop




def handle(msg):
    content_type, chat_type, chat_id = telepot.glance(msg)


    if content_type == 'text':
        text = msg['text']
        print(text)


        bot.sendMessage(chat_id = chat_id, text = "This message has been sent by heliohost")




        






#----------------MAIN---------------------------




bot = telepot.Bot("441478801:AAFlc7xxxxxxxSSzSEm0")


MessageLoop(bot, handle).run_as_thread()
print('Listening ...')
# Keep the program running.
while 1:
    time.sleep(100)

Thank you :)

 

Link to comment
Share on other sites

We have a maximum runtime on scripts, so the script is timing out and producing that error. Scripts that are designed to indefinitely will hit their time limit and be killed by the server in order to help keep load down. Apache spits out a 500 error when the process its waiting on dies unexpectedly without producing output (which is what happens when python is killed).

 

In laymans terms...it won't run here by design. We can't host scripts that are designed to be background processes.

Link to comment
Share on other sites

You need a VPS to run this. With a VPS you have your entire own virtual server, with its own operating system installation and resources, and you can use the virtual server however you want. Always-running bots like yours are a common use, as are game servers, websites that need lots of resources, etc.

 

The bad news is that you'll have a difficult time finding such an offering for free. :( Even we can't afford to offer them free: https://heliohost.org/vps For what you're doing, the cheapest $4/month plan would be plenty.

Link to comment
Share on other sites

As long as the scripts don't cause a lot of load they should be fine. If you read the link that you posted there is actually 3 scripts. One to start the script that you access with a browser, one to end the script that you access with a browser, and a loop script that you don't access in a browser. If you run the loop.py directly you'll get a 500 error when you browser closes, times out, or the http process kills it, etc. Also I don't see a shebang on your script that you posted. Did you just omit that?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...