starlette icon indicating copy to clipboard operation
starlette copied to clipboard

Background Thread created by WebSocketTestSession should exit when close() is called

Open devxpy opened this issue 4 years ago • 0 comments

Hello!

I've been trying to write tests for a starlette websocket API.

Only one problem - the server isn't written in a way to exit nicely when a websocket is closed. As a result, the tests just sit there, because websocket_connect() won't exit until the server does.

By looking at the source, I figured that WebSocketTestSession is waiting for the session thread (_run()) to complete.

Can we please make it so that it stops the server when close() is called?


I've cobbled together a small commit to make this work. If you're on board with this change, I'd love to upstream this.

devxpy avatar May 16 '20 18:05 devxpy