Hi, I had the same problem. I’m running the app into a remote server, and It works fine for a few minutes and then crash and get this error. I don’t know what the problem is… till yesterday everything was working ok in my local
2023-02-24 12:41:43.796 Task exception was never retrieved
future: <Task finished name='Task-851' coro=<WebSocketProtocol13.write_message.<locals>.wrapper() done, defined at /home/gdeuser/miniconda3/envs/py310/lib/python3.10/site-packages/tornado/websocket.py:1090> exception=WebSocketClosedError()>
Traceback (most recent call last):
File "/home/gdeuser/miniconda3/envs/py310/lib/python3.10/site-packages/tornado/websocket.py", line 1092, in wrapper
await fut
tornado.iostream.StreamClosedError: Stream is closed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/gdeuser/miniconda3/envs/py310/lib/python3.10/site-packages/tornado/websocket.py", line 1094, in wrapper
raise WebSocketClosedError()
tornado.websocket.WebSocketClosedError
2023-02-24 12:41:43.797 Task exception was never retrieved
future: <Task finished name='Task-856' coro=<WebSocketProtocol13.write_message.<locals>.wrapper() done, defined at /home/gdeuser/miniconda3/envs/py310/lib/python3.10/site-packages/tornado/websocket.py:1090> exception=WebSocketClosedError()>
Traceback (most recent call last):
File "/home/gdeuser/miniconda3/envs/py310/lib/python3.10/site-packages/tornado/websocket.py", line 1092, in wrapper
await fut
tornado.iostream.StreamClosedError: Stream is closed
My code is:
from pathlib import Path
import datetime
import pandas as pd
import plotly.express as px
import streamlit as st
st.set_page_config(
page_title="Resistencia HormigĂłn",
layout="wide",
initial_sidebar_state='expanded')
with open('style.css') as f:
st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
@st.cache_data
def load_data():
df = pd.read_parquet(Path(__file__).resolve().parents[1] / f'DHC_app/data/resistencias.parquet')
return df
st.header(f'Resistencia de HormigĂłn')
df=load_data()
df.columns = df.columns.str.capitalize()
df = df.round(2)
df['Grupo_economico'] = df['Grupo_economico'].str.title()
df['Zona'] = df['Zona'].str.title()
with st.sidebar:
count=0
Fecha_inicio = st.date_input('Fecha inicio:', datetime.date(2022,1,1), min_value=datetime.date(2019,1,1), key=f'{count}_date')
count += 1
Fecha_final = st.date_input('Fecha fin:', pd.to_datetime('today').date(), key=count)
count += 1
Fecha_inicio = str(pd.to_datetime(Fecha_inicio).date())
Fecha_final = str(pd.to_datetime(Fecha_final).date())
df['Fecha'] = pd.to_datetime(df['Fecha']).dt.strftime('%Y-%m-%d')
df = df.query(f'"{Fecha_inicio}" <= Fecha <= "{Fecha_final}"')
tabs = st.tabs(["Diferencia de Resistencia a 28 dĂas"])#, "Cumplimiento de Resistencias", "7 vs 28 dĂas"]) #"Cono", "Densidad",
tab_diferencia_resistencia = tabs[0]
#tab_cono = tabs[1]
#tab_densidad = tabs[2]
df = df.query(f'"{Fecha_inicio}" <= Fecha <= "{Fecha_final}"')
with tab_diferencia_resistencia:
fig = px.strip(df, x='Fecha', y='Diff', color='Color', hover_data=['Tipo_hormigon', 'Resistencia_28'], color_discrete_map={
"red": "red",
"blue": "blue"})
fig.update_layout(title={'text':f"<b>Diferencia entre Resistencia Hormigonera vs Resistencia Laboratorio</b>", 'x': 0.5,'xanchor':'center','yanchor':'top'}, width=800, height=500, margin=dict(l=20, r=20, t=100, b=20))
fig.update_layout(showlegend=False)
fig.add_hline(y=0, line_dash="dash")
#fig.add_hrect(y0=400, y1=700, line_width=0, fillcolor="green", opacity=0.5)
#fig.add_hrect(y0=-1, y1=-100, line_width=0, fillcolor="red", opacity=0.2)
fig.update_layout(xaxis=dict(rangeselector=dict(buttons=list([dict(count=1,label="1m",step="month",stepmode="backward"),
dict(count=6,label="6m",step="month",stepmode="backward"),
dict(count=1,label="YTD",step="year",stepmode="todate"),
dict(count=1,label="1y",step="year",stepmode="backward"),
dict(step="all")])),
rangeslider=dict(visible=True),
type="date"))
st.plotly_chart(fig)
# Filtro de dataframe para mostrar solo diferencias negativas
df1 = df.query('Diff<0')[['Zona', 'Fecha', 'Grupo_economico', 'Id_muestra', 'Tipo_hormigon', 'R_producto', 'Resistencia_7', 'Resistencia_28', 'Rel_28_fab', 'Diff']].sort_values(by="Diff")
df1 = df1.rename(columns={"Grupo_economico": "Grupo EconĂłmico", "Id_muestra": "ID", "Tipo_hormigon": "Tipo de HormigĂłn", "R_producto": "Resistencia producto (MPa)", "Resistencia_7": "Resistencia a 7 dĂas (MPa)", "Resistencia_28": "Resistencia a 28 dĂas (MPa)", "Rel_28_fab": "Resistencia 28d/Prod (%)", "Diff": "Diferencia (MPa)"})
st.dataframe(df1.style.format({"Resistencia producto (MPa)": "{:.1f}", "Resistencia a 7 dĂas (MPa)": "{:.1f}", "Resistencia a 28 dĂas (MPa)": "{:.1f}", "Resistencia 28d/Prod (%)": "{:.1%}", "Diferencia (MPa)": "{:.2f}"}))