Python client library for peer applications running under The Mule test orchestrator.
pip install -e lib/python/import asyncio
import logging
from the_mule import MuleClientBuilder
async def main():
client = await MuleClientBuilder().build()
await client.send_status("started")
async for command in client:
logging.info(f"received: {command}")
if command == "shutdown":
await client.send_status("stopped")
break
await client.close()
asyncio.run(main())| Variable | Required | Description |
|---|---|---|
REDIS_URL |
yes | Redis connection URL |
PEER_NAME |
yes | This peer's name |
LOG_LEVEL |
no | Python log level (e.g., INFO) |
- Commands: the async iterator calls
BLPOP {peer}_command 0(truly blocking, no polling). Becauseredis.asynciois used, theawaityields to the asyncio event loop so other coroutines run freely. - Logs: a
logging.Handlercaptures log records and forwards them to Redis viaLPUSH {peer}_log "level|message"in a background thread. - Status:
send_status()callsSET {peer}_status <value>, which triggers a keyspace notification on the orchestrator side.
MuleClientBuilder()— reads env vars.redis_url(url)/.peer_name(name)— override.build()— connect, install log handlerMuleClient.send_status(status)— push status to orchestratorasync for command in client:— yields raw command stringsMuleClient.close()— clean up