CAPI and thread safety

L

Lane Brooks

I am writing an extension module that needs to release the global
interpreter lock during some blocking I/O calls, but I need a mutex in
the C code to make some of the shared data in the extension module are
kept thread safe. Can anyone recommend a portable way to do this? I
could use a pthread mutex, but I do not think that is portable.

Are any of the python mutexes or locks exposed through the C API? I
could not find anything.

Thanks,
Lane
 
B

Benjamin

I am writing an extension module that needs to release the global
interpreter lock during some blocking I/O calls, but I need a mutex in
the C code to make some of the shared data in the extension module are
kept thread safe.  Can anyone recommend a portable way to do this?  I
could use a pthread mutex, but I do not think that is portable.

Are any of the python mutexes or locks exposed through the C API?  I
could not find anything.

Look at Include/pythread.h. You can use PyThread_allocate_lock to get
the threading abstractions that Python uses.
 
L

Lane Brooks

Thanks for the pointer. I'll check it out. That is what I was looking
for.

Lane
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top