mirakuru 0.2 released
Last Thursday, we released new minor version of mirakuru. Mirakuru is a helpful tools that lets add superpowers to Your tests, or maybe other scripts that need other processes to run.
Changes introduced to mirakuru 0.2 - are:
context managers (for both starting and stopping)
ability to detect if resources required by executors (TCP or HTTP) aren't already used.
and a fix, for killing executors started with their own shell.
Context managers
Context managers are reintroduced, since we removed "orchestrators" when we forked mirakuru form original code base - summon_process. "Orchestrators", as summon_processes called its specially crafted context managers, weren't general enough, and would require writing new context manager for new cases.
AlreadyRunning exception
Ability to detect the possibility to start executor - this feature comes from our testing environment, where a process leaked from test run, that has been forcefully stopped. We spend some time investigating, because error we got wasn't informative at all. Currently, TCPExecutor and HTTPExecutor will raise mirakuru.exception.AlreadyRunning exception.
Stopping executors with their own shell
And the last one, is a well known issue, when starting subprocesses with shell arg set to True. This makes subprocess to be started in it's own shell, but unfortunately, when You want to kill the process in normal way, let say like that:
import subprocess awsome_process = subprocess.Popen( './start_me.py --run_forever', shell=True) awsome_process.terminate()
Killing subprocess here only kills shell subprocess have been started in - effectively leaking it. Solution is to set a process group id - but that might be changed while the processes are running, or better solution, to set session id:
import os import signal import subprocess awsome_process = subprocess.Popen( './start_me.py --run_forever', preexec_fn=os.setsid, shell=True) os.killpg(awsome_process.pid, signal.SIGTERM)
Mirakuru's executors will now do that out of the box.
Links
Links where mirakuru can be found: