2.4 crashes when try to exit app and mulitple threads active

Maxwell Hammer hammer at maxwell.com
Sun Mar 20 13:29:08 CET 2005


On Sat, 19 Mar 2005 22:35:39 -0500, Peter Hansen wrote:

> When you say "only one thread running", did you mean only
> one monitor thread in addition to the main thread, or did
> you really mean only the main thread was active at this time?

I meant there was the main app and one thread. The problem
does not occur when there are no threads running and the app
has to exit.

> Also, are you doing something odd to terminate threads
> here, and could you have screwed things up yourself?
Very likely - it has happened before :-)

> The code in question is at the end of the MainThread's
> __exitfunc() method, and normally this would be executing
> only after all other threads had terminated, and should
> be safe.  It appears as though the _active dictionary that
> tracks threads has been modified by someone else.

That is what it looks like to me. It seems that the interpreter
is trying to delete a non-existant thread

> Can you post a small self-contained example that
> reproduces the problem?
This will be difficult to do...but perhaps if I give a summary:

def main():
	...initialize/configure
	...wait for certain events
	...based on events launch appropriate thread as follows:

	thread.start_new_thread(event_module.run, (StateValues, (job_parms)))
	...

def event_module.run(StateValues, (job_parms)):
	...initialize/configure
	while (1):
		Return = os.system(RunString)

		if Shutdown flag exists:	#thread detects here if needs to exit
			save_job(parms)
			cleanup_exit(message, exit_code)
		if Return == 0:			# SUCCESS
			break
		elif Return == 1:		# ERROR
			...		
		elif Return == 7:		# ERROR
			...
			
def cleanup_exit(message, exit_code):
	remove temp files
	log message, etc
	return
	
So at shutdown, any threads running save their state to a job file
then simply do a return.

Hope this helps...also I use command line apps to program like Nedit.

Know of any visual python debuggers? I know there is "idle"...
any others, better ones? 
Have you heard of "eric" python ide. Is it good? - it would have debug
capabilities but is dependent on many libraries I think.

thanks a lot.




More information about the Python-list mailing list