By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,331 Members | 1,134 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,331 IT Pros & Developers. It's quick & easy.

CAPI and thread safety

P: n/a
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
Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies

P: n/a
On Jun 27, 4:33*pm, Lane Brooks <l...@ubixum.comwrote:
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.
>
Thanks,
Lane
Jun 28 '08 #2

P: n/a
Thanks for the pointer. I'll check it out. That is what I was looking
for.

Lane

Benjamin wrote:
On Jun 27, 4:33 pm, Lane Brooks <l...@ubixum.comwrote:
>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.

>Thanks,
Lane

--
http://mail.python.org/mailman/listinfo/python-list
Jun 28 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.