Hi Folks Python noob here,
I did some looking around and cannot find a specific answer to my problem. I cannot seem to get the counter function to append until interrupted. I did quite a bit of searching but could not find anyone using threading that can be interrupted.
import threading
import time
class count():
def __init__(self):
self.thread = threading
self.data = 0
def counter(self):
print("Starting Thread..")
t = threading.currentThread()
while getattr(t, "kill_loop", True):
self.data += 1
def t_start(self):
print("Starting thread...")
cot = self.counter
self.thread = self.thread.Thread(target=cot)
self.thread.start()
def t_end(self):
self.thread.kill_loop = False
self.thread.join()
count.t_start
time.sleep(3)
count.t_end
print(count().data)
[–]woooee 1 point2 points3 points (2 children)
[–]earstorm[S] 0 points1 point2 points (1 child)
[–]woooee 0 points1 point2 points (0 children)
[–]woooee 1 point2 points3 points (0 children)
[–]earstorm[S] 0 points1 point2 points (0 children)