Comments (8)
in django-celery-beat/model.py
, it does not support nowfun, i think you can extend CrontabSchedule
to solve your problem.
from django-celery-beat.
Yes, I'm exploring options for extending it. Could pickle the lambda expression and store the string in CrontabSchedule, but that's pretty ugly... not sure how else to do it while making it compatible with already-existing schedules containing a nowfun, though.
Edit: One potential option would be to add a timezone field to CrontabSchedule. Then modify the schedule() method to create a nowfun that just uses datetime.now(timezone). This does not make the from_schedule() method start working correctly, however.
from django-celery-beat.
Hi.
Is there any predicted support for this feature? It is quite valuable to set events that are timezone aware.
Thanks
from django-celery-beat.
I believe b6c0581 fixes this issue and it is available in 1.1.0.
Please let me know if I'm wrong and I'll reopen this issue.
from django-celery-beat.
We still get
TypeError: can't pickle function objects
when trying to use
"schedule": crontab(hour=14, minute=38, nowfun=zonenowfun)
with zonenowfun = lambda: datetime.datetime.now(one_zone)
and 1.1.0
Any clues as to what is the problem?
from django-celery-beat.
You cann't pickle lambdas. Use a normal function.
from django-celery-beat.
A normal function, in this particular context, has the same issue because it is being created within a for loop which iterates over different timezones (we create a different task for each timezone).
My main gripe with this issue is that this code was working with djcelery and it is pretty much taken from several online tutorials using celery and djcelery. When I upgraded a relatively legacy project to new celery versions (which have deprecated djcelery), this completely broke down, and there seems to be no way to do the same thing. The Celery documentation also does not state anything regarding limitations with nowfun.
Is there no planned fix for this? In my project we have worked around the issue, but it might hit other people. As an example, this thread often comes up in search results for celery and timezones.
from django-celery-beat.
Hello,
As I needed this, I implemented a fork that allows to define CRON tasks in different timezones, by adding a timezone field to CrontabSchedule and subclassing celery.schedules.crontab. Let me know what you think !
See #99
from django-celery-beat.
Related Issues (20)
- Custom schedule type is not being used
- django 5.0 HOT 24
- CrontabSchedule uniqueness HOT 3
- celery beat_schedule can not automove HOT 1
- schedule task HOT 1
- (Django 5.0.1) AttributeError at /admin/django_celery_beat/crontabschedule/add/ HOT 3
- can I reduce number of beats? HOT 1
- I think there is no longer a need for `self.celery_app.loader.import_default_modules()` in the admin HOT 7
- Received unregistered task of type <app.tasks.function_name> HOT 1
- Rethinking total_run_count reset for one-off tasks in is_due HOT 1
- Add `sphinxcontrib-django` to docs extensions
- Error in logfile HOT 3
- Getting RuntimeWarning with django-celery-beat==2.6.0, django==5.0.3 HOT 7
- Admin: show tasks for each schedule
- Scheduled tasks not running despite showing in beat config HOT 1
- Invalid crontab is created, but breaks database scheduler
- migration returns error HOT 1
- Logging system exception when celery beat can not connect to redis
- Remove Strict Upper Version Limit for Django HOT 12
- How to update PeriodicTask after updating tasks in `app.conf.beat_schedule` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-celery-beat.