Skip to main content

Asynchronous client library for interacting with MOTHR

Project description

aiomothr

GitHub Actions codecov

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.3.0.tar.gz (9.5 kB view hashes)

Uploaded Source

Built Distribution

aiomothr-0.3.0-py3-none-any.whl (10.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page