473,385 Members | 1,901 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,385 software developers and data experts.

GIL on SMP (need quick answer for the boss :) - thanks!

I am working on a windoze service (deamon) that needs to spawn up to
NumCPU heavyweight processes on SMP and wait for results, which have to
be logged. So I have to do something like (total pseudocode, thread
pool not implemented, but demonstrates the problem):

Logger log
def ThreadFoo(job):
log.write(os.open(job).read())

while(1):
jobs = GetJobs()
threads = []
for job in jobs:
threads.append(SpawnThread(ThreadFoo, job))
waitFor(threads)
I have 3 questions:

1) (this is the killer) - is GIL going to get me into trouble? (i guess
not, since all the python threads can run on the same CPU, not
preventing the processes from being scheduled to different CPUs by the OS)
2) any problems having multiple threads write to the log (the standard
Python logger). In general, is there an easy way to determine if a
particular Python lib is thread-safe, at least for the standard libs?
3) Has anyone already implemented a thread pool lib that I can use (GPL
not ok for this :()

thanks,

max
Jul 18 '05 #1
1 1243
max khesin wrote:
I have 3 questions:

1) (this is the killer) - is GIL going to get me into trouble?
Define "trouble". You will not get in conflict with law enforcement
because of that Python code :-)

If you are asking "does it do what you think it does?", then "yes,
it does precisely what I think it does."

If you are asking "does it do what I think it does?", then "I
don't know, because I don't know what you are thinking".
2) any problems having multiple threads write to the log (the standard
Python logger).
It should work fine.
In general, is there an easy way to determine if a
particular Python lib is thread-safe, at least for the standard libs?


No. It starts with the lack of a clear definition of "thread-safe".
In most cases, if a library has what many people would consider a
serious problem, this problem has been either documented or fixed
by now.

OTOH, many libraries implemented in pure Python will act strangely
if two threads try to manipulate the same data structures. In many
cases, this is not considered a serious problem because one would
normally not attempt to use that data structure from two threads.

Regards,
Martin

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Al. C | last post by:
Yeah I know this has been done before, but it usually gets into a spitting contest. I run Slackware Linux 9.1 with KDE 3.14. I recently finished about 200,000 lines of code...
2
by: InvisibleMan | last post by:
Hi, I feel a little dumb for asking this (considering im writing TSQL) but there doesn't seem to be any definitive answers on the search engines... Okay I understand that if you open the ADO...
2
by: Andre L via AccessMonster.com | last post by:
We run numerous Access reports which we auto export as .rtfs to a share. We also have numerous Excel sheets. Each month 10 or more of these reports are combined into deprtmental monthly packets. ...
4
by: Jacek Jurkowski | last post by:
I have to add a property to an object that is already allive. The problem is that I'm creating MainMenu from a definition file ... enyway , there is a need to add each menu item some extra...
1
by: Shawn | last post by:
Hi. I have a DropDownList which is bound to a DataView from code-behind. I'm having trouble with the DataTextField and the DataValueField properties because I do not know the names of the two...
6
by: Chad A. Beckner | last post by:
Does anyone know how to make common database connections "common" in all aspx files? In other words, instead of creating a SQLConnection, then a DataAdapter in every ASPX file for my application,...
55
by: Steven Nagy | last post by:
Hi all, Sorry I have no time to test this myself.... Can I add the same attribute to a field twice? Eg. Public string myField;
0
by: partha das | last post by:
need some answer for the following question Can you use a commit statement within a database trigger? What is an UTL_FILE.What are different procedures and functions associated with it? ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.