(Semi-newbie) Thread locks in module code

gottfried_leibniz at my-deja.com gottfried_leibniz at my-deja.com
Sat Oct 2 15:24:37 EDT 1999


I'm thinking about adding Python scripting to an interactive systems
management application, and I'd like to take advantage of Python's
extensive library of OS API interfaces. (The first implementation I'm
looking at is for Win32, and this question mainly applies to the Win32
extension modules.)

The biggest problem I am facing with this is the fact that our current
application makes extensive use of worker threads to simultaneously
access multiple machines over the network. This avoids blocking the UI
when the target of a call is unreachable or broken, and it reduces
latency in general. I'd like to run Python scripts on these worker
threads.

As I understand it, all Python code runs in one global lock, and this
lock must be explicitly released in C code with the
Py_BEGIN_ALLOW_THREADS macro. Looking through the source of a few of
the included Win32 extension modules, I see that this macro is used
only in a subset of all of the OS API calls to make them "yieldable".

My question is: in general, are these macros missing due to omission,
or are they not used because of some problem they would cause? There
are several calls in the Win32 extension libraries to which I'd like to
modify by adding the unlock macros (taking care, of course, not to call
Python APIs in the unlocked sections). Is this inadvisable?

-Thanks


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list