skip to navigation
skip to content

Not Logged In

pyriodic 0.2.4

A scheduler that uses dateutil to run periodic jobs.

A scheduler that uses dateutil to run periodic jobs.

This project is in the alpha stage so there is a lot yet to do. It is coded in Python 3.3 and
with a couple minor tweaks it has been ported to 2.7.

Installation
~~~
pip install pyriodic

Usage
~~~

Schedule recurring jobs by specifying at least a desired interval from dateutil's rrule module.
Or schedule delayed jobs to run after any number of hours, minutes, seconds etc.

Example
~~~
from datetime import datetime

from pyriodic.pyriodic import Scheduler, HOURLY, MINUTELY

print('Program starting at', datetime.now())
sched = Scheduler()
message = 'Hello from argumentland.'

def run_test1(mes):
print('This is test 1.', mes, datetime.now())
return mes

sched.add_recuring_job(run_test1, args=(message,), interval=MINUTELY)

@sched.schedule_recuring_job(interval=MINUTELY, start_time='21m 30S')
def run_test2():
print('This is test 2.', datetime.now())

run_test2()

Output
~~~
Program starting at 2014-05-26 19:22:11.514066
This is test 1. Hello from argumentland. 2014-05-26 19:23:00.011272
This is test 1. Hello from argumentland. 2014-05-26 19:24:00.000703
This is test 2. 2014-05-26 19:24:30.008419
This is test 1. Hello from argumentland. 2014-05-26 19:25:00.009135
This is test 1. Hello from argumentland. 2014-05-26 19:26:00.011567

Intervals included are:
* yearly (haven't had the time to test this one out yet)
* monthly (nor this one)
* daily
* hourly
* minutely
* secondly

Other parameters include:
* string start_date (defaults to today's date)
* string start_time (defaults to midnight)
* integer how_many intervals to run (default is infinite)
* integer retrys upon exceptions (default is 3 times)
* integer retry_delay seconds to delay next run time after exception (default is 10 seconds right now)
* string name the name that the job can then be refered to as (defaults to function name)

Start dates and times are parsed by dateutil so it is flexible in what it excepts.

Go to http://ayehavgunne.github.io/pyriodic/ for more information.

Todo
~~~

1. Add support for Weekly Intervals
1. Add day_of_week option (currently there but doesn't do anything yet)
2. Add weekly to the list of accepted intervals
2. Add timezone awareness
3. Add logging capability
4. Add more options for error handling
1. Add option for a waiting time before the next function call after an exception - Done!
2. Add option for the number of retrys after exceptions - Done!
3. Maybe add the option to execute a different function upon an exception
5. Add docstrings
6. Add options for retrieving the return values
1. Add capturing of return variables into an OrderedDict (keys are the datetime that the return value was captured) for each job - Done!
2. Add option for maximum number of stored return values
7. Named Jobs - Done!

Changelog
~~~

Version 0.2
~~~
* Organized code a bit
* Added named jobs
* Added rudimentary capability to retrieve the return values from each job
* Added ability to limit job to x number of failures and to set the delay after an exception

Version 0.1
~~~
* Initial Release  
File Type Py Version Uploaded on Size
pyriodic-0.2.4-py3.3.egg (md5) Python Egg 3.3 2014-05-27 12KB
pyriodic-0.2.4.zip (md5) Source 2014-05-27 10KB
pyriodic-Python2.7v0.2.4-py2.7.egg (md5) Python Egg 2.7 2014-05-27 11KB
pyriodic-Python2.7v0.2.4.zip (md5) Source 2014-05-27 10KB
  • Downloads (All Versions):
  • 98 downloads in the last day
  • 540 downloads in the last week
  • 569 downloads in the last month
  • Author: Anthony Post
  • Home Page: http://ayehavgunne.github.io/pyriodic/
  • Bug Tracker: https://github.com/Ayehavgunne/pyriodic/issues
  • Download URL: http://ayehavgunne.github.io/pyriodic/
  • Keywords: schedule periodic job task time timer thread calendar clock queue dateutil
  • License:
    This project uses the dateutil library written by Gustavo Niemeyer.
    
    Copyright (c) 2014, Anthony Nelson Post <postanthony3000@gmail.com>
    All rights reserved.
    
    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are met:
    
    * Redistributions of source code must retain the above copyright notice, this
      list of conditions and the following disclaimer.
    
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    
    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  • Requires dateutils
  • Categories
  • Package Index Owner: Ayehavgunne
  • DOAP record: pyriodic-0.2.4.xml