Ok man, thanks again for all the info
I'm playing around with the code right now. I am running into problems when I try to call the class with parameters.
As far as I can see you already included that with param1 and param2.
But those two are defined in the startup script which defines the global function. This is done with
Code: Select all
eg.globals.MyTestLoop_1 = ThreadClass('EventPrefix', 'EventSuffix')
So how can I call the function from outside this script and pass some other parameters instead of ('EventPrefix', 'EventSuffix')? I was thinking about using global variables and it works. But this doesn't make any sense to me because the class is defined before when the globals are not set yet.
Code: Select all
eg.globals.MyTestLoop_1.start(param1,param2)
Will not work for obvious reasons:
Code: Select all
19:06:27 Traceback (most recent call last):
19:06:27 Python script "43", line 5, in <module>
19:06:27 eg.globals.MyTestLoop_1.start('Hello1', 'Hello2')
19:06:27 TypeError: start() takes exactly 1 argument (3 given)
I do understand why this is happening. I'm after all calling the function with the start argument and 'Hello1', 'Hello2' should be passed additionally.
And the thread seems not be closed properly because I will get this:
Code: Select all
19:38:12 thread definiton
19:38:16 Python Script
19:38:16 Thread started
19:38:16 Hello1
19:38:16 Hello2
19:38:16 0
19:38:17 1
19:38:18 Closing the thread
19:38:18 2
19:38:18 Thread closed
19:38:26 Python Script
19:38:26 Traceback (most recent call last):
19:38:26 Python script "51", line 4, in <module>
19:38:26 eg.globals.MyTestLoop_2.start()
19:38:26 Python script "50", line 13, in start
19:38:26 threading.Thread.start(self)
19:38:26 File "threading.pyc", line 730, in start
19:38:26 RuntimeError: threads can only be started once
Win10 x64 Prof. / Eventghost latest / MCE Plugin / MCE RC6 Receiver / Logitech Harmony Hub / MediaPortal / kodi