Skip to main content
Example

#test.py
from pytasks import App
from datetime import datetime as dt
from datetime import timedelta as td
class T:
def __init__(self, taskid):
self.times = 10 #<--------------the largest number of this task will be executed
self.now = dt.now()
self.every = td(seconds=4) #<------frequency of task being polled
self.taskid = taskid
def __call__(self): #<--------------content of task
print self.taskid, ":", dt.now()-self.now
self.now =dt.now()
def schedule(self): #<--------------task'schedule:
return dt.now()+td(seconds=2) #return bool() or datetime.datetime(...)[means the time to run task]
task1 = T(1)
task2 = T(2)
#set task2's schedule
task2.schedule = lambda: True if os.environ['LOGNAME']=='root' else False
app = App()
app.add(task1)
app.add(task2
app.run()

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytasks-1.1.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file pytasks-1.1.tar.gz.

File metadata

  • Download URL: pytasks-1.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pytasks-1.1.tar.gz
Algorithm Hash digest
SHA256 1784512f7e18ed63b1121b8f14bc657b7bea909d7dab06233cf5843a2f23c423
MD5 a04449c228d5cc34b82baadf98944b91
BLAKE2b-256 c9caf9739a58a21c10ad2806c0213629b16a139ad87629b4f04ae007cd5800dd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page