Registry / devops / mitogen

mitogen

JSON →
library0.3.49pypypi✓ verified 89d ago

Mitogen is a library for writing distributed self-replicating programs, designed to be fast, efficient, and flexible. It enables code execution on remote hosts with minimal overhead, making it ideal for automation and orchestration tasks. The current version is 0.3.46, and it sees regular minor releases, typically every few weeks or months, indicating active development.

pip install mitogen
INSTALL
IMPORT
SIG · MITOGEN
M
mitogen
devopspythonv0.3.49
Install
1.7s avg
Import
149ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.3.49 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.157s · 19.7MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 1.7s · import 0.140s · 20MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Router
✓ from mitogen.master import Router
ImportPolicy
✓ from mitogen.master import ImportPolicy
✗ from mitogen.master import Importer
Importer class and its whitelist/blacklist methods were removed in v0.3.42. Use ImportPolicy instead.

This example demonstrates how to connect to a remote host (defaulting to localhost via SSH) and execute a simple Python function, returning its result. Ensure SSH is configured for the target host or choose a different transport (e.g., `router.fork()`).

import mitogen.master import os import sys import logging logging.basicConfig(level=logging.INFO) # Connect to a remote host via SSH. For local testing, set MITOGEN_TARGET_HOSTNAME='localhost' # or configure your SSH client to allow localhost connections without password. router = mitogen.master.Router() try: hostname = os.environ.get('MITOGEN_TARGET_HOSTNAME', 'localhost') if hostname == 'localhost' and not os.path.exists(os.path.expanduser('~/.ssh/id_rsa')): logging.warning("No SSH key found for 'localhost'. Ensure SSH access is configured or use a different transport.") context = router.ssh(hostname=hostname) # Run an operation on the remote host. res = context.call(lambda: 'Hello from Python %s on %s' % (sys.version, os.uname()[1])) # Print its return value. print(f"Remote execution result: {res}") finally: router.shutdown() router.join()
Debug
Known issues
breakingThe `Importer` class and its `whitelist`/`blacklist` methods for controlling remote imports were removed in v00.3.42. Direct manipulation of `Router.importer_whitelist` or `Router.importer_blacklist` is no longer supported.
fix
Migrate to `mitogen.master.ImportPolicy`. Construct an `ImportPolicy` object with `overrides` or `blocks` and pass it to the `Router` constructor via the `import_policy` argument. E.g., `policy = ImportPolicy(overrides={'mypackage': True}); router = Router(import_policy=policy)`.
affects: >=0.3.42
gotchaMitogen's internal logging configuration was overhauled in v0.3.45. If your application relied on specific default logging behaviors or internal Mitogen loggers, you might observe changes in log output or levels.
fix
Review the Mitogen logging documentation and explicitly configure your `logging` module settings (e.g., `logging.basicConfig`) to ensure desired behavior. For Ansible integration, note that Mitogen debugging is hidden by default at high Ansible verbosity levels.
affects: >=0.3.45
gotchaImproved security in v0.3.41 introduced a default deny policy for `Unpickler GLOBAL` opcodes, restricting what types can be unpickled over the network. This prevents deserialization of potentially arbitrary code.
fix
If you encounter pickling errors for custom types, ensure they are explicitly allowed or refactor your code to avoid relying on implicit `GLOBAL` opcodes for insecure types. Consider using `mitogen.master.ImportPolicy` to manage allowed types for unpickling if custom unpickling is necessary and safe.
affects: >=0.3.41
Errors
Common errors & fixes
AttributeError: 'Router' object has no attribute 'importer_whitelist'
Attempting to access or set the deprecated `importer_whitelist` (or `importer_blacklist`) attribute on a `Router` instance.
fix
The `importer_whitelist` attribute was removed in Mitogen v0.3.42. Use `mitogen.master.ImportPolicy` instead, which is passed as an argument to the `Router` constructor. Example: `policy = mitogen.master.ImportPolicy(overrides={'mypackage': True}); router = mitogen.master.Router(import_policy=policy)`.
mitogen.parent.ModuleDeniedByOverridesError: Refused to import module 'your_module_name'
A module required by remote code is not explicitly allowed by the `ImportPolicy` configured on the Mitogen router, often after upgrading to v0.3.42 or later.
fix
Configure your `mitogen.master.ImportPolicy` to explicitly allow the module. For example, if 'your_module_name' is denied: `policy = mitogen.master.ImportPolicy(overrides={'your_module_name': True}); router = mitogen.master.Router(import_policy=policy)`. Remember to restart the router for changes to take effect.
Upgrade
Version history
0.3.49latest on PyPI · released Jun 3, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
mitogen — pip install mitogen · libregistry