Asynchronous client library for interacting with MOTHR
Project description
aiomothr
Installation
pip install aiomothr
Usage
Basic example submitting a job request
from aiomothr import AsyncJobRequest
request = AsyncJobRequest(service="echo")
request.add_parameter(value="Hello MOTHR!")
result = await request.run_job()
print(result)
Submitting a job request Using AsyncMothrClient
. This allows you to reuse the
client connection when making multiple requests.
from mothrpy import AsyncJobRequest, AsyncMothrClient
client = AsyncMothrClient()
# Send one request
request = AsyncJobRequest(client=client, service="echo")
request.add_parameter(value="Hello MOTHR!")
result = await request.run_job()
print(result)
# Reuse the client in another request
request = AsyncJobRequest(client=client, service="echo")
request.add_parameter(value="Hello again MOTHR!")
result = await request.run_job()
print(result)
Submit concurrent job requests
import asyncio
from mothrpy import AsyncJobRequest, AsyncMothrClient
client = AsyncMothrClient()
request_a = AsyncJobRequest(client=client, service="echo")
request_a.add_parameter(value="Hello MOTHR!")
request_b = AsyncJobRequest(client=client, service="echo")
request_b.add_parameter(value="Hello again MOTHR!")
# Execute both requests concurrently
tasks = [request_a.run_job(), request_b.run_job()]
results = await asyncio.gather(*tasks)
for result in results:
print(result)
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
aiomothr-0.2.1.tar.gz
(9.4 kB
view hashes)
Built Distribution
aiomothr-0.2.1-py3-none-any.whl
(10.1 kB
view hashes)