471,334 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,334 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 2691
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

Post your reply

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

Similar topics

3 posts views Thread by Leiji Liu | last post: by
19 posts views Thread by E. Robert Tisdale | last post: by
7 posts views Thread by William L. Bahn | last post: by
6 posts views Thread by Michael B Allen | last post: by
4 posts views Thread by Rui.Hu719 | last post: by
reply views Thread by rosydwin | last post: by

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.