Меняйте время между задачами в соответствии с волновой функциейPython

Программы на Python
Гость
Меняйте время между задачами в соответствии с волновой функцией

Сообщение Гость »


I need to run amount of tasks in a day, and I need the frequency of the tasks to vary according to a wave function (with a period of , or with one peak per day and horizontal shift of - I need to find the amplitude/vertical shift).
So I have the total daily tasks I want to run and I need to know how much time to sleep between them, according to time of day - how can I get to that equation? Can this be achieved in a simpler manner?
Example:

Код: Выделить всё

from datetime import datetime
from time import sleep

def get_daily_tasks(...):
...

def run_task(...):
...

def main(): # to be run daily
num_tasks = get_daily_tasks(...)
for _ in range(num_tasks):
run_task(...)
sleep_timer = sleep_timer(num_tasks, datetime.now())  # This is what I need to find
sleep(sleep_timer)


Источник: https://stackoverflow.com/questions/781 ... e-function

Вернуться в «Python»