# stop\_task

Stops the selected task.

Required User Role: See [Required Enterprise Manager permissions](https://help.qlik.com/en-US/enterprise-manager/November2024/Content/EnterpriseManager/EnterpriseManager_APIGuide/Introduction/AEMPermissions.htm).

## Syntax

`def stop_task(` `self,` `  server, ` `task,` `int timeout = 30` `)`

## Parameters

Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| server | string | The name of the server. |
| task | string | <ul> <li><span><span>Replicate</span>:</span> - The name of the task.</li> <li> <p><span><span>Compose</span>: </span>- The name of the task or workflow appended with a double underscore and the project name.</p> <p><span><span>Example: </span></span>&nbsp;</p> <p><span>mytask__myproject</span> </p> </li> </ul> |
| timeout | int | Time, in seconds, to wait until getting a response. |

## Return values

AemStopTaskResp

Return values

| Value | Type | Description |
| --- | --- | --- |
| state | AemTaskState<br><br>{<br><br>STOPPED = 0,<br><br>RUNNING = 1,<br><br>ERROR = 2,<br><br>RECOVERY = 3<br><br>} | The current state of the task. |
| error\_message | string | The description of the error. |

## Errors

All of the [general errors](https://help.qlik.com/en-US/enterprise-manager/November2024/Content/EnterpriseManager/EnterpriseManager_APIGuide/NetAPI/error_handling.htm) as well as the errors listed in the table below.

Error responses

| Error | Message | Description |
| --- | --- | --- |
| AEM\_TASK\_ALREADY\_STOPPED | Replicate task {task} on server {server} is already stopped. | Cannot stop a task that is in Stopped state. |
| AEM\_STOP\_TASK\_INNER\_ERR | Failed to stop Replicate task {0} on server {1}: &lt;{2}&gt; | An error occurred while trying to stop the task. |
| AEM\_STOP\_TASK\_TIMEOUT | A timeout occurred when trying to stop Replicate task {0} on server {1} | A timeout occurred while trying to stop the task. |