to fetch emails every N minutes or hours  -
http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html
I want the user to know that the mails are being retrieved -
https://channels.readthedocs.io/en/latest/

On Mon, Jul 2, 2018 at 3:53 PM, Vineeth Sagar <tv...@snu.edu.in> wrote:

> Problem:
> We are developing a email-CRM. The task at hand is to fetch emails every N
> minutes or hours. I have received a codebase written by another guy who
> left the company,my job is to re-write/re-factor. The guy who previously
> wrote the code started a thread whenever a user logged and he put a
> time.sleep() inside it, There's no limit on number of threads that can be
> initialized, if 100 users log in, we will have 100 active threads, he used
> locks so that at any given time only one thread can be executed.
>
> Solution:
> It's messy in so many ways(mentioned above) and I think writing django
> middleware would be appropriate for this task. So here's what I plan to do,
> using a Django cache I store a Python datetime object and a flag to see if
> there is any other request that's already retrieving the mails, I don't
> want multiple requests to retrieving mails at once. Is this a better idea?
> Are there any other ways to do this particular task?
>
> One more doubt I have is I want the user to know that the mails are being
> retrieved so he doesn't refresh the page passive-aggressively. How can I do
> this? I want the user to know it's happening and in the background
> middleware should be executed, I have to keep retrieving mails and once
> it's completed I'll execute the view_func parameter received via the
> process_request hook.
>
> I am a junior at the company(Start up),I am fairly new to django, I keep
> reading the documentation and find new things daily,after picking my mind
> for a day this to me seems best, but please if you have any suggestion let
> me know. Please help me out. Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/c563187e-a3ee-49c0-8c56-cb924a128891%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/c563187e-a3ee-49c0-8c56-cb924a128891%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOM-Qa1tkqF-SF6P-ThS4g3yLJJ79VrsbHJdpv6vKxDTo%2BWtUw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to