473,396 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

CAPI and thread safety

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
2 1046
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jonathan Burd | last post by:
Greetings everyone, Here is a random string generator I wrote for an application and I'm wondering about the thread-safety of this function. I was told using static and global variables cause...
9
by: Alexander Fleck | last post by:
Hi, I' ve to make a software module thread safe. I know how to realize that and what' re the main topics of thread safety. But I don' t know how thread safety can be tested. I read about a test...
4
by: The Crow | last post by:
for example i have static readonly SqlParameter and i want to clone them at runtime. as clone operation will not write to SqlParameter object, just reading, should i lock that object during read...
22
by: Brett | last post by:
I have a second thread, t2, that errors out and will stop. It's status is then "Stopped". I try to start t2 from thread 1, t1, by checking If t2.threadstate = "Stopped" Then t2.start() ...
4
by: Warren Sirota | last post by:
Hi, I've got a method that I want to execute in a multithreaded environment (it's a specialized spider. I want to run a whole bunch of copies at low priority as a service). It works well running...
6
by: fniles | last post by:
I am using VB.NET 2003 and a socket control to receive and sending data to clients. As I receive data in 1 thread, I put it into an arraylist, and then I remove the data from arraylist and send it...
1
by: paul.hester | last post by:
Hi all, All of the classes in my DAL are static, with constants defining the stored procedures and parameters. I've been having some problems with my site which makes me wonder if there's a...
13
by: arun.darra | last post by:
Are the following thread safe: 1. Assuming Object is any simple object Object* fn() { Object *p = new Object(); return p; } 2. is return by value thread safe?
0
by: Graham Wideman | last post by:
Folks: Can anyone tell me what controls php's "thread safety" feature? I have an installation where phpinfo() is showing Thread safety: enabled, whereas I need it disabled in order to work...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.