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 mitogenVerified import paths — ran on the pinned version, not inferred.
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()`).
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)`.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.
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.
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)`.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.No dependency data recorded yet.