473,625 Members | 3,222 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.op en(job).read())

while(1):
jobs = GetJobs()
threads = []
for job in jobs:
threads.append( SpawnThread(Thr eadFoo, 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 1250
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
1613
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 (http://www.jaya123.com see demo) in PHP using just the nedit text editor. (You really DO learn the langauge without an IDE.) For next project I thought maybe I would use an IDE... if for no other reason than easier debugging (as opposed to peppering the code with...
2
2265
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 connection that you close it with: adoCon.Close Set adoCon = Nothing
2
1584
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. We were given Adobe Acrobat Professional 6 and told it could build the packet for us in an automated fashion....ie it could convert the 10 or so reports to PDF format and merge them into one file. Manually I found this simple enough to do....
4
1322
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 informations. I used to do that using Tag property of an objects but ManuItem doesn't have anything like that. So how to add a Tag property to a MenuItem?
1
932
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 colums in the DataView. How can I solve this? Is there someway I can use an index or something instead? Thanks, Shawn
6
1404
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, I would like to "include" them, or "import", say an ascx file. In ASP, all you needed to to was include another .asp file to do this. Many thanks, Chad
55
2706
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
1018
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? Difference between database triggers and form triggers? What is OCI. What are its uses? What are ORACLE PRECOMPILERS? What is syntax for dropping a procedure and a function? Are these operations possible?
0
8259
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8696
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8637
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8358
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7188
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5571
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
1805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1504
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.