# Python Threading in Ignition

**URL:** <https://forum.inductiveautomation.com/t/python-threading-in-ignition/10243>\
**Category:** Ignition\
**Created:** [July 20, 2015, 7:06am UTC](https://forum.inductiveautomation.com/t/python-threading-in-ignition/10243 "2015-07-20T07:06:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ella\_ramos](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ella_ramos/32/3455_2.png) [@ella\_ramos](https://forum.inductiveautomation.com/u/ella_ramos)\
**Post date:** [July 20, 2015, 7:06am UTC](https://forum.inductiveautomation.com/t/python-threading-in-ignition/10243/1 "2015-07-20T07:06:34Z")

</div>

Hi,

I’d like to ask if there’s an equivalent Ignition module for python threading?  
What i want to do is to run a checker for idle time while the application is connected to the actual tool.

I know this is possible to do in python threading. But i need the thread to keep running while the application is up. Should i fire up the thread on the start up script? will the thread or function be able to run until i close the application?

Any idea guys?

Thank you!  
PS : I’ve researched about invokeasnychronous. Am i right that i creates a new thread for the function being called?

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [July 20, 2015, 4:14pm UTC](https://forum.inductiveautomation.com/t/python-threading-in-ignition/10243/2 "2015-07-20T16:14:28Z")

</div>

Hi Ella,

Yes, invokeasnychronous creates a new thread for the function that is called.

Best,

---

<div class="post-metadata">

**Author:** ![ella\_ramos](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ella_ramos/32/3455_2.png) [@ella\_ramos](https://forum.inductiveautomation.com/u/ella_ramos)\
**Post date:** [July 22, 2015, 12:09am UTC](https://forum.inductiveautomation.com/t/python-threading-in-ignition/10243/3 "2015-07-22T00:09:40Z")

</div>

Thanks for confirming Nick.

So is invokeasynchronous same with threading in python?

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [July 22, 2015, 5:03am UTC](https://forum.inductiveautomation.com/t/python-threading-in-ignition/10243/4 "2015-07-22T05:03:59Z")

</div>

They both use Java threads, so they are similar.

---

<div class="post-metadata">

**Author:** ![ella\_ramos](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ella_ramos/32/3455_2.png) [@ella\_ramos](https://forum.inductiveautomation.com/u/ella_ramos)\
**Post date:** [August 11, 2015, 11:24pm UTC](https://forum.inductiveautomation.com/t/python-threading-in-ignition/10243/5 "2015-08-11T23:24:23Z")

</div>

But is it possible to do multi threading in ignition?

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [August 12, 2015, 1:12am UTC](https://forum.inductiveautomation.com/t/python-threading-in-ignition/10243/6 "2015-08-12T01:12:16Z")

</div>

Yes, you are doing multi-threaded programming when you use system.util.invokeAsynchronous and system.util.invokeLater functions.

Each time you call system.util.invokeAsynchronous you are creating a new Java thread to execute the function argument in.

The [PA Power Scripting Module](http://nickmudge.info/post/pa-power-scripting-module) has more multi-threading tools, specifically the [pa.thread.multiTask](http://nickmudge.info/post/pa-power-scripting-module#pa.thread.multiTask) function and [@run](http://nickmudge.info/post/pa-power-scripting-module#run).

Best,
