Serve a python object through a simple socket; supports multiple connections.
Project description
Now available on pip! Just run
pip install Minimal-Server
Minimal Server
This library serves a very simple purpose: have a simple client/server pair to "serve" a Python (2 & 3) object.
Have you ever had to deal with a python object that takes forever to initiate? Maybe you need it to call it once in another script, but you can't bear the time it takes to initialize it. This module comes handy in these situations. It works as follows:
Server script:
from minimal_server import minimal_server
obj = SlowInitObject(...) # An instance of the object
minimal_server(obj, host='localhost', port=4444)
Client script:
from minimal_server import MinimalClient
client = MinimalClient(SlowInitObject, # Pass the class, not the instance!
host='localhost',
port=4444)
client.foo(...) # Call any public method of SlowInitObject
Easy, right?
Throughput
In my tests, it seems that the communication via sockets takes around 1 ms on localhost. So if the object you're trying to interface is substantially faster than that, it will impact its throughput significantly.
A note about Python 2 / 3 interoperability
This module is a great way to use Python 2 modules in a Python 3 codebase. Just make sure to set pickle_protocol=2 in both the client and the server.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file Minimal Server-1.0.1.tar.gz.
File metadata
- Download URL: Minimal Server-1.0.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe5a41fbe8dd4ff66e461997981518a50e4bf464a0264159021d2e533ec9a40e
|
|
| MD5 |
389b7a5ac8e220bb5f1a32b95166318c
|
|
| BLAKE2b-256 |
c04b242da12024a81600e4bc8ebab7363bdfb238c16bfe85427d70841565778a
|
File details
Details for the file Minimal_Server-1.0.1-py3-none-any.whl.
File metadata
- Download URL: Minimal_Server-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2638c26e195e8b8e824aa0abddf23f92088ad6025029b09fd69d34a5251be004
|
|
| MD5 |
2818123eb094c55a16bb6ca21c183158
|
|
| BLAKE2b-256 |
0e4b8de57dd8bb200ad2c1742403407a315322e192a59925874aab36f3de0e32
|