ultimate goal is a flashing LED in one of my wall mounted switches.
For testing thread behavior, I have the following code, which works fine with Python 2.7:
from threading import Thread import time class LedThread(Thread): def __init__(self): super(LedThread, self).__init__() self._keepgoing = True self.frequency = 1 def run(self): while (self._keepgoing): print "LED blinking" time.sleep(self.frequency) def stop(self): self._keepgoing = False mythread = LedThread() print type(mythread) mythread.frequency = 5 mythread.start() time.sleep(20) mythread.stop()
Type of mythread is reported as “<class ‘main.LedThread’>”
In Jython I get the error message “ttributeError: ‘org.python.core.FunctionThread’ object has no attribute ‘frequency’ in at line number 22”
In this case mythread is reported as “<type ‘org.python.core.FunctionThread’>”.
When I remove the line “mythread.frequency = 5” the code works as expected.
I have no clue, what is not OK with the code.
Thanks for your help!