* First attempt at new Websockets implementation based on websockets >= 9.0, with sans-i/o features. Requires more work.
* Update sanic/websocket.py
Co-authored-by: Adam Hopkins <adam@amhopkins.com>
* Update sanic/websocket.py
Co-authored-by: Adam Hopkins <adam@amhopkins.com>
* Update sanic/websocket.py
Co-authored-by: Adam Hopkins <adam@amhopkins.com>
* wip, update websockets code to new Sans/IO API
* Refactored new websockets impl into own modules
Incorporated other suggestions made by team
* Another round of work on the new websockets impl
* Added websocket_timeout support (matching previous/legacy support)
* Lots more comments
* Incorporated suggested changes from previous round of review
* Changed RuntimeError usage to ServerError
* Changed SanicException usage to ServerError
* Removed some redundant asserts
* Change remaining asserts to ServerErrors
* Fixed some timeout handling issues
* Fixed websocket.close() handling, and made it more robust
* Made auto_close task smarter and more error-resilient
* Made fail_connection routine smarter and more error-resilient
* Further new websockets impl fixes
* Update compatibility with Websockets v10
* Track server connection state in a more precise way
* Try to handle the shutdown process more gracefully
* Add a new end_connection() helper, to use as an alterative to close() or fail_connection()
* Kill the auto-close task and keepalive-timeout task when sanic is shutdown
* Deprecate WEBSOCKET_READ_LIMIT and WEBSOCKET_WRITE_LIMIT configs, they are not used in this implementation.
* Change a warning message to debug level
Remove default values for deprecated websocket parameters
* Fix flake8 errors
* Fix a couple of missed failing tests
* remove websocket bench from examples
* Integrate suggestions from code reviews
Use Optional[T] instead of union[T,None]
Fix mypy type logic errors
change "is not None" to truthy checks where appropriate
change "is None" to falsy checks were appropriate
Add more debug logging when debug mode is on
Change to using sanic.logger for debug logging rather than error_logger.
* Fix long line lengths of debug messages
Add some new debug messages when websocket IO is paused and unpaused for flow control
Fix websocket example to use app.static()
* remove unused import in websocket example app
* re-run isort after Flake8 fixes
Co-authored-by: Adam Hopkins <adam@amhopkins.com>
Co-authored-by: Adam Hopkins <admhpkns@gmail.com>
@cansarigol3megawatt Thanks for looking into this and getting the quick turnaround on this. I will 🍒 pick this into the 21.6 branch and get it out a little later tonight.
* Added fix to include subprotocols from scope
* Added unit test to validate fix
* Changes by black
* Made changes to WebsocketConnection protocol
* Linter changes
* Added unit tests
* Fixing bugs in linting due to isort import checks
* Reverting compat import changes
* Fixing linter errors in compat.py
Co-authored-by: Adam Hopkins <admhpkns@gmail.com>
* Remove remove_route, deprecated in 19.6.
* No need for py35 compat anymore.
* Rewrite asyncio.coroutines with async/await.
* Remove deprecated request.raw_args.
* response.text() takes str only: avoid deprecation warning in all but one test.
* Remove unused import.
* Revert unnecessary deprecation warning.
* Remove apparently unnecessary py38 compat.
* Avoid asyncio.Task.all_tasks deprecation warning.
* Avoid warning on a test that tests deprecated response.text(int).
* Add pytest-asyncio to tox deps.
* Run the coroutine returned by AsyncioServer.close.
Co-authored-by: L. Kärkkäinen <tronic@users.noreply.github.com>
* Fix Ctrl+C on Windows.
* Disable testing of a function N/A on Windows.
* Add test for coverage, avoid crash on missing _stopping.
* Initialise StreamingHTTPResponse.protocol = None
* Improved comments.
* Reduce amount of data in test_request_stream to avoid failures on Windows.
* The Windows test doesn't work on Windows :(
* Use port numbers more likely to be free than 8000.
* Disable the other signal tests on Windows as well.
* Windows doesn't properly support SO_REUSEADDR, so that's disabled in Python, and thus rebinding fails. For successful testing, reuse port instead.
* app.run argument handling: added server kwargs (alike create_server), added warning on extra kwargs, made auto_reload explicit argument. Another go at Windows tests
* Revert "app.run argument handling: added server kwargs (alike create_server), added warning on extra kwargs, made auto_reload explicit argument. Another go at Windows tests"
This reverts commit dc5d682448.
* Use random test server port on most tests. Should avoid port/addr reuse issues.
* Another test to random port instead of 8000.
* Fix deprecation warnings about missing name on Sanic() in tests.
* Linter and typing
* Increase test coverage
* Rewrite test for ctrlc_windows_workaround
* py36 compat
* py36 compat
* py36 compat
* Don't rely on loop internals but add a stopping flag to app.
* App may be restarted.
* py36 compat
* Linter
* Add a constant for OS checking.
Co-authored-by: L. Kärkkäinen <tronic@users.noreply.github.com>
* Begin swap of requests-async for httpx
* Finalize httpx adoption and resolve tests
Resolve linting and formatting
* Remove documentation references to requests-async in favor of httpx