Flask-SocketIO 5.6.0__tar.gz → 5.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. flask_socketio-5.7.0/PKG-INFO +98 -0
  2. flask_socketio-5.7.0/README.md +60 -0
  3. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/docs/conf.py +2 -8
  4. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/docs/getting_started.rst +11 -0
  5. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/docs/intro.rst +17 -19
  6. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/pyproject.toml +16 -4
  7. flask_socketio-5.7.0/src/Flask_SocketIO.egg-info/PKG-INFO +98 -0
  8. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/src/Flask_SocketIO.egg-info/SOURCES.txt +0 -0
  9. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/src/Flask_SocketIO.egg-info/dependency_links.txt +0 -0
  10. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/src/Flask_SocketIO.egg-info/not-zip-safe +0 -0
  11. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/src/Flask_SocketIO.egg-info/requires.txt +9 -1
  12. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/src/Flask_SocketIO.egg-info/top_level.txt +0 -0
  13. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/src/flask_socketio/__init__.py +52 -28
  14. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/src/flask_socketio/namespace.py +13 -7
  15. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/test_socketio.py +172 -181
  16. flask_socketio-5.7.0/tox.ini +44 -0
  17. flask_socketio-5.6.0/PKG-INFO +0 -82
  18. flask_socketio-5.6.0/README.md +0 -56
  19. flask_socketio-5.6.0/src/Flask_SocketIO.egg-info/PKG-INFO +0 -82
  20. flask_socketio-5.6.0/tox.ini +0 -36
  21. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/LICENSE +0 -0
  22. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/MANIFEST.in +0 -0
  23. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/docs/Makefile +0 -0
  24. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/docs/_static/README.md +0 -0
  25. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/docs/_static/custom.css +0 -0
  26. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/docs/api.rst +0 -0
  27. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/docs/deployment.rst +0 -0
  28. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/docs/implementation_notes.rst +0 -0
  29. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/docs/index.rst +0 -0
  30. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/docs/make.bat +0 -0
  31. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/docs/upgrading.rst +0 -0
  32. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/setup.cfg +0 -0
  33. {flask_socketio-5.6.0 → flask_socketio-5.7.0}/src/flask_socketio/test_client.py +0 -0
@@ -0,0 +1,98 @@
1
+ Metadata-Version: 2.4
2
+ Name: Flask-SocketIO
3
+ Version: 5.7.0
4
+ Summary: Socket.IO integration for Flask applications
5
+ Author-email: Miguel Grinberg <miguel.grinberg@gmail.com>
6
+ Project-URL: Homepage, https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio
7
+ Project-URL: Documentation, https://flask-socketio.readthedocs.io/
8
+ Project-URL: Source Code, https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio
9
+ Project-URL: Issue Tracker, https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio/issues
10
+ Project-URL: Changelog, https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio/src/branch/main/CHANGES.md
11
+ Project-URL: Funding, https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio#sponsor-this-project
12
+ Classifier: Environment :: Web Environment
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Requires-Python: >=3.8
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: blinker
21
+ Requires-Dist: click
22
+ Requires-Dist: flask
23
+ Requires-Dist: Flask>=2.1.0
24
+ Requires-Dist: jinja2
25
+ Requires-Dist: python-socketio>=5.12.0
26
+ Requires-Dist: werkzeug
27
+ Provides-Extra: docs
28
+ Requires-Dist: sphinx; extra == "docs"
29
+ Requires-Dist: furo; extra == "docs"
30
+ Provides-Extra: dev
31
+ Requires-Dist: flask-login; extra == "dev"
32
+ Requires-Dist: flask-session; extra == "dev"
33
+ Requires-Dist: pytest; extra == "dev"
34
+ Requires-Dist: pytest-cov; extra == "dev"
35
+ Requires-Dist: redis; extra == "dev"
36
+ Requires-Dist: tox; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ Flask-SocketIO
40
+ ==============
41
+
42
+ [![tests](https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio/badges/workflows/tests.yml/badge.svg)](https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio/actions)
43
+
44
+ Socket.IO integration for Flask applications.
45
+
46
+ Installation
47
+ ------------
48
+
49
+ You can install this package as usual with pip:
50
+
51
+ pip install flask-socketio
52
+
53
+ Example
54
+ -------
55
+
56
+ ```py
57
+ from flask import Flask, render_template
58
+ from flask_socketio import SocketIO, emit
59
+
60
+ app = Flask(__name__)
61
+ app.config['SECRET_KEY'] = 'secret!'
62
+ socketio = SocketIO(app)
63
+
64
+ @app.route('/')
65
+ def index():
66
+ return render_template('index.html')
67
+
68
+ @socketio.event
69
+ def my_event(message):
70
+ emit('my response', {'data': 'got it!'})
71
+
72
+ if __name__ == '__main__':
73
+ socketio.run(app)
74
+ ```
75
+
76
+ Resources
77
+ ---------
78
+
79
+ - [Tutorial](http://blog.miguelgrinberg.com/post/easy-websockets-with-flask-and-gevent)
80
+ - [git](https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio)
81
+ - [Change Log](https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio/src/branch/main/CHANGES.md)
82
+ - [Documentation](https://flask-socketio.readthedocs.io/)
83
+ - [PyPI](https://pypi.python.org/pypi/flask-socketio)
84
+ - [Contributor's guide](CONTRIBUTING.md)
85
+ - [Security policy](SECURITY.md)
86
+
87
+ Sponsor this project
88
+ --------------------
89
+
90
+ This project relies on contributions from its users. If you benefit from it please consider making a single or ongoing monetary contribution in one of the following platforms:
91
+
92
+ - [Github Sponsors](https://github.com/sponsors/miguelgrinberg)
93
+ - [Patreon](https://patreon.com/miguelgrinberg)
94
+ - [Buy me a Coffee](https://buymeacoffee.com/miguelgrinberg)
95
+ - [thanks.dev](https://thanks.dev/u/gh/miguelgrinberg)
96
+ - [PayPal](https://paypal.me/miguelgrinberg)
97
+
98
+ Thank you!
@@ -0,0 +1,60 @@
1
+ Flask-SocketIO
2
+ ==============
3
+
4
+ [![tests](https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio/badges/workflows/tests.yml/badge.svg)](https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio/actions)
5
+
6
+ Socket.IO integration for Flask applications.
7
+
8
+ Installation
9
+ ------------
10
+
11
+ You can install this package as usual with pip:
12
+
13
+ pip install flask-socketio
14
+
15
+ Example
16
+ -------
17
+
18
+ ```py
19
+ from flask import Flask, render_template
20
+ from flask_socketio import SocketIO, emit
21
+
22
+ app = Flask(__name__)
23
+ app.config['SECRET_KEY'] = 'secret!'
24
+ socketio = SocketIO(app)
25
+
26
+ @app.route('/')
27
+ def index():
28
+ return render_template('index.html')
29
+
30
+ @socketio.event
31
+ def my_event(message):
32
+ emit('my response', {'data': 'got it!'})
33
+
34
+ if __name__ == '__main__':
35
+ socketio.run(app)
36
+ ```
37
+
38
+ Resources
39
+ ---------
40
+
41
+ - [Tutorial](http://blog.miguelgrinberg.com/post/easy-websockets-with-flask-and-gevent)
42
+ - [git](https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio)
43
+ - [Change Log](https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio/src/branch/main/CHANGES.md)
44
+ - [Documentation](https://flask-socketio.readthedocs.io/)
45
+ - [PyPI](https://pypi.python.org/pypi/flask-socketio)
46
+ - [Contributor's guide](CONTRIBUTING.md)
47
+ - [Security policy](SECURITY.md)
48
+
49
+ Sponsor this project
50
+ --------------------
51
+
52
+ This project relies on contributions from its users. If you benefit from it please consider making a single or ongoing monetary contribution in one of the following platforms:
53
+
54
+ - [Github Sponsors](https://github.com/sponsors/miguelgrinberg)
55
+ - [Patreon](https://patreon.com/miguelgrinberg)
56
+ - [Buy me a Coffee](https://buymeacoffee.com/miguelgrinberg)
57
+ - [thanks.dev](https://thanks.dev/u/gh/miguelgrinberg)
58
+ - [PayPal](https://paypal.me/miguelgrinberg)
59
+
60
+ Thank you!
@@ -77,20 +77,14 @@ pygments_style = None
77
77
  # The theme to use for HTML and HTML Help pages. See the documentation for
78
78
  # a list of builtin themes.
79
79
  #
80
- html_theme = 'alabaster'
80
+ html_theme = 'furo'
81
+ html_title = 'Flask-SocketIO'
81
82
 
82
83
  # Theme options are theme-specific and customize the look and feel of a theme
83
84
  # further. For a list of options available for each theme, see the
84
85
  # documentation.
85
86
  #
86
87
  html_theme_options = {
87
- 'github_user': 'miguelgrinberg',
88
- 'github_repo': 'flask-socketio',
89
- 'github_banner': True,
90
- 'github_button': True,
91
- 'github_type': 'star',
92
- 'fixed_sidebar': True,
93
-
94
88
  }
95
89
 
96
90
  # Add any paths that contain custom static files (such as style sheets) here,
@@ -384,6 +384,17 @@ debugging outside the event handler::
384
384
  print(request.event["message"]) # "my error event"
385
385
  print(request.event["args"]) # (data,)
386
386
 
387
+ When using class-based namespaces, an error handler for the namespace can be
388
+ added as a method named ``error()``::
389
+
390
+ class MyCustomNamespace(Namespace):
391
+ # ...
392
+
393
+ def error(self, error):
394
+ print(f'Error {error} on event {request.event}'
395
+
396
+ socketio.on_namespace(MyCustomNamespace('/test'))
397
+
387
398
  Debugging and Troubleshooting
388
399
  -----------------------------
389
400
 
@@ -11,30 +11,28 @@ You can install this package in the usual way using ``pip``::
11
11
  Requirements
12
12
  ------------
13
13
 
14
- Flask-SocketIO is compatible with Python 3.6+. The asynchronous services that
14
+ Flask-SocketIO is compatible with Python 3.8+. The asynchronous services that
15
15
  this package relies on can be selected among three choices:
16
16
 
17
- - `eventlet <http://eventlet.net/>`_ is the best performant option, with
18
- support for long-polling and WebSocket transports.
17
+ - The ``threading`` package from the Python standard library is the easier and
18
+ most compatible solution, with full support of long-polling and WebSocket
19
+ transports. The Flask development web server can be used during development,
20
+ and Gunicorn in multi-threaded mode can be used in production deployments.
19
21
  - `gevent <http://www.gevent.org/>`_ is supported in a number of different
20
- configurations. The long-polling transport is fully supported with the
21
- gevent package, but unlike eventlet, gevent does not have native WebSocket
22
- support. To add support for WebSocket there are currently two options.
23
- Installing the `gevent-websocket <https://pypi.python.org/pypi/gevent-websocket/>`_
24
- package adds WebSocket support to gevent or one can use the `uWSGI
25
- <https://uwsgi-docs.readthedocs.io/en/latest/>`_ web server, which
26
- comes with WebSocket functionality. The use of gevent is also a performant
27
- option, but slightly lower than eventlet.
28
- - The Flask development server based on Werkzeug can be used as well, with the
29
- caveat that this web server is intended only for development use, so it
30
- should only be used to simplify the development workflow and not for
31
- production.
22
+ configurations, also with support for the long-polling and WebSocket
23
+ transports. The Flask development web server, gevent's own web server,
24
+ Gunicorn (with the gevent worker) and uWSGI (in gevent mode) are all
25
+ supported when using ``gevent``.
26
+ - `eventlet <http://eventlet.net/>`_ used to be a good option with support for
27
+ long-polling and WebSocket transports, but it is not actively maintained
28
+ anymore, so ``gevent`` should be preferred. The Flask development web server,
29
+ eventlet's own web server and Gunicorn (with the eventlet worker) are all
30
+ supported when using ``eventlet``.
32
31
 
33
32
  The extension automatically detects which asynchronous framework to use based
34
- on what is installed. Preference is given to eventlet, followed by gevent.
35
- For WebSocket support in gevent, uWSGI is preferred, followed by
36
- gevent-websocket. If neither eventlet nor gevent are installed, then the Flask
37
- development server is used.
33
+ on what is installed. Preference is given to eventlet, followed by gevent. If
34
+ neither eventlet nor gevent are installed, Python's ``threading`` package is
35
+ used.
38
36
 
39
37
  If using multiple processes, a message queue service must be configured to
40
38
  allow the servers to coordinate operations such as broadcasting. The supported
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "Flask-SocketIO"
3
- version = "5.6.0"
3
+ version = "5.7.0"
4
4
  authors = [
5
5
  { name = "Miguel Grinberg", email = "miguel.grinberg@gmail.com" },
6
6
  ]
@@ -14,8 +14,13 @@ classifiers = [
14
14
  ]
15
15
  requires-python = ">=3.8"
16
16
  dependencies = [
17
+ "blinker",
18
+ "click",
19
+ "flask",
17
20
  "Flask >= 2.1.0",
21
+ "jinja2",
18
22
  "python-socketio >= 5.12.0",
23
+ "werkzeug",
19
24
  ]
20
25
 
21
26
  [project.readme]
@@ -23,18 +28,25 @@ file = "README.md"
23
28
  content-type = "text/markdown"
24
29
 
25
30
  [project.urls]
26
- Homepage = "https://github.com/miguelgrinberg/flask-socketio"
27
- "Bug Tracker" = "https://github.com/miguelgrinberg/flask-socketio/issues"
31
+ Homepage = "https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio"
32
+ Documentation = "https://flask-socketio.readthedocs.io/"
33
+ "Source Code" = "https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio"
34
+ "Issue Tracker" = "https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio/issues"
35
+ Changelog = "https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio/src/branch/main/CHANGES.md"
36
+ Funding = "https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio#sponsor-this-project"
28
37
 
29
38
  [project.optional-dependencies]
30
39
  docs = [
31
40
  "sphinx",
41
+ "furo",
32
42
  ]
33
43
  dev = [
34
- "tox",
44
+ "flask-login",
45
+ "flask-session",
35
46
  "pytest",
36
47
  "pytest-cov",
37
48
  "redis",
49
+ "tox",
38
50
  ]
39
51
 
40
52
  [tool.setuptools]
@@ -0,0 +1,98 @@
1
+ Metadata-Version: 2.4
2
+ Name: Flask-SocketIO
3
+ Version: 5.7.0
4
+ Summary: Socket.IO integration for Flask applications
5
+ Author-email: Miguel Grinberg <miguel.grinberg@gmail.com>
6
+ Project-URL: Homepage, https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio
7
+ Project-URL: Documentation, https://flask-socketio.readthedocs.io/
8
+ Project-URL: Source Code, https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio
9
+ Project-URL: Issue Tracker, https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio/issues
10
+ Project-URL: Changelog, https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio/src/branch/main/CHANGES.md
11
+ Project-URL: Funding, https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio#sponsor-this-project
12
+ Classifier: Environment :: Web Environment
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Requires-Python: >=3.8
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: blinker
21
+ Requires-Dist: click
22
+ Requires-Dist: flask
23
+ Requires-Dist: Flask>=2.1.0
24
+ Requires-Dist: jinja2
25
+ Requires-Dist: python-socketio>=5.12.0
26
+ Requires-Dist: werkzeug
27
+ Provides-Extra: docs
28
+ Requires-Dist: sphinx; extra == "docs"
29
+ Requires-Dist: furo; extra == "docs"
30
+ Provides-Extra: dev
31
+ Requires-Dist: flask-login; extra == "dev"
32
+ Requires-Dist: flask-session; extra == "dev"
33
+ Requires-Dist: pytest; extra == "dev"
34
+ Requires-Dist: pytest-cov; extra == "dev"
35
+ Requires-Dist: redis; extra == "dev"
36
+ Requires-Dist: tox; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ Flask-SocketIO
40
+ ==============
41
+
42
+ [![tests](https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio/badges/workflows/tests.yml/badge.svg)](https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio/actions)
43
+
44
+ Socket.IO integration for Flask applications.
45
+
46
+ Installation
47
+ ------------
48
+
49
+ You can install this package as usual with pip:
50
+
51
+ pip install flask-socketio
52
+
53
+ Example
54
+ -------
55
+
56
+ ```py
57
+ from flask import Flask, render_template
58
+ from flask_socketio import SocketIO, emit
59
+
60
+ app = Flask(__name__)
61
+ app.config['SECRET_KEY'] = 'secret!'
62
+ socketio = SocketIO(app)
63
+
64
+ @app.route('/')
65
+ def index():
66
+ return render_template('index.html')
67
+
68
+ @socketio.event
69
+ def my_event(message):
70
+ emit('my response', {'data': 'got it!'})
71
+
72
+ if __name__ == '__main__':
73
+ socketio.run(app)
74
+ ```
75
+
76
+ Resources
77
+ ---------
78
+
79
+ - [Tutorial](http://blog.miguelgrinberg.com/post/easy-websockets-with-flask-and-gevent)
80
+ - [git](https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio)
81
+ - [Change Log](https://code.miguelgrinberg.com/miguelgrinberg/flask-socketio/src/branch/main/CHANGES.md)
82
+ - [Documentation](https://flask-socketio.readthedocs.io/)
83
+ - [PyPI](https://pypi.python.org/pypi/flask-socketio)
84
+ - [Contributor's guide](CONTRIBUTING.md)
85
+ - [Security policy](SECURITY.md)
86
+
87
+ Sponsor this project
88
+ --------------------
89
+
90
+ This project relies on contributions from its users. If you benefit from it please consider making a single or ongoing monetary contribution in one of the following platforms:
91
+
92
+ - [Github Sponsors](https://github.com/sponsors/miguelgrinberg)
93
+ - [Patreon](https://patreon.com/miguelgrinberg)
94
+ - [Buy me a Coffee](https://buymeacoffee.com/miguelgrinberg)
95
+ - [thanks.dev](https://thanks.dev/u/gh/miguelgrinberg)
96
+ - [PayPal](https://paypal.me/miguelgrinberg)
97
+
98
+ Thank you!
@@ -1,11 +1,19 @@
1
+ blinker
2
+ click
3
+ flask
1
4
  Flask>=2.1.0
5
+ jinja2
2
6
  python-socketio>=5.12.0
7
+ werkzeug
3
8
 
4
9
  [dev]
5
- tox
10
+ flask-login
11
+ flask-session
6
12
  pytest
7
13
  pytest-cov
8
14
  redis
15
+ tox
9
16
 
10
17
  [docs]
11
18
  sphinx
19
+ furo
@@ -84,18 +84,23 @@ class SocketIO:
84
84
  :param client_manager: The client manager instance that will manage the
85
85
  client list. When this is omitted, the client list
86
86
  is stored in an in-memory structure, so the use of
87
- multiple connected servers is not possible. In most
88
- cases, this argument does not need to be set
89
- explicitly.
87
+ multiple connected servers is not possible.
90
88
  :param logger: To enable logging set to ``True`` or pass a logger object to
91
89
  use. To disable logging set to ``False``. The default is
92
- ``False``. Note that fatal errors will be logged even when
90
+ ``False``. Note that fatal errors are logged even when
93
91
  ``logger`` is ``False``.
94
- :param json: An alternative json module to use for encoding and decoding
92
+ :param serializer: The serialization method to use when transmitting
93
+ packets. Valid values are ``'default'``, ``'pickle'``,
94
+ ``'msgpack'`` and ``'cbor'``. Alternatively, a subclass
95
+ of the :class:`Packet` class with custom implementations
96
+ of the ``encode()`` and ``decode()`` methods can be
97
+ provided. Client and server must use compatible
98
+ serializers.
99
+ :param json: An alternative JSON module to use for encoding and decoding
95
100
  packets. Custom json modules must have ``dumps`` and ``loads``
96
101
  functions that are compatible with the standard library
97
- versions. To use the same json encoder and decoder as a Flask
98
- application, use ``flask.json``.
102
+ versions. This is a process-wide setting, all instantiated
103
+ servers and clients must use the same JSON module.
99
104
  :param async_handlers: If set to ``True``, event handlers for a client are
100
105
  executed in separate threads. To run handlers for a
101
106
  client synchronously, set to ``False``. The default
@@ -110,17 +115,22 @@ class SocketIO:
110
115
  connect handler and your client is confused when it
111
116
  receives events before the connection acceptance.
112
117
  In any other case use the default of ``False``.
118
+ :param namespaces: a list of namespaces that are accepted, in addition to
119
+ any namespaces for which handlers have been defined. The
120
+ default is `['/']`, which always accepts connections to
121
+ the default namespace. Set to `'*'` to accept all
122
+ namespaces.
113
123
 
114
124
  The Engine.IO server configuration supports the following settings:
115
125
 
116
126
  :param async_mode: The asynchronous model to use. See the Deployment
117
127
  section in the documentation for a description of the
118
- available options. Valid async modes are ``threading``,
119
- ``eventlet``, ``gevent`` and ``gevent_uwsgi``. If this
120
- argument is not given, ``eventlet`` is tried first, then
121
- ``gevent_uwsgi``, then ``gevent``, and finally
122
- ``threading``. The first async mode that has all its
123
- dependencies installed is then one that is chosen.
128
+ available options. Valid async modes are "threading",
129
+ "eventlet", "gevent" and "gevent_uwsgi". If this
130
+ argument is not given, "eventlet" is tried first, then
131
+ "gevent_uwsgi", then "gevent", and finally "threading".
132
+ The first async mode that has all its dependencies
133
+ installed is the one that is chosen.
124
134
  :param ping_interval: The interval in seconds at which the server pings
125
135
  the client. The default is 25 seconds. For advanced
126
136
  control, a two element tuple can be given, where
@@ -128,10 +138,12 @@ class SocketIO:
128
138
  is a grace period added by the server.
129
139
  :param ping_timeout: The time in seconds that the client waits for the
130
140
  server to respond before disconnecting. The default
131
- is 5 seconds.
132
- :param max_http_buffer_size: The maximum size of a message when using the
133
- polling transport. The default is 1,000,000
134
- bytes.
141
+ is 20 seconds.
142
+ :param max_http_buffer_size: The maximum size that is accepted for incoming
143
+ messages. The default is 1,000,000 bytes. In
144
+ spite of its name, the value set in this
145
+ argument is enforced for HTTP long-polling and
146
+ WebSocket connections.
135
147
  :param allow_upgrades: Whether to allow transport upgrades or not. The
136
148
  default is ``True``.
137
149
  :param http_compression: Whether to compress packages when using the
@@ -140,7 +152,7 @@ class SocketIO:
140
152
  is greater than this value. The default is
141
153
  1024 bytes.
142
154
  :param cookie: If set to a string, it is the name of the HTTP cookie the
143
- server sends back to the client containing the client
155
+ server sends back tot he client containing the client
144
156
  session id. If set to a dictionary, the ``'name'`` key
145
157
  contains the cookie name and other keys define cookie
146
158
  attributes, where the value of each attribute can be a
@@ -150,15 +162,18 @@ class SocketIO:
150
162
  :param cors_allowed_origins: Origin or list of origins that are allowed to
151
163
  connect to this server. Only the same origin
152
164
  is allowed by default. Set this argument to
153
- ``'*'`` to allow all origins, or to ``[]`` to
154
- disable CORS handling.
165
+ ``'*'`` or ``['*']`` to allow all origins, or
166
+ to ``[]`` to disable CORS handling.
155
167
  :param cors_credentials: Whether credentials (cookies, authentication) are
156
- allowed in requests to this server. The default is
157
- ``True``.
168
+ allowed in requests to this server. The default
169
+ is ``True``.
158
170
  :param monitor_clients: If set to ``True``, a background task will ensure
159
171
  inactive clients are closed. Set to ``False`` to
160
172
  disable the monitoring task (not recommended). The
161
173
  default is ``True``.
174
+ :param transports: The list of allowed transports. Valid transports
175
+ are ``'polling'`` and ``'websocket'``. Defaults to
176
+ ``['polling', 'websocket']``.
162
177
  :param engineio_logger: To enable Engine.IO logging set to ``True`` or pass
163
178
  a logger object to use. To disable logging set to
164
179
  ``False``. The default is ``False``. Note that
@@ -806,13 +821,22 @@ class SocketIO:
806
821
  environ['saved_session'] = _ManagedSession(flask.session)
807
822
  session_obj = environ['saved_session']
808
823
  if hasattr(flask, 'globals') and \
809
- hasattr(flask.globals, 'request_ctx'):
810
- # update session for Flask >= 2.2
811
- ctx = flask.globals.request_ctx._get_current_object()
824
+ hasattr(flask.globals, 'app_ctx'):
825
+ if hasattr(flask.globals.app_ctx, 'session'):
826
+ # get context for flask >= 3.2
827
+ ctx = flask.globals.app_ctx._get_current_object()
828
+ else:
829
+ # get context for Flask >= 2.2, < 3.2
830
+ ctx = flask.globals.request_ctx._get_current_object()
812
831
  else: # pragma: no cover
813
- # update session for Flask < 2.2
832
+ # get context for Flask < 2.2
814
833
  ctx = flask._request_ctx_stack.top
815
- ctx.session = session_obj
834
+ if hasattr(ctx, '_session'):
835
+ # update session for Flask >= 3.1.3
836
+ ctx._session = session_obj
837
+ else:
838
+ # update session for Flask < 3.1.3
839
+ ctx.session = session_obj
816
840
  else:
817
841
  # let Flask handle the user session
818
842
  # for cookie based sessions, this effectively freezes the
@@ -834,7 +858,7 @@ class SocketIO:
834
858
  ret = handler(*args)
835
859
  except ConnectionRefusedError:
836
860
  raise # let this error bubble up to python-socketio
837
- except:
861
+ except Exception:
838
862
  err_handler = self.exception_handlers.get(
839
863
  namespace, self.default_exception_handler)
840
864
  if err_handler is None:
@@ -23,13 +23,19 @@ class Namespace(_Namespace):
23
23
  return
24
24
  handler = getattr(self, handler_name)
25
25
  try:
26
- return self.socketio._handle_event(handler, event, self.namespace,
27
- *args)
28
- except TypeError:
29
- if event == 'disconnect':
30
- # legacy disconnect events do not have the reason argument
31
- return self.socketio._handle_event(
32
- handler, event, self.namespace, *args[:-1])
26
+ try:
27
+ return self.socketio._handle_event(handler, event,
28
+ self.namespace, *args)
29
+ except TypeError:
30
+ if event == 'disconnect':
31
+ # legacy disconnect events do not have the reason argument
32
+ return self.socketio._handle_event(
33
+ handler, event, self.namespace, *args[:-1])
34
+ else:
35
+ raise
36
+ except Exception as exc:
37
+ if hasattr(self, 'error'):
38
+ return self.error(exc)
33
39
  else:
34
40
  raise
35
41