#NEWLINE# def __enter__( self ) : #NEWLINE# #INDENT# redis_key = self . CELERY_LOCK . format ( task_id = redis_key . task_identifier ) #NEWLINE# self . lock = self . celery_self . backend . client . lock ( redis_key , timeout = self . timeout ) #NEWLINE# self . log . debug ( 'Timeout %ds | Redis key %s' , self . timeout , redis_key ) #NEWLINE# if ( not self . lock . acquire ( blocking = False ) ) : #NEWLINE# #INDENT# self . log . debug ( 'Another instance is running.' ) #NEWLINE# raise OtherInstanceError ( 'Failed to acquire lock, {0} already running.' . format ( self . task_identifier ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . log . debug ( 'Got lock, running.' )