css322 <charles.salvia316 <at> gmail.com> writes: > > (1) A worker thread calls Py_AddPendingCall and assigns a handler function. > (2) When the Python interpreter runs, it calls the handler function whenever it yields control to another thread
Not exactly. As the documentation says: "If successful, func will be called with the argument arg *at the earliest convenience*." This is a deliberately vague wording to stress that the function will not be called as early as you think. It *should* be called in a timely manner, but not necessarily as soon as the thread switch happens. Which begs the question: > In this example, worker_thread is invoked in C as a pthread worker thread. > This > loops infinitely, but the pending call handler is never invoked. What is your main Python thread doing? Is it running Python code (*)? Or do you have a main Python thread at all? The "main Python thread" is the one from which Py_Initialize() was called. (*) for example, running one of the following functions: http://docs.python.org/dev/c-api/veryhigh.html Regards Antoine. -- http://mail.python.org/mailman/listinfo/python-list