If you are using PythonAnywhere, they have Scheduled Tasks and (for paid 
accounts) an Aways-on Task. 
These are very simple to use. I use them for managing the queue of outgoing 
emails.

Andy

On Wednesday, September 2, 2020 at 5:09:15 PM UTC+10 mostwanted wrote:

> You are on point Jim, you get what i'm trying to achieve, let me see if i 
> can put it together.
>
> Regards;
>
> On Tuesday, September 1, 2020 at 8:48:34 PM UTC+2 Jim S wrote:
>
>> Ah, so this sounds a little different than what I thought you were after.
>>
>> Looks like you want to run a task at a regularly scheduled time, not 
>> based on something that you've triggered in your application.
>>
>> Given that information, I'd turn to the scheduler on my host system.  Are 
>> you running Linux then I'd just create a cron job.  Windows - add it to the 
>> windows scheduler (they still have that on windows server, right?)
>>
>> Then I would go here ->  
>> http://web2py.com/books/default/chapter/29/04/the-core#Command-line-options
>>
>> to learn how to craft a command that would call my script to determine 
>> who to send emails to, and then send them.
>>
>> Does that help?
>>
>> (or, please correct me if my understanding of your problem is still off)
>>
>> -Jim
>>
>>
>> On Tuesday, September 1, 2020 at 11:59:02 AM UTC-5, mostwanted wrote:
>>>
>>> Hey Jim, I'm failing to understand the scheduler, please if its not a 
>>> bother simplify it for me. In my script below I wanna send users who host 
>>> stuff on my site emails when their subscription is left with 7 days to 
>>> expire. Ideally twice a week for these 7 days. I'm hosting my app with 
>>> pythonanywhere. How do i put it together?
>>>
>>> *CODE*:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> *import datetimedef email_reminder():    
>>> dt=db(db.house_owner).select()    for dt in dt:            
>>> now_dt=dt.expiry_date-request.now.date()            
>>> now_dt2=now_dt.days            new_con=dt.controller+1            if 
>>> now_dt2 <= 7:                mail.send(to=dt.email_address,subject="House 
>>> Hosting Reminder",message ='Hello %s %s, \nThis is a reminder that your 
>>> house listing with our service will expire in %d days. \nTo increase your 
>>> suscription time or for further details please contact us at the given 
>>> details.\n\nBest regards;' % (dt.Name, dt.Surname, now_dt2))                
>>> db(db.house_owner.controller).update(controller=new_con)*
>>>
>>> *Regards;              *
>>>
>>> On Tuesday, September 1, 2020 at 4:02:42 PM UTC+2 Jim S wrote:
>>>
>>>> The web2py scheduler pretty much is a background task that runs 
>>>> unnoticed.  
>>>>
>>>> I use it in a number of places to queue hundreds or thousands of 
>>>> outbound emails.  I like the scheduler because it then also servers as a 
>>>> log of the emails that were sent.
>>>>
>>>> If that isn't what you're looking for then how about celery or 
>>>> redis-queue?  But, they are a bother because then you have more services 
>>>> you need to grok, start up and manage.  The web2py scheduler takes care of 
>>>> all of that for you.  Let me know if you want to see a sample of how we 
>>>> handle it.
>>>>
>>>> -Jim
>>>>
>>>>
>>>> On Tuesday, September 1, 2020 at 8:41:27 AM UTC-5, mostwanted wrote:
>>>>>
>>>>>
>>>>> Is there a way to have a function always running without having to use 
>>>>> a scheduler?
>>>>> I have a function that i want to always send emails based on its 
>>>>> arguments & conditions but i want it to run in the background unnoticed 
>>>>> like a worker but not run by a scheduler, is this possible? I hope my 
>>>>> question is clear.
>>>>>
>>>>> Regards;
>>>>>
>>>>> Mostwanted 
>>>>>
>>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/b09e640c-fd89-4d03-803a-53b5f9e91df2n%40googlegroups.com.

Reply via email to