original_docstring: 
          Set and automatically clear a lock
          
docstring: Set and automatically clear a lock
docstring_tokens: Set and automatically clear a lock
code: def gen_lock(self, lock_type='update'):
          '''
          Set and automatically clear a lock
          '''
          lock_set = False
          try:
              self._lock(lock_type=lock_type, failhard=True)
              lock_set = True
              yield
          except (OSError, IOError, GitLockError) as exc:
              raise GitLockError(exc.errno, exc.strerror)
          finally:
              if lock_set:
                  self.clear_lock(lock_type=lock_type)
code_tokens: def gen_lock ( self , lock_type = 'update' ) : lock_set = False try : self . _lock ( lock_type = lock_type , failhard = True ) lock_set = True yield except ( OSError , IOError , GitLockError ) as exc : raise GitLockError ( exc . errno , exc . strerror ) finally : if lock_set : self . clear_lock ( lock_type = lock_type )
short_docstring: Set and automatically clear a lock
short_docstring_tokens: Set and automatically clear a lock
comment: '''
          Set and automatically clear a lock
          '''