Skip to content

StreamIterator.close函数手动关闭资源导致了线程阻塞 #920

@borenchan

Description

@borenchan

需求背景

业务上需要支持提前中断AI流式输出

问题

  1. appbuilder中没有提供类似中断的接口;
  2. 使用close关闭资源时出现阻塞,影响了后续业务。

com.baidubce.appbuilder.base.utils.iterator.StreamIterator#close

public void close() {
        try {
            if (reader != null) {
                reader.close();   //这里阻塞,直到百度服务器输出结束关闭连接
            }
        } catch (Exception ignored) {
            // ignore
        } finally {
            try {
                if (resp != null) {
                    resp.close();
                }
            } catch (Exception ignored) {
                // ignore
            }
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions