Files
chongming-core/test_amqtt.py
T

30 lines
647 B
Python
Raw Normal View History

2026-07-24 16:33:23 +08:00
import asyncio
from asyncio import CancelledError
import logging
from amqtt.broker import Broker
"""
This sample shows how run a broker
"""
formatter = "[%(asctime)s] :: %(levelname)s :: %(name)s :: %(message)s"
logging.basicConfig(level=logging.INFO, format=formatter)
async def run_server() -> None:
broker = Broker()
try:
await broker.start()
while True:
await asyncio.sleep(1)
except CancelledError:
await broker.shutdown()
def __main__():
try:
asyncio.run(run_server())
except KeyboardInterrupt:
print("Server exiting...")
if __name__ == "__main__":
__main__()