Skip to content

Python decorators that only let a function or method run within specified times

License

Notifications You must be signed in to change notification settings

datamade/bankers-hours

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bankers-hours

Python decorator that will only let a function or method run during specified times

import datetime

import dateutil
from bankershours import within_hours, within_hours_method

TIMEZONE = tz.gettz('America/Chicago')

@within_hours(start_time=datetime.time(9, 0, tzinfo=TIMEZONE),
              end_time=datetime.time(5, 0, tzinfo=TIMEZONE))
def time_sensitive_function():
    ...


class SomeClass(object):

    def __init__(self, start_time, end_time):
        self.start_time = start_time
	self.end_time = end_time

    @within_hours_method
    def time_sensitive_method():
        ...

About

Python decorators that only let a function or method run within specified times

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages