Skip to main content

A library for calling functions and generators from Python modules located in other virtual environments, including environments with different Python versions and conflicting dependencies.

Project description

License  OS  Library Python  Module Python 

MultiEnvEmployer

MultiEnvEmployer — a Python library for calling functions and generators from modules in other virtual environments, including environments with different Python versions and conflicting dependencies.

The library is designed for situations where code cannot be imported directly but needs to be called and controlled from a single main process.


Key Features

  • run Python code in isolated virtualenvs
  • support for different Python versions
  • call functions as regular Python functions
  • pass data between processes
  • support for return, yield, and streaming large data
  • intercept print() without breaking IPC
  • execution time control (timeouts)
  • error handling as regular exceptions
  • file caching of results

Quick Start

from MultiEnvEmployer import Employer, RemoteModule

emp = Employer(
    project_dir="/path/to/project",
    venv_path="/path/to/venv"
)

moduleA = RemoteModule(emp, "moduleA")

result = moduleA.add(2, 4)
print(result)

The moduleA.py module should be located in the specified project directory and will be executed in a different virtualenv.


How It Works

  • code runs in a separate Python process
  • the specified virtualenv is used
  • data is exchanged through a binary channel (pickle)
  • errors and print() are correctly proxied to the main process

From the user's perspective, calls look like regular Python code.


Data Return

Supported:

  • regular return
  • generators (yield)
  • streaming large data (automatic)

For large objects, data is sent in chunks to avoid memory overload.


Timeouts

Supported modes:

  • unlimited
  • hard timeout
  • inactivity-based timeout (progress)

If the time limit is exceeded, the worker process will be terminated.


Error Handling

Errors inside the remote code are raised as Python exceptions:

  • RemoteExecutionError
  • RemoteTimeoutError
  • RemoteImportError
  • and others

Who This Library Is For

MultiEnvEmployer is useful if you need to:

  • run code with conflicting dependencies
  • support multiple Python versions
  • avoid using import due to architectural constraints
  • control code execution at runtime

This is not a dev tool, but an execution infrastructure layer.


Documentation and Source Code

Full documentation, architecture, and examples are available on GitHub:

https://github.com/REYIL/MultiEnvEmployer


License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

multi_env_employer-1.0.1.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

multi_env_employer-1.0.1-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file multi_env_employer-1.0.1.tar.gz.

File metadata

  • Download URL: multi_env_employer-1.0.1.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for multi_env_employer-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1472ef7fd8427680d48a5024c21d7196220c83e9c2d68d01206e7bd49c3f63be
MD5 4cbfdaecff5760c79856e57742b4ae2c
BLAKE2b-256 fce9fef7fb05017547a670808660cf2472cdcbf2cb24c409b91a54e144ef6bca

See more details on using hashes here.

File details

Details for the file multi_env_employer-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for multi_env_employer-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ce9a7b66a3d73f646646f426c31d7ac4854c621bd6af1e65d27e6c6721f839c
MD5 1a9bfe0e1ffba8a75545446d114d28d1
BLAKE2b-256 524ae6d699f56620f0f4e02d427d8b6444051f9af7fb0cb4e41fe27c315d6014

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page