Python Forum
Is Event.set() the preferred way to stop a thread?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is Event.set() the preferred way to stop a thread?
#6
Yes, you should avoid using the private method in client code.
Using just a Boolean to stop a thread may cause race conditions.

The object Event is threadsafe.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
RE: Is Event.set() the preferred way to stop a thread? - by DeaD_EyE - Jul-17-2018, 08:14 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Anyway to stop a thread and continue it? dimidgen 2 352 Mar-18-2024, 10:53 AM
Last Post: DeaD_EyE
  Error SQLite objects created in a thread can only be used in that same thread. binhduonggttn 3 15,606 Jan-31-2020, 11:08 AM
Last Post: DeaD_EyE
  Preferred way to slice a list SvetlanaofVodianova 3 2,561 Dec-09-2019, 11:50 PM
Last Post: SvetlanaofVodianova
Exclamation Error: There is no current event loop in thread 'MainThread' AlekseyPython 5 15,920 Feb-21-2019, 04:37 AM
Last Post: AlekseyPython
  a preferred choice os the two lines? Skaperen 9 6,358 May-27-2017, 02:31 AM
Last Post: Skaperen
  preferred?: multiple assignment Skaperen 6 6,139 Dec-19-2016, 06:18 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

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