freshcrate
Home > Databases > mirakuru

mirakuru

Process executor (not only) for tests.

Description

.. image:: https://raw.githubusercontent.com/dbfixtures/mirakuru/master/logo.png :height: 100px mirakuru ======== Mirakuru is a process orchestration tool designed for functional and integration tests. When your application or tests rely on external processes (like databases, APIs, or other services), ensuring these processes are started and ready *before* your main code executes can be challenging. **Mirakuru** solves this by orchestrating the startup of these processes and waiting until they are fully operational (e.g., accepting connections, producing specific output) before allowing your program or tests to continue. .. image:: https://img.shields.io/pypi/v/mirakuru.svg :target: https://pypi.python.org/pypi/mirakuru/ :alt: Latest PyPI version .. image:: https://img.shields.io/pypi/wheel/mirakuru.svg :target: https://pypi.python.org/pypi/mirakuru/ :alt: Wheel Status .. image:: https://img.shields.io/pypi/pyversions/mirakuru.svg :target: https://pypi.python.org/pypi/mirakuru/ :alt: Supported Python Versions .. image:: https://img.shields.io/pypi/l/mirakuru.svg :target: https://pypi.python.org/pypi/mirakuru/ :alt: License Installation ------------ Install mirakuru using pip: .. code-block:: bash pip install mirakuru Quick Start ----------- Here's a simple example showing how mirakuru ensures a Redis server is ready before your code runs: .. code-block:: python from mirakuru import TCPExecutor # Start Redis server and wait until it accepts connections on port 6379 redis_executor = TCPExecutor('redis-server', host='localhost', port=6379) redis_executor.start() # Redis is now running and ready to accept connections # ... your code that uses Redis here ... # Clean up - stop the Redis server redis_executor.stop() The key benefit: ``start()`` blocks until Redis is actually ready, so you never try to connect too early. Usage ----- In projects that rely on multiple processes, there might be a need to guard code with tests that verify interprocess communication. You need to set up all the required databases, auxiliary and application services to verify their cooperation. Synchronizing (or orchestrating) test procedures with tested processes can be challenging. If so, then **mirakuru** is what you need. ``Mirakuru`` starts your process and waits for a clear indication that it's running. The library provides seven executors to fit different cases: .. list-table:: :header-rows: 1 :widths: 25 75 * - Executor - Use When * - **SimpleExecutor** - You just need to start/stop a process without waiting for readiness. Base class for all other executors. * - **Executor** - Base class for executors that verify process startup. * - **OutputExecutor** - Your process prints a specific message when ready (e.g., "Server started on port 8080") * - **TCPExecutor** - Your process opens a TCP port when ready (e.g., Redis, PostgreSQL, Memcached) * - **UnixSocketExecutor** - Your process opens a Unix socket when ready (e.g., Docker daemon, some databases) * - **HTTPExecutor** - Your process serves HTTP requests when ready (e.g., web servers, REST APIs) * - **PidExecutor** - Your process creates a .pid file when ready (e.g., traditional Unix daemons) SimpleExecutor ++++++++++++++ The simplest executor implementation. It simply starts the process passed to constructor, and reports it as running. .. code-block:: python from mirakuru import SimpleExecutor process = SimpleExecutor('my_special_process') process.start() # Here you can do your stuff, e.g. communicate with the started process process.stop() OutputExecutor ++++++++++++++ OutputExecutor starts a process and monitors its output for a specific text marker (banner). The process is not reported as started until this marker appears in the output. .. code-block:: python from mirakuru import OutputExecutor process = OutputExecutor('my_special_process', banner='processed!') process.start() # Here you can do your stuff, e.g. communicate with the started process process.stop() What happens during start here, is that the executor constantly checks output produced by started process, and looks for the banner part occurring within the output. Once the output is identified, as in example `processed!` is found in output. It is considered as started, and executor releases your script from wait to work. TCPExecutor +++++++++++ TCPExecutor should be used to start processes that communicate over TCP connections. This executor tries to connect to the process on the specified host and port to check if it started accepting connections. Once it successfully connects, the process is reported as started and control returns to your code. .. code-block:: python from mirakuru import TCPExecutor process = TCPExecutor('my_special_process', host='localhost', port=1234) proce

Release History

VersionChangesUrgencyDate
3.0.2Imported from PyPI (3.0.2)Low4/21/2026
v3.0.2Tag v3.0.2Low2/11/2026
v3.0.1Tag v3.0.1Low11/1/2025
v3.0.0Tag v3.0.0Low10/29/2025
v2.6.1Tag v2.6.1Low7/2/2025
v2.6.0Tag v2.6.0Low2/7/2025
v2.5.3Tag v2.5.3Low10/11/2024
v2.5.2Tag v2.5.2Low10/17/2023
v2.5.1Tag v2.5.1Low2/27/2023
v2.5.0Tag v2.5.0Low2/17/2023
v2.4.2Tag v2.4.2Low2/9/2022
v2.4.1Tag v2.4.1Low5/31/2021
v2.4.0Tag v2.4.0Low5/20/2021
v2.3.1Tag v2.3.1Low5/7/2021
v2.3.0Tag v2.3.0Low5/11/2020
v2.2.0Tag v2.2.0Low2/11/2020
v2.1.2Tag v2.1.2Low1/10/2020
v2.1.1Tag v2.1.1Low12/12/2019
v2.0.2Tag v2.0.2Low9/27/2019
v2.1.0Tag v2.1.0Low9/3/2019
v2.0.1Tag v2.0.1Low6/22/2019

Dependencies & License Audit

Loading dependencies...

Similar Packages

pytest-postgresqlPostgresql fixtures and fixture factories for Pytest.8.0.0
azure-storage-blobMicrosoft Azure Blob Storage Client Library for Pythonazure-template_0.1.0b6187637
azure-storage-file-shareMicrosoft Azure Azure File Share Storage Client Library for Pythonazure-template_0.1.0b6187637
opentelemetry-instrumentation-qdrantOpenTelemetry Qdrant instrumentation0.60.0
django-modelclusterDjango extension to allow working with 'clusters' of models as a single unit, independently of the database6.4.1