connect_default.py 315 B

1234567891011121314151617
  1. import asyncio
  2. from nats.aio.client import Client as NATS
  3. async def example():
  4. # [begin connect_default]
  5. nc = NATS()
  6. await nc.connect()
  7. # Do something with the connection
  8. await nc.close()
  9. # [end connect_default]
  10. loop = asyncio.get_event_loop()
  11. loop.run_until_complete(example())
  12. loop.close()