Python Forum
Stopping a loop in another file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stopping a loop in another file
#5
(Jun-13-2020, 06:12 PM)Yoriz Wrote: Maybe this will suffice

File1.py:
import File2
 
while True:
    a = input()
    if a == "start":
        File2.run_func = True
        threading.Thread(target = File2.func).start()
    if a == "stop":
        #stop function File2.func
        File2.run_func = False
File2.py:
run_func = True

def func():
    while run_func:
        #do stuff

Is not working, i cannot update the value of File2.run_func into False. If I do:
print(File2.run_func)
after run the line:
File2.run_func = False
the output is:
Output:
True
instead of False



EDIT: It works! Sorry, my mistake!Thank you all!
Reply


Messages In This Thread
Stopping a loop in another file - by catosp - Jun-13-2020, 06:04 PM
RE: Stopping a loop in another file - by Yoriz - Jun-13-2020, 06:12 PM
RE: Stopping a loop in another file - by catosp - Jun-15-2020, 02:45 PM
RE: Stopping a loop in another file - by catosp - Jun-13-2020, 06:16 PM
RE: Stopping a loop in another file - by catosp - Jun-14-2020, 05:10 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  stopping number conversion before end Skaperen 6 3,014 Jul-12-2020, 09:22 AM
Last Post: DeaD_EyE
  Help with Stopping a function after a timer SheeppOSU 0 1,943 Jan-28-2019, 10:13 PM
Last Post: SheeppOSU
  reading raw data until condition is met, then stopping unknowntothem 7 4,166 Sep-27-2018, 06:10 AM
Last Post: unknowntothem
  Stopping scheduler with condition j.crater 17 15,973 Jan-10-2017, 11:06 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020