dbader / schedule

Python job scheduling for humans.
https://schedule.readthedocs.io/
MIT License
11.73k stars 959 forks source link

Cant seem to run or even schedule a task at all, checked multiple sources all of them have different variations of the same solutions none work #527

Open JamesAib opened 2 years ago

JamesAib commented 2 years ago

This is the code nothing seems to work

@client.event async def on_ready(self): schedule.every(1).seconds.do(self.local, script_path, update()) self.job_func = functools.partial(job_func, *args, **kwargs) schedule.run_pending()

-----------------------------------------------------------------------------------------------------------------------

def do(self, job_func, *args, *kwargs): """ Specifies the job_func that should be called every time the job runs. Any additional arguments are passed on to job_func when the job runs. :param job_func: The function to be scheduled :return: The invoked job instance """ self.job_func = functools.partial(job_func, args, **kwargs) functools.update_wrapper(self.job_func, job_func) self._schedule_next_run() if self.scheduler is None: raise ScheduleError("Unable to a add job to schedule.\n Job is not associated with an scheduler.") self.scheduler.jobs.append(self) return

JamesAib commented 2 years ago

Another sulotion from the docs that did not work

@client.event async def on_ready(): schedule.every(1).seconds.do(self.local, script_path, update()) self.job_func = functools.partial(job_func, *args, **kwargs) schedule.run_pending()

-----------------------------------------------------------------------------------------------------------------------

def do(self, job_func: callable, *args, *kwargs): """ Specifies the job_func that should be called every time the job runs. Any additional arguments are passed on to job_func when the job runs. :param job_func: The function to be scheduled :return: The invoked job instance """ self.job_func = functools.partial(job_func, args, **kwargs) functools.update_wrapper(self.job_func, job_func) self._schedule_next_run() if self.scheduler is None: raise ScheduleError("Unable to a add job to schedule.\n Job is not associated with an scheduler.") self.scheduler.jobs.append(self) return

JamesAib commented 2 years ago

The error

Ignoring exception in on_ready Traceback (most recent call last): File "D:\Præpositi\venv\lib\site-packages\discord\client.py", line 343, in _run_event await coro(*args, **kwargs) File "D:/Præpositi/Global-Guard/Global-Guard.py", line 122, in on_ready schedule.every(1).seconds.do(self.local, script_path, update()) NameError: name 'self' is not defined