try: condition.acquire ( ) if not counter == 0: while self.gothread: condition.wait ( ) if self.gothread: lock.acquire ( ) else: return try: operation() except: tantpis() finally: condition.notify ( ) condition.release ( ) lock.release ( )