Multiple subscriptions

import asyncio
from netlab.async_client import NetlabClient


async def main():
    async with NetlabClient() as client:

        async def subscription_1():
            async with client.subscribe("SYS.TIME.UPDATE.5SEC") as events:
                while True:
                    event = await events.get()
                    print("event from subscription_1", event)

        async def subscription_2():
            async with client.subscribe("SYS.TIME.UPDATE.5SEC") as events:
                while True:
                    event = await events.get()
                    print("event from subscription_2", event)

        completed, pending = await asyncio.wait([
            asyncio.ensure_future(subscription_1()),
            asyncio.ensure_future(subscription_2()),
        ], return_when=asyncio.FIRST_COMPLETED)

        print("One of the tasks stopped!", completed)


if __name__ == '__main__':
    asyncio.run(main())