Hi, I was wondering how does scheduling the same t...
# prefect-community
Hi, I was wondering how does scheduling the same task to run with different parameters at the same time work? It seems to not work as I imagined it should. Maybe it seems there is a limitation to only have one task at a specific time of day. Does anyone have any insight on this setup?
Hi @Richard Hughes, it's straightforward to do this, you just use multiple Clocks in a Schedule. Here's an example from a personal project of mine:
Copy code
family_datetimes = [
    pendulum.parse("2020-07-15T17:30:00", tz="America/New_York"),
    pendulum.parse("2020-07-16T17:30:00", tz="America/New_York"),
    pendulum.parse("2020-07-18T15:00:00", tz="America/New_York"),
    pendulum.parse("2020-07-19T15:00:00", tz="America/New_York")
family_attendees = ["Sarah", "Joe", "Kid1", "Kid2"]
family_schedule_datetimes = [r.add(days=-2) for r in family_datetimes]

nanny_datetimes = [
    pendulum.parse("2020-07-17T12:30:00", tz="America/New_York"),
nanny_attendees = ["Maria", "Kid1", "Kid2"]
nanny_schedule_datetimes = [r.add(days=-2) for r in nanny_datetimes]

family_clock = DatesClock(dates=family_schedule_datetimes, parameter_defaults={"attendees": family_attendees})
nanny_clock = DatesClock(dates=nanny_schedule_datetimes, parameter_defaults={"attendees": nanny_attendees})
schedule = Schedule(clocks=[family_clock, nanny_clock])

with Flow("PoolReservation", schedule=schedule) as flow:
These don't happen to be at the same time, but they could be. Hopefully this helps!
⬆️ 1
@Joe Schmid thanks for your reply. I am using a CronClock schedule such as the following:
Copy code
GenericSchedule = Schedule(clocks=[
    CronClock(cron="0 5 * * 1",start_date=pendulum.now("America/Chicago"),parameter_defaults={"Name": "A"}),
    CronClock(cron="50 * * * *",start_date=pendulum.now("America/Chicago"),parameter_defaults={"Name": "B"}),
    CronClock(cron="50 * * * *",start_date=pendulum.now("America/Chicago"),parameter_defaults={"Name": "C"})

with Flow(schedule=GenericSchedule) as flow:
When the flow is registered I would expect to see B and C scheduled but, I am only seeing B scheduled and only B is running.
@Richard Hughes ah, that makes sense re: CronClock. It looks like it's a known issue and there's an open Github issue to track it: https://github.com/PrefectHQ/prefect/issues/2510 Would it work for you to use IntervalClock as a workaround for now or have one of those CronClocks run a minute later?