ngrok / ngrok-python

Embed ngrok secure ingress into your Python apps with a single line of code.
https://ngrok.com
Apache License 2.0
103 stars 19 forks source link

How do I get a list of tunnels by calling `ngrok.get_listeners()` from async? #111

Closed Zapzatron closed 2 months ago

Zapzatron commented 2 months ago

How do I get a list of tunnels by calling ngrok.get_listeners() from async?

import ngrok
import asyncio

def get_listeners():
    print(ngrok.get_listeners())

async def async_get_listeners():
    print(ngrok.get_listeners())

get_listeners()

asyncio.run(async_get_listeners())

Output:

[]
<Task pending name='Task-5' coro=<wrap() running at ngrok_wrapper:6>>
Zapzatron commented 2 months ago

Just need to add await before ngrok.get_listeners()