Getting Started with Tasktronaut
Welcome to Tasktronaut!
This guide will help you install the library, set up your first process, and run it successfully.
Installation
Prerequisites
Tasktronaut requires:
Python 3.7 or higher
pip (Python package manager)
Installing from PyPI
The easiest way to install Tasktronaut is using pip:
pip install tasktronaut[rq]
For a specific version:
pip install tasktronaut[rq]==0.5.0
Installing with Optional Dependencies
Tasktronaut may offer optional extras for extended functionality. Install them as follows:
pip install tasktronaut[dev]
pip install tasktronaut[docs]
Installing from Source
To install the development version from the repository:
git clone https://github.com/virtualstaticvoid/tasktronaut.git
cd tasktronaut
uv sync
Verifying Your Installation
Verify the installation was successful by importing Tasktronaut in a Python shell:
>>> import tasktronaut
>>> print(tasktronaut.__version__)
x.x.x
If you see the version number without errors, you’re ready to go!
Configuring RQ Workers
When executing processes with RQ, use tasktronaut.backends.rq.RqQueue as the
queue class of your workers, so that each step of a process is enqueued as soon as the
steps it depends on have finished, even when many workers are busy:
rq worker --queue-class tasktronaut.backends.rq.RqQueue
With django-rq, mix tasktronaut.backends.rq.JobScopedReadyJobRegistryMixin
into the queue class and configure it with the QUEUE_CLASS setting:
from django_rq.queues import DjangoRQ
from tasktronaut.backends.rq import JobScopedReadyJobRegistryMixin
class ApplicationQueue(JobScopedReadyJobRegistryMixin, DjangoRQ):
pass
# settings.py
RQ = {"QUEUE_CLASS": "myapp.queues.ApplicationQueue"}
Your First Process
Creating a Simple Process
Let’s create a basic process with three sequential tasks. Create a file called my_first_process.py:
from tasktronaut import ProcessDefinition, Builder
class GreetingProcess(ProcessDefinition):
"""A simple process that greets the user."""
def define_process(self, builder: Builder):
builder.task(self.say_hello)
builder.task(self.say_name)
builder.task(self.say_goodbye)
def say_hello(self):
print("Hello!")
def say_name(self, name: str = "World", **kwargs):
print(f"Nice to meet you, {name}.")
def say_goodbye(self):
print("Goodbye!")