⚡️electron
Rapid RPC Framework for building Python 3.7+ services using Asyncio + MsgPack
Installation
$ pip install electron-rpc
How does it work?
Create a server instance with a single endpoint sum() which outputs the sum of two values:
from electron import Server
app = Server()
@app.endpoint("sum")
async def sum(a, b, **kwargs):
return f"Result: {a + b}"
app.run()
__ __
___ / /__ _____/ /__________ ____
/ _ \/ / _ \/ ___/ __/ ___/ __ \/ __ \
/ __/ / __/ /__/ /_/ / / /_/ / / / /
\___/_/\___/\___/\__/_/ \____/_/ /_/
⚡ electron build v0.0.4
Listening on 127.0.0.1:9999
Registered Endpoints:
- sum
Calling the endpoint from a client
electron uses MsgPack-RPC, so craft a payload and send it over TCP:
import socket
from electron.messages import RemoteProcedureCall
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("127.0.0.1", 9999))
sock.send(RemoteProcedureCall(endpoint="sum", args=[1, 2]).encode())
data = sock.recv(1024)
print(f"Received: \n{data.decode()}")
sock.close()
Received:
Result: 3
Background Tasks
To create a background task, decorate it with @app.background(time_in_seconds):
@app.background(3)
async def some_background_task():
print("Running background task every 3 seconds")
Now the task will execute every 3 seconds.
Metadata
Release files for electron-rpc 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| electron-rpc-0.0.4.tar.gz | 4.6 kB | Without provenance | Details for electron-rpc-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| electron_rpc-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for electron_rpc-0.0.4-py3-none-any.whl |
Total release size: 12.6 kB
Release files / electron-rpc-0.0.4.tar.gz
| Download URL | electron-rpc-0.0.4.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5f742512030981c3464226db8031febceabe33dc854d2fc232c072d7f001c64
|
|
BLAKE2b-256 checksum How to use checksums |
d99b98e55dea58983c5792d9ebab9ee6afa42f3ec53835d18ad365769efc6e8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.6
|
Release files / electron_rpc-0.0.4-py3-none-any.whl
| Download URL | electron_rpc-0.0.4-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b605dcfe311e2243cee3d91b8b9f86e546cba5fb21e693c972aa29858ed6be28
|
|
BLAKE2b-256 checksum How to use checksums |
a4b30f4915c701d350126636f0822d0e6acc81d8878f8b1bb56fab201e68ed24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.6
|
Security for electron-rpc 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.