question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem on combining triggers

See original GitHub issue

Hi, I’m trying to use combine triggers. For example, I want to run a function on the first minute for every 2 seconds:

from time import sleep
from apscheduler.triggers.combining import AndTrigger
from apscheduler.triggers.interval import IntervalTrigger
from apscheduler.triggers.cron import CronTrigger
from apscheduler.schedulers.background import BackgroundScheduler


def job_function():
    print("hello from function")


if __name__ == "__main__":
    scheduler = BackgroundScheduler()
    trigger = AndTrigger([IntervalTrigger(seconds=2),
                          CronTrigger(minute=1)])
    scheduler.add_job(job_function, trigger)
    print("before start", scheduler.get_jobs())
    scheduler.start()
    print("after start", scheduler.get_jobs())
    print("ok")
    while True:
        sleep(.1)

But the program never prints after start. It is very strange to me. The OrTrigger works fine for this example. If it is a bug is there any workaround?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
agronholmcommented, May 15, 2018

Why not just: day=10, hour=10, second='*/10'?

0reactions
agronholmcommented, Aug 17, 2022

The proper solution would have been to use CronTrigger(minute=1, second="*/2"). v4.0.0a1 also includes a threshold parameter for AndTrigger which can be used to solve the issue of the trigger run times not matching exactly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

mixing triggers - MOD WIGGLER
I've combined triggers with mixers, no problems mostly. I have found an offset/attenuator to be useful with triggers, a little offset ...
Read more >
How to Consolidate Triggers and Why It's a Good Idea
One of the biggest reasons to consolidate triggers is to control the order of execution. If you have multiple triggers on the same...
Read more >
Problem-solving: triggers and behaviors - LinkedIn
A defined process provides a path for team members to follow, lets them know expected behavior, and helps teams navigate issues from root-cause ......
Read more >
Can I combine two triggers in an automation
Looking to make an automation triggered if the issue is new OR if the issue is moved. Need to know how to combine...
Read more >
Combined problem triggers in simultaneous interpreting
The complexity of simultaneous interpreting may be influenced by so-called problem triggers, i.e. factors that increase the interpreter's ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found