【问题标题】:Error on socket shutdown: [WinError 10038] An operation related to an object that is not a socket套接字关闭时出错:[WinError 10038] 与不是套接字的对象相关的操作
【发布时间】:2021-11-16 14:07:11
【问题描述】:

我有以下问题: 我正在(同时)对来自同一个数据库的 sql 请求进行处理,第二个请求取决于第一个请求的结果: 例如

def get_alldata(timestart):
    statement = f""" SELECT * FROM "xxx"."xxx" WHERE timestart>=toDateTime('{timestart}')"""
    df = client.query_dataframe(statement) #note that i already defined my 
                                 #client from clickhouse and it works
    return df

#now the second
def second_request(id, time, line):  #note that i get the id,time and line from the table(df) of 
                                     #the first function (i'm working 
                                     #with dash plotly) so i saved df in a Store and used it for 
                                     #the second function
    statement = f'''SELECT student,class FROM "xxx"."xxx" WHERE id IN ({id}) AND time IN ({time}) AND line IN ({line})'''
    df = client.query_dataframe(statement)
    return df

第一个功能在我的应用程序中有效,但当涉及到第二个时,我收到此错误:

套接字关闭时出错:[WinError 10038] 与不是套接字的对象相关的操作

还有 AttributeError: 'NoneType' object has no attribute 'close'

我尝试在网上查找有关套接字的信息,但没有找到与我的问题相关的内容

有人有想法吗??

我在破折号的两个回调中调用函数

@app.callback(Output('id', 'options'),
              Output('time', 'options'),
              Output('line', 'options'),
             [Input('loaded_data', 'data'),
]
)
def get_first_fuction(data):
    df = get_alldata(data) # then i used it for a dropdown for the three outputs
.
.
@app.callback(
     Output('graph', 'children'),
     [Input('id', 'value'),
      Input('time', 'value'),
      Input('line', 'value'),
]
)
def second_function(id,time,line):
    df = second_request(id,time,line)
    # and i use it for a plot
    # I get the error by this df 

【问题讨论】:

    标签: python sql sockets plotly-dash clickhouse


    【解决方案1】:

    也许您关闭了光标和/或这些函数的执行(调用)之间的连接?我猜函数看起来没问题,但你能展示整个程序或至少你实际调用函数的部分吗?

    【讨论】:

    • 这不是答案,而是评论。请考虑在此处添加评论。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-19
    • 2015-02-06
    • 2021-09-01
    • 2016-12-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多