Do not silence exceptions that occur in the SSE task

This commit is contained in:
Miguel Grinberg
2025-05-18 12:20:50 +01:00
parent 3c936a82e0
commit 654a85f46b
2 changed files with 23 additions and 2 deletions

View File

@@ -42,3 +42,15 @@ class TestWebSocket(unittest.TestCase):
'data: [42, "foo", "bar"]\n\n'
'data: foo\n\n'
'data: foo\n\n'))
def test_sse_exception(self):
app = Microdot()
@app.route('/sse')
@with_sse
async def handle_sse(request, sse):
await sse.send('foo')
await sse.send(1 / 0)
client = TestClient(app)
self.assertRaises(ZeroDivisionError, self._run, client.get('/sse'))