Hello, So I'm trying to get a bot online 24/7 using the scheduled task trick. I copied the example and set the task to run every hour in "Schedule" but it seems to be failing.
Traceback
Traceback (most recent call last):
File "/home/Necro/necrobot/starter.py", line 25, in <module>
from bot import *
File "/home/Necro/necrobot/bot.py", line 28
async def get_pre(bot, message):
^
SyntaxError: invalid syntax
2017-08-03 20:41:06 -- Completed task, took 2.00 seconds, return code was 1.
So the error is coming from code in the bot but only when I import it to the file used to check whether it's running. Here's the code I use to check if it's running, a slightly modified version of the example:
import logging
import socket
import sys
from bot import *
lock_socket = None # we want to keep the socket open until the very end of
# our script so we use a global variable to avoid going
# out of scope and being garbage-collected
def is_lock_free():
global lock_socket
lock_socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
try:
lock_id = "necro.necrobot" # this should be unique. using your username as a prefix is a convention
lock_socket.bind('\0' + lock_id)
logging.debug("Acquired lock %r" % (lock_id,))
return True
except socket.error:
# socket already locked, task must already be running
logging.info("Failed to acquire lock %r" % (lock_id,))
return False
if not is_lock_free():
sys.exit()
And if people think the bot code is really the trouble they can check it out there, but it works fine from my computer and when starting it manually. https://github.com/ClementJ18/necrobot
Thanks for any help