sanic/examples
Ashley Sommer 6ffc4d9756
New websockets (#2158)
* 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>
2021-09-29 13:09:23 +03:00
..
request_stream Pausable response streams (#1179) 2018-08-18 18:12:13 -07:00
static Static dir 2075 (#2076) 2021-03-21 15:03:54 +02:00
add_task_sanic.py feat(exapmles): add add_task_sanic.py 2017-08-20 11:11:14 +08:00
amending_request_object.py Add example of amending request object 2019-01-02 14:52:25 +08:00
authorized_sanic.py Reduce nesting for the sample authentication decorator (#1715) 2019-11-14 14:57:41 -06:00
blueprint_middlware_execution_order.py Reverse named_response_middlware execution order, to match normal response middleware execution order. 2020-05-14 09:54:47 +10:00
blueprints.py Streaming Server (#1876) 2021-01-11 00:45:36 +02:00
delayed_response.py Socket binding implemented properly for IPv6 and UNIX sockets. (#1641) 2020-06-29 08:55:32 +03:00
docker-compose.yml Added examples and form processing 2016-10-09 15:28:31 -07:00
Dockerfile Fix some examples and docs (#2052) 2021-03-10 11:19:38 +02:00
exception_monitoring.py reverted back to default 0.0.0.0 host 2017-06-01 14:01:13 -07:00
http_redirect.py Prepare for 21.3 release (#2057) 2021-03-21 10:43:18 +02:00
limit_concurrency.py Clean up of examples. Removes non-core examples, optimizes and restyles remaining to strictly follow PEP 8 styling guidelines. Non-Core examples will be moved to Wiki. 2017-06-01 11:53:05 -07:00
log_request_id.py Fix some examples and docs (#2052) 2021-03-10 11:19:38 +02:00
logdna_example.py add monitoring examples and documents 2018-12-28 10:22:28 +05:30
modify_header_example.py Clean up of examples. Removes non-core examples, optimizes and restyles remaining to strictly follow PEP 8 styling guidelines. Non-Core examples will be moved to Wiki. 2017-06-01 11:53:05 -07:00
override_logging.py Fix some examples and docs (#2052) 2021-03-10 11:19:38 +02:00
pytest_xdist.py Fix some examples and docs (#2052) 2021-03-10 11:19:38 +02:00
raygun_example.py add monitoring examples and documents 2018-12-28 10:22:28 +05:30
redirect_example.py Clean up of examples. Removes non-core examples, optimizes and restyles remaining to strictly follow PEP 8 styling guidelines. Non-Core examples will be moved to Wiki. 2017-06-01 11:53:05 -07:00
request_timeout.py Clean up of examples. Removes non-core examples, optimizes and restyles remaining to strictly follow PEP 8 styling guidelines. Non-Core examples will be moved to Wiki. 2017-06-01 11:53:05 -07:00
rollbar_example.py add monitoring examples and documents 2018-12-28 10:22:28 +05:30
run_asgi.py Streaming Server (#1876) 2021-01-11 00:45:36 +02:00
run_async_advanced.py Signals Integration (#2160) 2021-08-05 22:55:42 +03:00
run_async.py Fix #1551 missing parameter in create_server 2019-04-15 22:18:35 +02:00
sentry_example.py add monitoring examples and documents 2018-12-28 10:22:28 +05:30
simple_async_view.py fix one example and add one example (#1257) 2018-07-11 01:42:34 -07:00
simple_server.py Updated examples for 0.5.0 2017-04-11 20:34:55 +00:00
static_assets.py Static dir 2075 (#2076) 2021-03-21 15:03:54 +02:00
teapot.py add status codes and teapot example 2017-09-13 14:08:29 +02:00
try_everything.py rename function to something else 2018-03-29 15:57:10 -07:00
unix_socket.py Clean up of examples. Removes non-core examples, optimizes and restyles remaining to strictly follow PEP 8 styling guidelines. Non-Core examples will be moved to Wiki. 2017-06-01 11:53:05 -07:00
url_for_example.py Clean up of examples. Removes non-core examples, optimizes and restyles remaining to strictly follow PEP 8 styling guidelines. Non-Core examples will be moved to Wiki. 2017-06-01 11:53:05 -07:00
versioned_blueprint_group.py GIT-2045: enable versioning and strict slash on BlueprintGroup (#2047) 2021-03-07 14:54:45 +02:00
vhosts.py Fix some examples and docs (#2052) 2021-03-10 11:19:38 +02:00
websocket.html websocket support, using websockets package 2017-02-27 22:35:28 -08:00
websocket.py New websockets (#2158) 2021-09-29 13:09:23 +03:00