# Python's Timer: from threading import Timer

**URL:** <https://forum.inductiveautomation.com/t/pythons-timer-from-threading-import-timer/64268>\
**Category:** Ignition\
**Tags:** perspective, scripting, ignition81\
**Created:** [September 20, 2022, 8:28am UTC](https://forum.inductiveautomation.com/t/pythons-timer-from-threading-import-timer/64268 "2022-09-20T08:28:56Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [September 20, 2022, 11:41am UTC](https://forum.inductiveautomation.com/t/pythons-timer-from-threading-import-timer/64268/6 "2022-09-20T11:41:06Z")

</div>

> [@tupanaster](#):
>
> Are those legacy scoping issues related to Script Hint Scope?

No. The Script Hint Scope just lets you chose what types of functions it will hint you for. For instance if you set it to Client, then you wont see functions that can only run in the gateway. It's just a "Hint" to what you can use. It doesn't play any role in what scope the script is actually executed in.

Are you testing this in the Designer or in a real Session?

> [@tupanaster](#):
>
> Because invokeAsync doesn’t have a fixed time as a parameter.

`system.util.invokeLater()` has a delay parameter.

[https://docs.inductiveautomation.com/display/DOC81/system.util.invokeLater](https://docs.inductiveautomation.com/display/DOC81/system.util.invokeLater)

I think you're headed down a perilous road here. How do you plan to manage the life cycle of these threads? I see no way to halt or interrupt the timer. What happens if the gateway service needs to be rebooted? Or the project is saved restarting scripting?

See this for some more pertinent information

> [@Managing multiple asynchronous threads](https://forum.inductiveautomation.com/t/managing-multiple-asynchronous-threads/37185/2):
>
> To manage long-running jython threads through scripting restarts, you need to: Place the thread object in a dictionary that retains its content through script restarts. I used to recommend the dictionary from system.util.getGlobals(), but that is no longer suitable. I created a free [Life Cycle Module](http://forum.inductiveautomation.com/t/system-util-getglobals-not-persisted-across-designer-save/33869/14) that provides such dictionaries going forward. Write the asynchronous function’s loop so that it regularly checks [Thread.interrupted()](https://docs.oracle.com/javase/8/docs/api/java/lang/Thread.html#interrupted--), particularly after any java I/O operations. Clean up …

---

_[View the full topic](https://forum.inductiveautomation.com/t/pythons-timer-from-threading-import-timer/64268)._
