quart icon indicating copy to clipboard operation
quart copied to clipboard

app.teardown_websocket no longer exists

Open heuripedes opened this issue 2 years ago • 1 comments

app.teardown_websocket no longer exists in 0.19.x. It was previously implemented in the Scaffold class, the previous base for Quart and Blueprint, which was deleted in commit https://github.com/pallets/quart/commit/598b771abd36fb2d581aa88a64336c88615a26bf

Code to reproduce:

from quart import Quart

app = Quart(__name__)

@app.teardown_websocket
def on_websocket_teardown(*args, **kwargs):
    print("TEARDOWN!!")

app.run()

Traceback:

Traceback (most recent call last):
  File "/home/higor/code/no-teardown-websocket/app.py", line 5, in <module>
    @app.teardown_websocket
AttributeError: 'Quart' object has no attribute 'teardown_websocket'

Expected behavior:

  1. no crash
  2. a function should have been registered as a websocket teardown handler

Environment:

  • Python version: 3.9.18
  • Quart version: 0.19.4

heuripedes avatar Dec 06 '23 20:12 heuripedes

It's worth noting that quart 0.19 still contains logic that runs the registered websocket teardown handlers (Quart.do_teardown_websocket()), but there is no longer a handy method to add a new function to the Quart.teardown_websocket_funcs list.

heuripedes avatar Dec 06 '23 20:12 heuripedes

Restored in 153617a0b4fb125777ef6fd66757955ec72bbfb6

pgjones avatar Apr 01 '24 16:04 pgjones