Jump to content


Photo

Error with loop.py script on Riky


  • Please log in to reply
4 replies to this topic

#1 georgemo

georgemo

    Newbie

  • Members
  • 2 posts

Posted 14 December 2018 - 02:30 PM

Hello,

 

I have just tried this script posted on this forum  https://www.helionet...avior/?p=132451
But I get an internal error 500:

 

Here is it: http://georgemo.heli...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 :)

 



#2 wolstech

wolstech

    Rank X Member

  • Root Admin
  • 10,147 posts
  • Gender:Male
  • Location:Pennsylvania

Posted 14 December 2018 - 02:43 PM

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.


Please do not PM me for support. Posting on our forums lets all of us learn.

Do you play Minecraft? | Server Monitors | And the Dumbass of the Decade award goes to...


#3 georgemo

georgemo

    Newbie

  • Members
  • 2 posts

Posted 14 December 2018 - 02:48 PM

Thank you for the answer :)

What method would you suggest me to host a python telegram bot that is always running?



#4 wolstech

wolstech

    Rank X Member

  • Root Admin
  • 10,147 posts
  • Gender:Male
  • Location:Pennsylvania

Posted 14 December 2018 - 05:33 PM

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.


Please do not PM me for support. Posting on our forums lets all of us learn.

Do you play Minecraft? | Server Monitors | And the Dumbass of the Decade award goes to...


#5 Krydos

Krydos

    Rank X Member

  • Root Admin
  • 17,826 posts
  • Gender:Male

Posted 14 December 2018 - 06:01 PM

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?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users