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

'BoundedSemaphore' is not defined

Hi
I am very new to python,In case of using multithreading i want to synchronize all the threads but using
Expand|Select|Wrap|Line Numbers
  1. sem = BoundedSemaphore  
statement i am getting this error.
even i have imported the threading module.
please guide me in locking with a suitable and simple example .

thanx
Sep 19 '07 #1
3 2782
bartonc
6,596 Expert 4TB
Hi
I am very new to python,In case of using multithreading i want to synchronize all the threads but using
Expand|Select|Wrap|Line Numbers
  1. sem = BoundedSemaphore  
statement i am getting this error.
even i have imported the threading module.
please guide me in locking with a suitable and simple example .

thanx
Expand|Select|Wrap|Line Numbers
  1. import threading
  2. maxconnections = 5
  3. ##...
  4. pool_sema = threading.BoundedSemaphore(value=maxconnections)
From 7.5.4.1 Semaphore Example
Sep 19 '07 #2
Expand|Select|Wrap|Line Numbers
  1. import threading
  2. maxconnections = 5
  3. ##...
  4. pool_sema = threading.BoundedSemaphore(value=maxconnections)
From 7.5.4.1 Semaphore Example

Thanx a lot
i agree this was the foolish mistake done by me

but now again there is a problem
1. sem = threading.BoundedSemaphore(1)
2. sem.acquire()
3. fileObj.write(writing)
4. sem.release()

i am trying to write to a file but it just stuck at 3. line number.

is the above code is correct syntactically as well as logically.
please
Sep 19 '07 #3
bartonc
6,596 Expert 4TB
Thanx a lot
i agree this was the foolish mistake done by me

but now again there is a problem
1. sem = threading.BoundedSemaphore(1)
2. sem.acquire()
3. fileObj.write(writing)
4. sem.release()

i am trying to write to a file but it just stuck at 3. line number.

is the above code is correct syntactically as well as logically.
please
Correctness of the above will depend an what precedes it.
Please look to the right hand side of the page when you reply. There you will find "REPLY GUIDELINES". The third item is "Use CODE tags". Following those instructions, paste your actual code (in its entirety or just a more relevant snippet) and we'll see if we can't get you headed in the right directions (odds are, we can). Thanks.
Sep 19 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Dave | last post by:
Hello all, Please consider this code: #ifndef FOO_INCLUDED #define FOO_INCLUDED // File: foo.h class foo {
2
by: David Emme | last post by:
Access 97 I have a number of SELECT statements which contain references to user-defined VBA functions. These typically work as expected, but occasionally, on one user's machine or another,...
3
by: Leiji Liu | last post by:
Hi, I am curious if there are any pre-defined varables (constants?) in C? I saw some code with __LINE__, __FILE__, etc. Are those located in some include files? LL
19
by: E. Robert Tisdale | last post by:
In the context of the comp.lang.c newsgroup, the term "undefined behavior" actually refers to behavior not defined by the ANSI/ISO C 9 standard. Specifically, it is *not* true that "anything can...
7
by: William L. Bahn | last post by:
I'm working on some lessons and want to be sure I get some stuff correct. If any of this is covered in the FAQ, please feel free to point me to the section - I couldn't find it. ...
6
by: Michael B Allen | last post by:
Which is the preferred method for preprocessor tests and why? #ifdef XYZ or #if XYZ or #if defined(XYZ) and
6
by: karthi | last post by:
hi, I need user defined function that converts string to float in c. since the library function atof and strtod occupies large space in my processor memory I can't use it in my code. regards,...
4
by: Rui.Hu719 | last post by:
Hi, All: I read the following passage from a book: "There are three exceptions to the rule that headers should not contain definitions: classes, const objects whose value is known at compile...
2
by: curious2007 | last post by:
During the linking I get the following: 1>Linking... 1>main.obj : error LNK2005: "double __cdecl sigma(class curious2007::pair<double,double> const &)" (?sigma@@YANABV?$pair@NN@curious2007@@@Z)...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.