Exemplo n.º 1
0
    def _AddOpMethod2(client, callback):
      """Create operation with lower op id."""
      op_dict = self._CreateTestOpDict(user_id=1, handler=_AddOpMethod3)
      op_dict['operation_id'] = Operation.ConstructOperationId(1, 5)
      Operation.CreateFromKeywords(**op_dict).Update(client, callback)

      # Explicitly call Execute for this op, since otherwise the UserOpManager won't "see" it, because
      # it has an op-id that is lower than the currently executing op-id.
      user_op_mgr.Execute(op_dict['operation_id'])
Exemplo n.º 2
0
    def _AddOpMethod3(client, callback):
      """Create operation with lower op id."""
      with util.Barrier(callback) as b:
        op_dict = self._CreateTestOpDict(user_id=1, handler=self._OpMethod)
        op_dict['operation_id'] = Operation.ConstructOperationId(1, 1)
        Operation.CreateFromKeywords(**op_dict).Update(client, b.Callback())

      # Try to acquire lock, which has side effect of incrementing "acquire_failures" and triggering requery.
      Lock.TryAcquire(self._client, LockResourceType.Operation, '1', b.Callback())
Exemplo n.º 3
0
  def _CreateTestOp(self, user_id, handler, **kwargs):
    Operation.ConstructOperationId(1, self._id)
    self._id += 1

    op_dict = self._CreateTestOpDict(user_id, handler, **kwargs)
    op = Operation.CreateFromKeywords(**op_dict)

    op.Update(self._client, self.stop)
    self.wait()

    return op
Exemplo n.º 4
0
 def _AddOpMethod1(client, callback):
   """Create operation with higher op id."""
   op_dict = self._CreateTestOpDict(user_id=1, handler=_AddOpMethod2)
   Operation.CreateFromKeywords(**op_dict).Update(client, callback)