Jan-09-2018, 11:13 PM
This is some code I have written based off basic knowledge of threading I acquired. What I am trying to do is limit the actions hourly so it doesn't spam:
import datetime
import time
from threading import Thread
the_Minute = str(datetime.datetime.now().time())[3:5]
action_Limit = 0
def updater():
global the_Minute
while True:
the_Minute=str(datetime.datetime.now().time())[3:5]
#updates the minute value
def resetter():
global action_Limit
global the_Minute
while True:
if the_Minute=='00':
action_Limit=0
time.sleep(30)
def performer():
global action_Limit
global the_Minute
while the_Minute!='00' and action_Limit<100:
#perform actions here
action_Limit+=1
print(action_Limit)
time.sleep(1)
updater_Thread = Thread(target=updater)
resetter_Thread = Thread(target=resetter)
performer_Thread = Thread(target=performer)
updater_Thread.start
performer_Thread.start
resetter_Thread.start When I run this, nothing happens, but I also don't receive any errors. Could anyone tell me how I could make it work, point me to some resources to help, or notify me of any better/other ways to do this? Thank you for your time.
