May-03-2017, 11:00 PM
it looks like that works fine. i extended the code into my main program but is giving me issues still.
import time import multiprocessing import queue def cleancycle(clean,seconds): msgqueue=multiprocessing.Queue() ctr=multiprocessing.Process(target=timeremaining,args=(seconds,msgqueue)) ctr.daemon=True if not ctr.is_alive: ctr.start() print('clean') print('Queue: {}'.format(msgqueue)) if clean=='1': print('clean is one') pass else: msgqueue.put('stop') def timeremaining(seconds=0,msgqueue=None): print('Time: {}'.format(seconds)) print('Queue: {}'.format(queue)) while seconds != 0: print('time remaining: {}'.format(seconds)) seconds-=1 time.sleep(1) try: msg=msgqueue.get(False) if msg=='stop': print('Exit loop') break except queue.Empty: pass def main(): i=0 seconds=100 cleancycle('1',seconds) for i in range(0,30): print (i) i+=1 time.sleep(1) cleancycle('2',seconds) if __name__ == '__main__': main()the issue im now facing is that it doesnt print time remaining. if you have any ideas to maybe restructure the program instead of reprogramming stuff that would be fine too