[Python-ideas] Thread object

Aaron Brady castironpi at comcast.net
Fri Jan 11 08:43:48 CET 2008

Hey Group:

I find myself using Threads quite a bit, and I so often write:
	bContinue= True
And in the thread:
	while bContinue:
And elsewhere:
	if ...: bContinue= False

Proposing for the standard library:

	th= threading.Thread( target= myfunction )

	def myfunction( selfth ):
		while selfth.bContinue:


	th.bContinue= False.

Of course, there is a little more functionality that's very common as well.
Throw it in, touched up from above:

	def pausesleep( self, secs ):
		'''Pauses until 'stopped' is set, 'unpaused' is set
		neglects to account for remaining unelapsed seconds),
		or 'secs' seconds elapses.  Set 'stopped' and 'unpaused'
		with Stop(), Pause(), and Resume().  Also, Going() returns
		not stopped.isSet().'''

		self.stopped.wait( secs )
		self.unpaused.wait() #secs- timeout or sth.

Additional; further proposing:
	def Copy( self, runimm= None, name= None ),
	def StopAll(),
	def JoinAll(),
	def PauseAll(),
	def ResumeAll().

However quote the docs: 'group should be None; reserved for future extension
when a ThreadGroup class is implemented', so this may be under way.

Current implementation (read: working version) available and offered to

Thank you and sincerely,

More information about the Python-ideas mailing list