* `job.get_status()` Possible values are `queued`, `started`, `deferred`, `finished`, and `failed`
* `job.get_status()` Possible values are `queued`, `started`, `deferred`, `finished`, and `failed`
* `job.origin` queue name of this job
* `job.func_name`
* `job.func_name`
* `job.args` arguments passed to the underlying job function
* `job.args` arguments passed to the underlying job function
* `job.kwargs` key word arguments passed to the underlying job function
* `job.kwargs` key word arguments passed to the underlying job function
@ -133,6 +121,36 @@ for job in jobs:
print('Job %s: %s' % (job.id, job.func_name))
print('Job %s: %s' % (job.id, job.func_name))
```
```
## Stopping a Currently Executing Job
_New in version 1.7.0._
You can use `send_stop_job_command()` to tell a worker to immediately stop a currently executing job. A job that's stopped will be sent to [FailedJobRegistry](https://python-rq.org/docs/results/#dealing-with-exceptions).
```python
from redis import Redis
from rq.command import send_stop_job_command
redis = Redis()
# This will raise an exception if job is invalid or not currently executing
send_stop_job_command(redis, job_id)
```
## Job / Queue Creation with Custom Serializer
When creating a job or queue, you can pass in a custom serializer that will be used for serializing / de-serializing job arguments.
Serializers used should have at least `loads` and `dumps` method.
Starting in version 1.6.0, workers use Redis' pubsub mechanism to listen to external commands while
Starting in version 1.6.0, workers use Redis' pubsub mechanism to listen to external commands while
they're working. Two commands are currently implemented:
they're working. Two commands are currently implemented:
* `send_shutdown_command()`: sends shutdown command to worker. This is similar to sending a SIGINT
### Shutting Down a Worker
`send_shutdown_command()` instructs a worker to shutdown. This is similar to sending a SIGINT
signal to a worker.
signal to a worker.
```python
```python
@ -394,7 +396,9 @@ for worker in workers:
send_shutdown_command(redis, worker.name) # Tells worker to shutdown
send_shutdown_command(redis, worker.name) # Tells worker to shutdown
```
```
* `send_kill_horse_command()`: tells a worker to cancel a currently executing job. If worker is
### Killing a Horse
`send_kill_horse_command()` tells a worker to cancel a currently executing job. If worker is
not currently working, this command will be ignored.
not currently working, this command will be ignored.
```python
```python
@ -410,8 +414,11 @@ for worker in workers:
send_kill_horse_command(redis, worker.name)
send_kill_horse_command(redis, worker.name)
```
```
### Stopping a Currently Executing Job
_New in version 1.7.0._
_New in version 1.7.0._
* `send_stop_job_command()`: tells worker to stop a job.
You can use `send_stop_job_command()` to tell a worker to immediately stop a currently executing job. A job that's stopped will be sent to [FailedJobRegistry](https://python-rq.org/docs/results/#dealing-with-exceptions).