Skip to content

create_worker_block async

create_worker_block(
    worker_id: CustomerId,
    reason: String,
    *,
    config_overrides: Optional[AsyncMTurkClientConfig] = None,
) -> CreateWorkerBlockResponse

The CreateWorkerBlock operation allows you to prevent a Worker from working on your HITs. For example, you can block a Worker who is producing poor quality work. You can block up to 100,000 Workers.

Parameters:

  • worker_id (CustomerId) –

    The ID of the Worker to block.

  • reason (String) –

    A message explaining the reason for blocking the Worker. This parameter enables you to keep track of your Workers. The Worker does not see this message.

Raises:

  • RequestError –

    Your request is invalid.

  • ServiceFault –

    Amazon Mechanical Turk is temporarily unable to process your request. Try your call again.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_mturk/_services/async_m_turk.py
async def create_worker_block(
    self,
    worker_id: "capo_mturk.types.customer_id.CustomerId",
    reason: "capo_mturk.types.string.String",
    *,
    config_overrides: Optional[AsyncMTurkClientConfig] = None,
) -> "capo_mturk.types.create_worker_block_response.CreateWorkerBlockResponse":
    """<p>The <code>CreateWorkerBlock</code> operation allows you to prevent a Worker from working on your HITs. For example, you can block a Worker who is producing poor quality work. You can block up to 100,000 Workers.</p>

    Args:
        worker_id: <p>The ID of the Worker to block.</p>
        reason: <p>A message explaining the reason for blocking the Worker. This parameter enables you to keep track of your Workers. The Worker does not see this message.</p>

    Raises:
        capo_mturk.errors.request_error.RequestError: <p>Your request is invalid.</p>
        capo_mturk.errors.service_fault.ServiceFault: <p>Amazon Mechanical Turk is temporarily unable to process your request. Try your call again.</p>
        capo_mturk.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_mturk.types.create_worker_block_request.CreateWorkerBlockRequest]",
    ) -> AsyncOperationResponse[
        "capo_mturk.types.create_worker_block_response.CreateWorkerBlockResponse"
    ]:
        import capo_mturk._operations.m_turk_requester_service_v20170117.create_worker_block

        (
            output,
            http_response,
        ) = await capo_mturk._operations.m_turk_requester_service_v20170117.create_worker_block.async_create_worker_block(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateWorkerBlock")
    )
    input_: capo_mturk.types.create_worker_block_request.CreateWorkerBlockRequest = {
        "worker_id": worker_id,
        "reason": reason,
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output