Opinionated distributed RPC using AMQP workers
Project description
beef
Beef is good for your health.
Usage
from beef import beef
@beef
async def add(x: int, y: int) -> int:
return x + y
Server:
async def server():
async with add.connect('amqp://localhost/'):
await add.serve() # here server blocks forever, executing incoming tasks
if __name__ == '__main__':
import asyncio
asyncio.run(server())
Client (blocking):
async def client():
async with add.connect('amqp://localhost/'):
task_id = await add.submit(1, 2) # submits task
result = await add.result(task_id) # waits for completion
if __name__ == '__main__':
import asyncio
asyncio.run(client())
Client (polling):
import asyncio
async def client():
async with add.connect('amqp://localhost/'):
task_id = await add.submit(1, 2) # submits task
while True:
status = await add.get_status(task_id)
if status.is_final:
break
await asyncio.sleep(1)
print(f'Task {task_id} completed with status {status})
if __name__ == '__main__':
import asyncio
asyncio.run(client())
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
pybeef-0.0.2-py3-none-any.whl
(5.8 kB
view hashes)