diff --git a/cubyc/query/query.py b/cubyc/query/query.py
index 836d258..fbe2f54 100644
--- a/cubyc/query/query.py
+++ b/cubyc/query/query.py
@@ -87,7 +87,14 @@ def query(
         log.error("Comments table can only be queried from remote repositories.")
         exit()
 
-    loop = asyncio.get_event_loop()
+
+    # check if asyncio event loop is already running
+
+    try:
+        loop = asyncio.get_event_loop()
+    except RuntimeError:
+        loop = asyncio.new_event_loop()
+        asyncio.set_event_loop(loop)
 
     if branch == "all" or branch is None:
         branch = Repo(path=utils.get_caller_path()).active_branch.name
diff --git a/cubyc/utils.py b/cubyc/utils.py
index ff11a4f..93dd0ca 100644
--- a/cubyc/utils.py
+++ b/cubyc/utils.py
@@ -358,7 +358,7 @@ def get_caller_path():
 
     path = os.path.abspath("")
 
-    if not is_running_in_notebook():
+    if not is_running_in_notebook() and not is_running_in_streamlit():
         # Get the current frame
         current_frame = inspect.currentframe()
 
@@ -393,3 +393,19 @@ def is_running_in_notebook() -> bool:
         return False
 
     return 'IPKernelApp' in ipython.config
+
+
+def is_running_in_streamlit() -> bool:
+    """
+    Check if the code is running in a Streamlit app.
+
+    Returns
+    -------
+    bool
+        True if running in a Streamlit app, False otherwise.
+    """
+    try:
+        import streamlit.runtime.scriptrunner.script_run_context
+        return True
+    except ImportError:
+        return False
\ No newline at end of file