'Handle post request.'

def post(self):

    spec = model.MapreduceSpec.from_json_str(self.request.get('mapreduce_spec'))
    self._start_time = self._time()
    shard_id = self.shard_id()
    logging.debug('post:    shard=%s    slice=%s    headers=%s', shard_id, self.slice_id(), self.request.headers)
    (shard_state, control) = db.get([model.ShardState.get_key_by_shard_id(shard_id), model.MapreduceControl.get_key_by_job_id(spec.mapreduce_id)])
    if (not shard_state):
        logging.error('State    not    found    for    shard    ID    %r;    shutting    down', shard_id)
        return
    if (control and (control.command == model.MapreduceControl.ABORT)):
        logging.info("Abort    command    received    by    shard    %d    of    job    '%s'", shard_state.shard_number, shard_state.mapreduce_id)
        shard_state.active = False
        shard_state.result_status = model.ShardState.RESULT_ABORTED
        shard_state.put()
        model.MapreduceControl.abort(spec.mapreduce_id)
        return
    input_reader = self.input_reader(spec.mapper)
    if spec.mapper.params.get('enable_quota', True):
        quota_consumer = quota.QuotaConsumer(quota.QuotaManager(memcache.Client()), shard_id, _QUOTA_BATCH_SIZE)
    else:
        quota_consumer = None
    ctx = context.Context(spec, shard_state)
    context.Context._set(ctx)
    try:
        if ((not quota_consumer) or quota_consumer.check()):
            scan_aborted = False
            entity = None
            if ((not quota_consumer) or quota_consumer.consume()):
                for entity in input_reader:
                    if isinstance(entity, db.Model):
                        shard_state.last_work_item = repr(entity.key())
                    else:
                        shard_state.last_work_item = repr(entity)[:100]
                    scan_aborted = (not self.process_entity(entity, ctx))
                    if (quota_consumer and (not scan_aborted) and (not quota_consumer.consume())):
                        scan_aborted = True
                    if scan_aborted:
                        break
            else:
                scan_aborted = True
            if (not scan_aborted):
                logging.info("Processing    done    for    shard    %d    of    job    '%s'", shard_state.shard_number, shard_state.mapreduce_id)
                if quota_consumer:
                    quota_consumer.put(1)
                shard_state.active = False
                shard_state.result_status = model.ShardState.RESULT_SUCCESS
        ctx.flush()
    finally:
        context.Context._set(None)
        if quota_consumer:
            quota_consumer.dispose()
    if shard_state.active:
        self.reschedule(spec, input_reader)
