Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
Terminating a function
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Diez B. Roggisch, post: 1864832"] Yes and no. As you didn't tell us muc about your actual problem, threads might be what you need. But you _can't_ just stop a thread - however, depending on what you do, you can for example regularly check for a flag inside your function and then terminate: class Foo(threading.Thread): def __init__(self): super(Foo, self).__init__() self.setDaemon(True) self.interrupted = False def run(self): while not self.interrupted: do_some_work_but_make_sure_to_come_back_regularly() f = Foo() f.start() time.sleep(10) f.interrupted = True Diez [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
Terminating a function
Top