recherche

Maison  >  Questions et réponses  >  le corps du texte

python - tornado 如何知道客户端是否结束连接

有一个tornado的脚本,当客户端请求时服务器会向某处发出一个长耗时的http请求,但是当客户端停止请求时服务端的那一个请求也就毫无意义。
如何知晓客户端的连接情况?

阿神阿神2889 Il y a quelques jours310

répondre à tous(3)je répondrai

  • PHP中文网

    PHP中文网2017-04-17 17:34:07

    Remplacer self.on_finish()
    Documentation

    répondre
    0
  • 高洛峰

    高洛峰2017-04-17 17:34:07

    Le client met fin à la connexion unilatéralement soit en envoyant un message de fin au serveur, soit en attendant que le serveur expire. Sinon, si vous y mettez fin unilatéralement, le serveur ne pourra pas attendre et gaspiller des ressources. .

    répondre
    0
  • 大家讲道理

    大家讲道理2017-04-17 17:34:07

    RequestHandler.on_connection_close()
    Called in async handlers if the client closed the connection.
    
    Override this to clean up resources associated with long-lived connections. Note that this method is called only if the connection was closed during asynchronous processing; if you need to do cleanup after every request override on_finish instead.
    
    Proxies may keep a connection open for a time (perhaps indefinitely) after the client has gone away, so this method may not be called promptly after the end user closes their connection.

    http://www.tornadoweb.org/en/stable/web....

    répondre
    0
  • Annulerrépondre