Giter Site home page Giter Site logo

Comments (8)

mapleflow avatar mapleflow commented on July 17, 2024

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.

nl3v avatar nl3v commented on July 17, 2024

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.

Jorl17 avatar Jorl17 commented on July 17, 2024

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.

thedrow avatar thedrow commented on July 17, 2024

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.

Jorl17 avatar Jorl17 commented on July 17, 2024

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.

thedrow avatar thedrow commented on July 17, 2024

You cann't pickle lambdas. Use a normal function.

from django-celery-beat.

Jorl17 avatar Jorl17 commented on July 17, 2024

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.

tartieret avatar tartieret commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.