def _wrapped(import_file_pk, *args, **kwargs): """Lock and return progress url for updates.""" lock_key = _get_lock_key(func_name, import_file_pk) prog_key = get_prog_key(func_name, import_file_pk) is_locked = get_lock(lock_key) # If we're already processing a given task, don't proceed. if is_locked: return {'error': 'locked'} # Otherwise, set the lock for 1 minute. lock_cache(lock_key) try: response = fn(import_file_pk, *args, **kwargs) finally: # Unset our lock unlock_cache(lock_key) # If our response is a dict, add our progress URL to it. if isinstance(response, dict): response['progress_key'] = prog_key return response
def _wrapped(import_file_pk, *args, **kwargs): """Lock and return progress url for updates.""" lock_key = _get_lock_key(func_name, import_file_pk) prog_key = get_prog_key(func_name, import_file_pk) is_locked = get_lock(lock_key) # If we're already processing a given task, don't proceed. if is_locked: return {'error': 'locked'} # Otherwise, set the lock for 1 minute. lock_cache(lock_key) try: response = fn(import_file_pk, *args, **kwargs) finally: # Unset our lock unlock_cache(lock_key) # If our response is a dict, add our progress URL to it. if isinstance(response, dict): response['progress_key'] = prog_key return response