offu / WeRoBot

WeRoBot 是一个微信公众号开发框架

Home Page:https://werobot.readthedocs.io/zh_CN/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@myrobot.text回复函数运行超过一段时间会导致连接失败

Nonponder opened this issue · comments

使用werobot接入chatGPT,由于chatGPT计算时间很长导致运算长时间不回复报错:
`WSGI application error
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 266, in
inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 122, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 85, in callWithContext
return func(*args,**kw)
File "/usr/lib/python3/dist-packages/twisted/web/wsgi.py", line 533, in run
self.started = True
--- ---
File "/usr/lib/python3/dist-packages/twisted/web/wsgi.py", line 508, in run
self.write(elem)
File "/usr/lib/python3/dist-packages/twisted/web/wsgi.py", line 462, in write
return blockingCallFromThread(
File "/usr/lib/python3/dist-packages/twisted/internet/threads.py", line 122, in blockingCallFromThread
result.raiseException()
File "/usr/lib/python3/dist-packages/twisted/python/failure.py", line 467, in raiseException
raise self.value.with_traceback(self.tb)
builtins.AttributeError: 'NoneType' object has no attribute 'writeHeaders'

Unhandled Error
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/bottle.py", line 3026, in run
return sa(self.host, self.port, **self.options).run(handler)
File "/usr/local/lib/python3.8/dist-packages/bottle.py", line 2931, in run
reactor.run()
File "/usr/lib/python3/dist-packages/twisted/internet/base.py", line 1267, in run
self.mainLoop()
File "/usr/lib/python3/dist-packages/twisted/internet/base.py", line 1276, in mainLoop
self.runUntilCurrent()
--- ---
File "/usr/lib/python3/dist-packages/twisted/internet/base.py", line 875, in runUntilCurrent
f(*a, **kw)
File "/usr/lib/python3/dist-packages/twisted/web/wsgi.py", line 521, in wsgiError
self.request.loseConnection()
File "/usr/lib/python3/dist-packages/twisted/web/http.py", line 1551, in loseConnection
self.channel.loseConnection()
builtins.AttributeError: 'NoneType' object has no attribute 'loseConnection'
`
目前正常回复原始query不会报错,只有超时情况会报错,请问如何解决?

同样的问题。