Skip to main content

Fast and reliable distributed systems in Python

Project description

PyPI

🌀 Portal

Fast and reliable distributed systems in Python.

Features

  • 📡 Communication: Portal lets you bind functions to a Server and call them from one or more Clients. Wait on results via Future objects. Clients can automatically restore broken connections.
  • 🚀 Performance: Optimized for throughput and latency. Array data is zero-copy serialized and deserialized for throughput near the hardware limit.
  • 🤸 Flexibility: Function inputs and outputs can be nested dicts and lists of numbers, strings, bytes, None values, and Numpy arrays. Bytes allow applications to chose their own serialization, such as pickle.
  • 🚨 Error handlings: Provides Process and Thread objects that can reliably be killed by the parent. Unhandled exceptions in threads stop the program. Error files can be used to stop distributed systems.
  • 📦 Request batching: Use BatchServer to collect multiple incoming requests and process them at once, for example for AI inference servers. Batching and dispatching happens in a separate process to free the GIL.
  • Correctness: Covered by over 100 unit tests for common usage and edge cases and used for large scale distributed AI systems.

Installation

pip install portal

Example

This example runs the server and client in the same Python program using subprocesses, but they could also be separate Python scripts running on different machines.

def server():
  import portal
  server = portal.Server(2222)
  server.bind('add', lambda x, y: x + y)
  server.bind('greet', lambda msg: print('Message from client:', msg))
  server.start()

def client():
  import portal
  client = portal.Client('localhost:2222')
  future = client.add(12, 42)
  result = future.result()
  print(result)  # 54
  client.greet('Hello World')

if __name__ == '__main__':
  import portal
  server_proc = portal.Process(server, start=True)
  client_proc = portal.Process(client, start=True)
  client_proc.join()
  server_proc.kill()
  print('Done')

Questions

Please open a separate GitHub issue for each question.

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

portal-3.8.0.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

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

portal-3.8.0-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file portal-3.8.0.tar.gz.

File metadata

  • Download URL: portal-3.8.0.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for portal-3.8.0.tar.gz
Algorithm Hash digest
SHA256 5ee9f24e10b729f8e94928038ac146ab74e163623f157b7e0914ccf1c8e2d20d
MD5 9059ba0285409a90d0abc9e69cd8215b
BLAKE2b-256 d20ac5a143a723cc4ad15aa687c238a6d88016a3e8859842807be1b77dd75d72

See more details on using hashes here.

File details

Details for the file portal-3.8.0-py3-none-any.whl.

File metadata

  • Download URL: portal-3.8.0-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for portal-3.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b454b4ee5c64adacb19b1150cfda68981adb1c8e0e864e0090ccdf2769672c5e
MD5 98fb3ab26fe285cd99f60473d07c6ae8
BLAKE2b-256 55f4abeeb49c9edc9b8b294cc190e55b9e143e652b106ce3fe70ecf31e055a1c

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