I'm currently integrating python celery to do some task. What I really want to acheive is to assign crontab with CUSTOMIZE TIMEZONE.
For example:
task_timezone = datetime.now(timezone('US/Eastern')) + timedelta(hours=7)
Each task is designed to run on US/Eastern time plus 7 hours as timezone.
Already tried Celery beat - different time zone per task
Not working on my end. What I did in my code as follow:
Method 1:
nowfun = lambda: datetime.now(timezone('US/Eastern')) + timedelta(hours=7)
....
'schedule': crontab(minute='1', hour='1', day_of_week=[1, 2, 3, 4, 5], nowfun=nowfun)
But this code gives me this error:
Can't pickle <function <lambda> at 0x7f74326264c0>: attribute lookup <lambda>
So I tried method 2:
def nowfun():
return datetime.now(timezone('US/Eastern')) + timedelta(hours=7)
....
'schedule': crontab(minute='1', hour='1', day_of_week=[1, 2, 3, 4, 5], nowfun=nowfun)
But this time, I got this error:
tzinfo argument must be None or of a tzinfo subclass, not type 'function'
Any idea how to resolve this issue?