Open Morgon opened 2 years ago
I dont see how to make this possible. The decorator expect a ready to use function. In that case you don't know where to find an instance (self)
A solution may be to instanciate an instance before setting the cron:
instance = Myclass()
aiocron.crontab('* * * * *', func=instance.crontest)
Should work in __init__
too:
class Myclass:
def __init__(self):
aiocron.crontab('* * * * *', func=self.crontest)
(not tested)
Placing it in __init__
should fix this (it did for me).
class cogtest(commands.Cog):
def __init__(self, client):
self.client = client
@aiocron.crontab('0 8 * * *')
Pardon the potentially-simple question/issue. Given a simple class, what is preventing aiocron from properly executing the decorated function?
This results in the following error:
Short of "don't use classes", is there some other structure I can use to utilize the convenient decorator?