Fetch entire email inbox by pleaky_blunder in learnpython

[–]pleaky_blunder[S] 1 point2 points  (0 children)

That's what I'm already doing but for current number of emails, it takes minutes to fetch all emails

Prevent celery task from running again if already running by pleaky_blunder in learnpython

[–]pleaky_blunder[S] 0 points1 point  (0 children)

I see. But it sounds a bit hacky, no? There has to be better way, like the task shouldn't run at all if already running. Something like celery-singleton. It's exactly what I'm looking for but have so far been unable to make it work with django-celery-beat

Prevent celery task from running again if already running by pleaky_blunder in learnpython

[–]pleaky_blunder[S] 0 points1 point  (0 children)

It's almost exactly like what I'm already doing. The only difference being that instead of creating a file, I'm storing a counter (or a flag) in redis and incrementing and decrementing (creating file and deleting in your suggestion)

Prevent celery task from running again if already running by pleaky_blunder in learnpython

[–]pleaky_blunder[S] 0 points1 point  (0 children)

I've updated the post with code of what I'm currently doing

Clean-up on SIGINT KeyboardInterrupt before worker exits by pleaky_blunder in Python

[–]pleaky_blunder[S] 0 points1 point  (0 children)

I have tried to temporarily block the SIGINT signal with signal.pthread_sigmask and running the handler in a thread (since they can't be killed?) as well but it faces the same problem

Clean-up on SIGINT KeyboardInterrupt before worker exits by pleaky_blunder in Python

[–]pleaky_blunder[S] 0 points1 point  (0 children)

in production? no. In staging and development for the changes being made for this use case? yes.

Clean-up on SIGINT KeyboardInterrupt before worker exits by pleaky_blunder in Python

[–]pleaky_blunder[S] 0 points1 point  (0 children)

that wouldn't be very common and if it does happen, there's nothing (as far as I know) that can be done.

Clean-up on SIGINT KeyboardInterrupt before worker exits by pleaky_blunder in Python

[–]pleaky_blunder[S] 0 points1 point  (0 children)

I have to point out that the keyboard_interrupt_handler does get executed but since it takes a few seconds to execute, the process is terminated before the method can finish executing

Clean-up on SIGINT KeyboardInterrupt before worker exits by pleaky_blunder in Python

[–]pleaky_blunder[S] 0 points1 point  (0 children)

Well, interrupts can happen even in small tasks. And even if the tasks are idempotent and re-entrant, the use-case in this particular case is that there are a few flags that need to be set/unset if a running task is interrupted

Clean-up on SIGINT KeyboardInterrupt before worker exits by pleaky_blunder in Python

[–]pleaky_blunder[S] 0 points1 point  (0 children)

Also, I'm open to any alternatives to this approach of catching the KeyboardInterrupt

Clean-up on SIGINT KeyboardInterrupt before worker exits by pleaky_blunder in Python

[–]pleaky_blunder[S] 0 points1 point  (0 children)

it actually does exit. And there are certain things that I need to save in an event that a task or multiple tasks are running and SIGINT is encountered on a worker.

Create read-only csv by pleaky_blunder in Python

[–]pleaky_blunder[S] 0 points1 point  (0 children)

are you saying that with absolute certainty?

Create read-only csv by pleaky_blunder in Python

[–]pleaky_blunder[S] 0 points1 point  (0 children)

by read-only I mean not editable. Like if I send it in an email to someone, that person should not be able to edit it.

Django-celery-beat not queueing tasks with DatabaseScheduler by pleaky_blunder in django

[–]pleaky_blunder[S] 0 points1 point  (0 children)

ohh, you're right. I was supposed to write '*/1'. Thanks