Skip to main content

mirakuru

Maybe you want to be able to start database only when you start your program, or maybe you need just to set up additional processes for your tests, this is where you should consider using mirakuru, to add superpowers to your program, or tests.

Latest PyPI version Documentation Status Number of PyPI downloads Wheel Status Egg Status License

Package status

Tests Coverage Status Requirements Status

About

As developers, we have to work on project that rely on multiple processes to run. We guard ourselves with tests. But sometimes it’s not enough what one process sends, and the other receives. Sometimes there’s need to actually exchange data between processes. Or write selenium tests. Or maybe write a program that takes care of starting databases or other required services itself.

If so, then mirakuru is what you need.

Mirakuru starts your required process, and wait for clear indication, that it’s running. There are three basic executors with predefined conditions:

  • Executor - simply starts

  • OutputExecutor - awaits for specified output to be given by process

  • TCPExecutor - waits for ability to connect through tcp with process

  • HTTPExecutor - waits for successful HEAD request (and tcp before)

  • PidExecutor - waits for a specified file to exist

from mirakuru import HTTPExecutor
from httplib import HTTPConnection, OK


def test_it_works():
    executor = HTTPExecutor("./server", url="http://localhost:6543/")

    # start and wait for it to run
    executor.start()
    # should be running!
    conn = HTTPConnection("localhost", 6543)
    conn.request('GET', '/')
    assert conn.getresponse().status is OK
    executor.stop()

The server command in this case is just a bash script that sleeps for some time and then launches the builtin SimpleHTTPServer on port 6543.

Author

The project was first developed by Mateusz Lenik as summon_process. Later forked, renamed to mirakuru and tended to by The A Room @ Clearcode.

License

mirakuru is licensed under LGPL license, version 3.

Contributing and reporting bugs

Source code is available at: ClearcodeHQ/mirakuru. Issue tracker is located at GitHub Issues. Projects PyPi page.

When contributing, don’t forget to add your name to AUTHORS.rst file.

CHANGELOG

0.3.0

  • [feature] PidExecutor that waits for specified file to be created.

  • pypy compatibility

  • [fix] closing all resources explicitly

0.2.0

  • [fix] - kill all children processes of Executor started with shell=True

  • [feature] executors are now context managers - to start executors for given context

  • [feature] Executor.stopped - context manager for stopping executors for given context

  • [feature] HTTPExecutor and TCPExecutor before .start() check whether port is already used by other processes and raise AlreadyRunning if detects it

  • moved python version conditional imports into compat.py module

0.1.4

  • fix issue where setting shell to True would execute only part of the command.

0.1.3

  • fix issue where OutputExecutor would hang, if started process stopped producing output

0.1.2

  • [fix] removed leftover sleep from TCPExecutor._wait_for_connection

0.1.1

  • fixed MANIFEST.in

  • updated packaging options

0.1.0

  • exposed process attribute on Executor

  • exposed port and host on TCPExecutor

  • exposed url on HTTPExecutor

  • simplified package structure

  • simplified executors operating api

  • updated documentation

  • added docblocks for every function

  • applied license headers

  • stripped orchestrators

  • forked off from summon_process

Metadata

Release files for mirakuru 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mirakuru 0.3.0
File Size Uploaded Provenance
mirakuru-0.3.0.tar.gz 12.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mirakuru 0.3.0
File Interpreter ABI Platform
mirakuru-0.3.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 29.4 kB

Release files / mirakuru-0.3.0.tar.gz

Download URL mirakuru-0.3.0.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
848a41e04a5845667ab449323044dcb7fd29ef43745e6fa7b12913bfa6fd8c40
BLAKE2b-256 checksum
How to use checksums
e5f7bb05b87217fd37bfcfcf66d56e9c1d1930bf27d8c638cfd5319218628dcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / mirakuru-0.3.0-py2.py3-none-any.whl

Download URL mirakuru-0.3.0-py2.py3-none-any.whl
Size 16.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
9819e1838e5e08a61bf32f05f95b8aab57acd41c6b0d5dc90438e5ed6a0d6814
BLAKE2b-256 checksum
How to use checksums
ed97cff6fd9682675d47e8b9acf469ab288291cb652f49a808dd4ebaeecb2d63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for mirakuru 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page