Handle a locked slice case.
775385
private void handleLockHeld(String taskId, ShardedJobStateImpl<T> jobState,
      IncrementalTaskState<T> taskState) {
    long currentTime = System.currentTimeMillis();
    int sliceTimeoutMillis = jobState.getSettings().getSliceTimeoutMillis();
    long lockExpiration = taskState.getLockInfo().lockedSince() + sliceTimeoutMillis;
    boolean wasRequestCompleted = wasRequestCompleted(taskState.getLockInfo().getRequestId());

    if (lockExpiration > currentTime && !wasRequestCompleted) {
      // if lock was not expired AND not abandon reschedule in 1 minute.
      long eta = Math.min(lockExpiration, currentTime + 60_000);
      scheduleWorkerTask(null, jobState.getSettings(), taskState, eta);
      log.info("Lock for " + taskId + " is being held. Will retry after " + (eta - currentTime));
    } else {
      ShardRetryState<T> retryState;
      if (wasRequestCompleted) {
        retryState = handleSliceFailure(jobState, taskState, new RuntimeException(
            "Resuming after abandon lock for " + taskId + " on slice: "
                + taskState.getSequenceNumber()), true);
      } else {
        retryState = handleShardFailure(jobState, taskState, new RuntimeException(
          "Lock for " + taskId + " expired on slice: " + taskState.getSequenceNumber()));
      }
      updateTask(jobState, taskState, retryState, false);
    }
  }
553353
def handle_ans(self, ans_):
        
        ans = ans_.strip(' ')
        def chack_if_answer_was(valid_keys):
            return any([ans == key or ans.startswith(key + ' ')
                        for key in valid_keys])
        # Custom interactions
        for func, tup in self.actions.items():
            valid_keys = tup[0]
            if chack_if_answer_was(valid_keys):
                func()
285729
def unlock(self):
        
        pid = readlink(self.name)
        if int(pid) != os.getpid():
            raise ValueError("Lock %r not owned by this process" % (self.name,))
        rmlink(self.name)
        self.locked = False
630422
def slice_repr(slice_instance):
    
    if not isinstance(slice_instance, slice):
        raise TypeError('Unhandled type {}'.format(type(slice_instance)))
    start = slice_instance.start or ''
    stop = slice_instance.stop or ''
    step = slice_instance.step or ''

    msg = '{}:'.format(start)
    if stop:
        msg += '{}'.format(stop)
        if step:
            msg += ':'
    if step:
        msg += '{}'.format(step)
    return msg
94857
public synchronized void runslice(long slice)
	{
		// Run one time slice - called by Scheduler
		timeslice = slice;
		waitWhileState(RunState.RUNNING, RunState.RUNNING, null, null);
	}
843809
def case_stmt_handle(self, loc, tokens):
        """"""
        if len(tokens) == 2:
            item, cases = tokens
            default = None
        elif len(tokens) == 3:
            item, cases, default = tokens
        else:
            raise CoconutInternalException("invalid case tokens", tokens)
        check_var = case_check_var + "_" + str(self.case_check_count)
        self.case_check_count += 1
        out = (
            match_to_var + " = " + item + "\n"
            + match_case_tokens(loc, cases[0], check_var, True)
        )
        for case in cases[1:]:
            out += (
                "if not " + check_var + ":\n" + openindent
                + match_case_tokens(loc, case, check_var, False) + closeindent
            )
        if default is not None:
            out += "if not " + check_var + default
        return out
791737
function _lock_map(field, id_list){
	var fixed_list = [];
	bbop.core.each(id_list,
		       function(item){
			   fixed_list.push(bbop.core.ensure(item, '"'));
		       });

	var base_id_list = '(' + fixed_list.join(' OR ') + ')';

	var ret_query = field + ':' + base_id_list;
	return ret_query;
	
    }
1098699
def locked(self, lock):
        """"""
        _LOGGER.debug("Setting the lock: %s", lock)
        value = struct.pack('BB', PROP_LOCK, bool(lock))
        self._conn.make_request(PROP_WRITE_HANDLE, value)
469454
function handleCipherSuccess(opts, err) {
  console.log(chalk.green(
    '\nSuccess: ' + opts.input + ' → ' + opts.output + '\n'
  ));
}
146379
def locked_get_or_set(self, key, value_creator, version=None,
                          expire=None, id=None, lock_key=None,
                          timeout=DEFAULT_TIMEOUT):
        
        if lock_key is None:
            lock_key = 'get_or_set:' + key

        val = self.get(key, version=version)
        if val is not None:
            return val

        with self.lock(lock_key, expire=expire, id=id):
            # Was the value set while we were trying to acquire the lock?
            val = self.get(key, version=version)
            if val is not None:
                return val

            # Nope, create value now.
            val = value_creator()

            if val is None:
                raise ValueError('`value_creator` must return a value')

            self.set(key, val, timeout=timeout, version=version)
            return val
595254
def freeze(o):
    
    if isinstance(o, (tuple, list)):
        return tuple(sorted(freeze(e) for e in o))

    if isinstance(o, dict):
        return tuple(sorted((k, freeze(v)) for k, v in iteritems(o)))

    if isinstance(o, (set, frozenset)):
        return tuple(sorted(freeze(e) for e in o))

    return o
1039446
private void doMacLockRequestWorkaround( final ITransaction transaction, final WebdavRequest req, final WebdavResponse resp )
        throws LockFailedException, IOException
    {
        LockedObject lo;
        final int depth = getDepth( req );
        int lockDuration = getTimeout( transaction, req );
        if ( lockDuration < 0 || lockDuration > MAX_TIMEOUT )
        {
            lockDuration = DEFAULT_TIMEOUT;
        }

        boolean lockSuccess = false;
        lockSuccess = _resourceLocks.exclusiveLock( transaction, _path, _lockOwner, depth, lockDuration );

        if ( lockSuccess )
        {
            // Locks successfully placed - return information about
            lo = _resourceLocks.getLockedObjectByPath( transaction, _path );
            if ( lo != null )
            {
                generateXMLReport( transaction, resp, lo );
            }
            else
            {
                resp.sendError( SC_INTERNAL_SERVER_ERROR );
            }
        }
        else
        {
            // Locking was not successful
            sendLockFailError( transaction, req, resp );
        }
    }
1086476
def _get_string_slice(self, key):
        """"""
        parsed, resolution = _parse_iso8601_with_reso(self.date_type, key)
        try:
            loc = self._partial_date_slice(resolution, parsed)
        except KeyError:
            raise KeyError(key)
        return loc
257612
private Map<String, String> readExistingLocks(HLock lock) {
    // logger.debug("Started reading all columns");
    SliceQuery<String, String, String> sliceQuery = HFactory
        .createSliceQuery(keyspace, StringSerializer.get(), StringSerializer.get(), StringSerializer.get())
        .setColumnFamily(lockManagerConfigurator.getLockManagerCF()).setKey(lock.getPath());

    //we only care about the first 2 locks, anything else is simply queued.  Select 10 just to be safe if the clients aren't ordered properly
    sliceQuery.setRange(null, null, false, maxSelectSize);

    QueryResult<ColumnSlice<String, String>> queryResult = sliceQuery.execute();

    // logger.debug("Finished reading all columns");
    return getResults(queryResult);
  }
1267057
def STORE_SLICE_3(self, instr):
        ''

        upper = self.ast_stack.pop()
        lower = self.ast_stack.pop()
        value = self.ast_stack.pop()
        expr = self.ast_stack.pop()
        
        kw = dict(lineno=instr.lineno, col_offset=0)
        slice = _ast.Slice(lower=lower, step=None, upper=upper, **kw)
        subscr = _ast.Subscript(value=value, slice=slice, ctx=_ast.Store(), **kw)
        
        if isinstance(expr, _ast.AugAssign):
            assign = expr
            result = cmp_ast(expr.target, subscr)
            
            assert result
        else:
            assign = _ast.Assign(targets=[subscr], value=expr, **kw)
            
        self.ast_stack.append(assign)
382076
function(data, convertCaseOptions) {

    let converted;

    if (_.isArray(data) || _.isPlainObject(data)) {
      converted = _.transform(data, (result, value, key) => {
        if (_.isArray(value) || _.isPlainObject(value)) {
          result[this._convertCase(key, convertCaseOptions)] = this._convertCase(value, convertCaseOptions);
        } else {
          result[this._convertCase(key, convertCaseOptions)] = value;
        }
      });
    } else {
      switch (convertCaseOptions) {
      case 'snake_case':
        converted = _.snakeCase(data);
        break;
      case 'kebab-case':
        converted = _.kebabCase(data);
        break;
      case 'camelCase':
        converted = _.camelCase(data);
        break;
      default:
        converted = data;
        break;
      }
    }

    return converted;
  }
1131494
def handle(indicator, code, tailch, rspace, lspace)
      case indicator
      when '|=', '|=='
        rspace = nil if tailch && !tailch.empty?
        add_text(lspace) if lspace
        escape_capture = !((indicator == '|=') ^ @escape_capture)
        src << "begin; (#{@bufstack} ||= []) << #{@bufvar}; #{@bufvar} = #{@bufval}; #{@bufstack}.last << #{@escapefunc if escape_capture}((" << code
        add_text(rspace) if rspace
      when '|'
        rspace = nil if tailch && !tailch.empty?
        add_text(lspace) if lspace
        result = @yield_returns_buffer ? " #{@bufvar}; " : ""
        src << result << code << ")).to_s; ensure; #{@bufvar} = #{@bufstack}.pop; end;"
        add_text(rspace) if rspace
      else
        super
      end
    end