Re: [Sikuli-driver] [Question #682255]: Custom theading best practices
Question #682255 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/682255 Status: Open => Answered RaiMan proposed the following answer: this is my test on Windows 10/Java 12: import threading def myTask(): n = 0 while True: print n n += 1 wait(1) taskThread = threading.Thread(target = myTask) taskThread.start() while True: wait(1) When running the script from inside IDE: Using alt-shift-c (abort key) terminates everything and returns to the IDE When running the script from commandline: Problem: alt-shift-c (abort key) currently does not work (I have to fix this) ... but ctrl-c allows to terminate the complete run (with an additional confirmation when using a batch script) -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #682255]: Custom theading best practices
Question #682255 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/682255 Status: Answered => Open Hugo Jose Goncalves is still having a problem: Error in atexit._run_exitfuncs: Traceback (most recent call last): File "C:\Users\hugo1\AppData\Roaming\Sikulix\Extensions\jython-standalone-2.7.1.jar\Lib\atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "C:\Users\hugo1\AppData\Roaming\Sikulix\Extensions\jython-standalone-2.7.1.jar\Lib\threading.py", line 297, in _MainThread__exitfunc t.join() File "C:\Users\hugo1\AppData\Roaming\Sikulix\Extensions\jython-standalone-2.7.1.jar\Lib\threading.py", line 137, in join self._thread.join() InterruptedException: java.lang.InterruptedException Error in sys.exitfunc: Traceback (most recent call last): File "C:\Users\hugo1\AppData\Roaming\Sikulix\Extensions\jython-standalone-2.7.1.jar\Lib\atexit.py", line 24, in _run_exitfuncs File "C:\Users\hugo1\AppData\Roaming\Sikulix\Extensions\jython-standalone-2.7.1.jar\Lib\threading.py", line 297, in _MainThread__exitfunc File "C:\Users\hugo1\AppData\Roaming\Sikulix\Extensions\jython-standalone-2.7.1.jar\Lib\threading.py", line 137, in join at java.lang.Object.wait(Native Method) at java.lang.Thread.join(Unknown Source) at java.lang.Thread.join(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) java.lang.InterruptedException: java.lang.InterruptedException I don't think it should be waiting (joinning) these custom threads as they have a infinite loop that's why I thought it made a lot of sense to mark them as daemon -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #682255]: Custom theading best practices
Question #682255 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/682255 RaiMan proposed the following answer: no problem. Everything is worth to be evaluated and might lead to enhancements ;-) -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #682255]: Custom theading best practices
Question #682255 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/682255 Hugo Jose Goncalves posted a new comment: Oh, I don't need at all I may have misread python docs about threading Long time I don't use it at all. Gonna test it tonight, sorry for bothering. -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #682255]: Custom theading best practices
Question #682255 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/682255 RaiMan proposed the following answer: I tested and found the problem is: taskThread.daemon = True This seems to completely detach the thread from the running script's context to the global context of the IDE. Everything works fine, if you leave this out. Why do you think you need it in your case? -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #682255]: Custom theading best practices
Question #682255 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/682255 Status: Open => Answered RaiMan proposed the following answer: ok, I have to check with your special threading usage. -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #682255]: Custom theading best practices
Question #682255 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/682255 Status: Answered => Open Hugo Jose Goncalves is still having a problem: even with build 364 daemon threads doenst get killed using alt+shift+c, same issue if the sikulix ends due an exception -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #682255]: Custom theading best practices
Question #682255 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/682255 Status: Open => Answered RaiMan proposed the following answer: latest 1.1.4 should reliably work with alt-shift-c. -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
[Sikuli-driver] [Question #682255]: Custom theading best practices
New question #682255 on Sikuli: https://answers.launchpad.net/sikuli/+question/682255 Are there any recommended approach for custom threading? I'm already using observers which work pretty well for some cenarios, but I want to leave a thread running some tasks until a observer gets triggered and stops that task. I'm using something like this -> ` myreg.onVanish(stopTask) myreg.observeInBackground(FOREVER) taskThread = threading.Thread(target = myTask, args = (taskArg, )) taskThread.daemon = True taskThread.start() while True: # keep alive stuff ` I ran into a few things like **taskThread** not getting stopped with **alt+shift+c** for example I kinda managed to make it work fine using a custom stop HK. Just wondering if there are any best practices about custom threading and SikuliX as I couldn't find any information. -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp