Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Periodic decorator does not work when multiple plugins use the periodic decorator #309

Open
jaybz opened this issue Jul 15, 2020 · 1 comment

Comments

@jaybz
Copy link

jaybz commented Jul 15, 2020

Using the following plugin code works if this is the only plugin using periodics:

import gremlin

@gremlin.input_devices.periodic(0.5)
def periodic():
    gremlin.util.log("Fire!")

Once you copy this code onto a plugin with a different name, periodics stop working altogether. Even just adding a new instance of the previous plugin instead of creating a separate plugin also triggers this issue. Note that not just the 2nd instance/plugin doesn't work when added, the first instance/plugin also stops working.

@HexaKhan
Copy link

HexaKhan commented Mar 5, 2024

Through trial and error, I've discovered this issue only seems to occur if you have multiple plugins that happen to utilize the exact same periodic time period.

Ex:
If you have Plugin A with:

import gremlin

gremlin.util.log("Starting Script 1")

@gremlin.input_devices.periodic(1)
def testing_loop_1():
    gremlin.util.log("Running Test on Script 1")

And Plugin B with:

import gremlin

gremlin.util.log("Starting Script 2")

@gremlin.input_devices.periodic(1)
def testing_loop_2():
    gremlin.util.log("Running Test on Script 2")

The only output you get is:

2024-03-04 21:34:28 Starting Script 1
2024-03-04 21:34:28 Starting Script 2

It's like neither runs the periodic function.

But if you update plugin A to utilize a periodic time of 1.0001 instead of 1, it seems to work OK

2024-03-04 21:37:59 Starting Script 1
2024-03-04 21:37:59 Starting Script 2
2024-03-04 21:38:00 Running Test on Script 2
2024-03-04 21:38:00 Running Test on Script 1
2024-03-04 21:38:01 Running Test on Script 2
2024-03-04 21:38:01 Running Test on Script 1
2024-03-04 21:38:02 Running Test on Script 2
2024-03-04 21:38:02 Running Test on Script 1
2024-03-04 21:38:03 Running Test on Script 2
2024-03-04 21:38:03 Running Test on Script 1
2024-03-04 21:38:04 Running Test on Script 2
2024-03-04 21:38:04 Running Test on Script 1
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants