Fundamental Tkinter inefficiency?

Mike Clarkson support at internetdiscovery.com
Wed Dec 20 11:08:03 EST 2000


I'm looking at the implementation of Tk_MainLoop in _tkinter.c:

	quitMainLoop = 0;
	while (Tk_GetNumMainWindows() > threshold &&
	       !quitMainLoop &&
	       !errorInCmd)
	{
		int result;

#ifdef WITH_THREAD
		Py_BEGIN_ALLOW_THREADS
		PyThread_acquire_lock(tcl_lock, 1);
		tcl_tstate = tstate;
		result = Tcl_DoOneEvent(TCL_DONT_WAIT);
		tcl_tstate = NULL;
		PyThread_release_lock(tcl_lock);
		if (result == 0)
			Sleep(20);
		Py_END_ALLOW_THREADS
#else
		result = Tcl_DoOneEvent(0);
#endif

		if (PyErr_CheckSignals() != 0)
			return NULL;
		if (result < 0)
			break;
	}


and was wondering if it would be better to use a Tcl Event procedure
with a MaxBlock time to check the Python signals, instead of calling
Sleep.  Does anyone know how to do this in Tcl - it shouldn't be
more than a few lines I suspect.

Many thanks in advance,

Mike.





More information about the Python-list mailing list