'BoundedSemaphore' is not defined

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • diwakar09
    New Member
    • Sep 2007
    • 39

    '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
    Code:
    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
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Originally posted by diwakar09
    Hi
    I am very new to python,In case of using multithreading i want to synchronize all the threads but using
    Code:
    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
    [CODE=pytohn]import threading
    maxconnections = 5
    ##...
    pool_sema = threading.Bound edSemaphore(val ue=maxconnectio ns)[/CODE]

    From 7.5.4.1 Semaphore Example

    Comment

    • diwakar09
      New Member
      • Sep 2007
      • 39

      #3
      Originally posted by bartonc
      [CODE=pytohn]import threading
      maxconnections = 5
      ##...
      pool_sema = threading.Bound edSemaphore(val ue=maxconnectio ns)[/CODE]

      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.Bound edSemaphore(1)
      2. sem.acquire()
      3. fileObj.write(w riting)
      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

      Comment

      • bartonc
        Recognized Expert Expert
        • Sep 2006
        • 6478

        #4
        Originally posted by diwakar09
        Thanx a lot
        i agree this was the foolish mistake done by me

        but now again there is a problem
        1. sem = threading.Bound edSemaphore(1)
        2. sem.acquire()
        3. fileObj.write(w riting)
        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.

        Comment

        Working...