I’m working with Python and Jython to deploy applications to WebSphere. However, we are running into an issue with the WAS libraries where calls to these actions will sometimes take up to 30 minutes to execute. In order to troubleshoot this issue, I need to be able to keep tabs on if a process is still executing after so many minutes and, if so, send an alert.
I’m assuming I will need to put the call in a separate thread and watch it, but I have no experience with multithreading. What is the best way to do so and are there any gotchas?
Python has a built-in
Timerclass which will handle the threading stuff for you:Gotchas:
after_30_minuteswill run in a separate thread, so as with any thread, you have to make sure that its actions don’t interfere with your other threads (although you can manipulate simple data structures without problems due to the Global interpreter lock in CPython).