Async API calls in streamlit

Hello, I able to fetch the data using API package. I am making calls using asyc. I can fetch the data easily but the problem.

When I am trying to use streamlit and write the data on streamlit st.write. I am facing this error. "RuntimeError: There is no current event loop in thread ‘ScriptRunner.scriptThread’.

Please help with the solution.

How about awaiting the coroutine

import streamlit as st
import asyncio

async def fetch_data():
    return data

async def main():
    await fetch_data()

if __name__ == "__main__":

Thank you so much. It worked :slight_smile:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.