--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CABBPk35MGR64r2sOEDXAdFh-oCwYBV2frAHo89VX%3DiJZFPJcfA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Subprocess is really only good for external processes, and less so for Python functions.
Threading to the rescue!
import time
import threading
def my_system_function():
print("Doing something for 5 seconds..")
time.sleep(5)
print("Done!")
threading.Thread(target=my_system_function).start()
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CABBPk35MGR64r2sOEDXAdFh-oCwYBV2frAHo89VX%3DiJZFPJcfA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCO1rDSXGNVhOTfen8fTheY68yLQEM9dRTO_%3DVxstG7BA%40mail.gmail.com.
They could still be run through subprocess if you package your functions into a proper main application. And then you just run it with arguments that control which service(s) will be performed. A benefit is that it is easy to stop them by killing a process id. The downside is if you need to actually talk to them actively, it is more complicated than threads.
With threads, to get them to stop before their own action chooses to end, you have to build in cancellation to the function you run, like having them check a stop condition.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CA%2Bhu4Mzk6J0NDms8fK0PmPsRf0PKmj_yjN1jYfOzY_YV7Z6g5g%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3ZuUzXY%2BzJGY22DL1Huhb6%2BOYnRC3ArSN9OxksSjeD0g%40mail.gmail.com.