METADATA 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. Metadata-Version: 2.4
  2. Name: websockets
  3. Version: 17.0.1
  4. Summary: An implementation of the WebSocket Protocol (RFC 6455 & 7692)
  5. Author-email: Aymeric Augustin <aymeric.augustin@m4x.org>
  6. License-Expression: BSD-3-Clause
  7. Project-URL: Homepage, https://github.com/python-websockets/websockets
  8. Project-URL: Changelog, https://websockets.readthedocs.io/en/stable/project/changelog.html
  9. Project-URL: Documentation, https://websockets.readthedocs.io/
  10. Project-URL: Funding, https://tidelift.com/subscription/pkg/pypi-websockets?utm_source=pypi-websockets&utm_medium=referral&utm_campaign=readme
  11. Project-URL: Tracker, https://github.com/python-websockets/websockets/issues
  12. Keywords: WebSocket
  13. Classifier: Development Status :: 5 - Production/Stable
  14. Classifier: Environment :: Web Environment
  15. Classifier: Intended Audience :: Developers
  16. Classifier: Operating System :: OS Independent
  17. Classifier: Programming Language :: Python
  18. Classifier: Programming Language :: Python :: 3
  19. Classifier: Programming Language :: Python :: 3.11
  20. Classifier: Programming Language :: Python :: 3.12
  21. Classifier: Programming Language :: Python :: 3.13
  22. Classifier: Programming Language :: Python :: 3.14
  23. Classifier: Programming Language :: Python :: 3.15
  24. Requires-Python: >=3.11
  25. Description-Content-Type: text/x-rst
  26. License-File: LICENSE
  27. Dynamic: description
  28. Dynamic: description-content-type
  29. Dynamic: license-file
  30. .. image:: logo/horizontal.svg
  31. :width: 480px
  32. :alt: websockets
  33. |licence| |version| |pyversions|
  34. .. |licence| image:: https://img.shields.io/pypi/l/websockets.svg
  35. :target: https://pypi.python.org/pypi/websockets
  36. .. |version| image:: https://img.shields.io/pypi/v/websockets.svg
  37. :target: https://pypi.python.org/pypi/websockets
  38. .. |pyversions| image:: https://img.shields.io/pypi/pyversions/websockets.svg
  39. :target: https://pypi.python.org/pypi/websockets
  40. What is ``websockets``?
  41. -----------------------
  42. websockets is a library for building WebSocket_ servers and clients in Python
  43. with a focus on correctness, simplicity, robustness, and performance.
  44. .. _WebSocket: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API
  45. Built on top of ``asyncio``, Python's standard asynchronous I/O framework, the
  46. default implementation provides an elegant coroutine-based API.
  47. Implementations on top of ``threading`` and ``trio`` are also provided, as well
  48. as a Sans-I/O layer for integration in third-party projects.
  49. `Documentation is available on Read the Docs. <https://websockets.readthedocs.io/>`_
  50. .. copy-pasted because GitHub doesn't support the include directive
  51. Here's an echo server with the ``asyncio`` API:
  52. .. code:: python
  53. #!/usr/bin/env python
  54. import asyncio
  55. from websockets.asyncio.server import serve
  56. async def echo(websocket):
  57. async for message in websocket:
  58. await websocket.send(message)
  59. async def main():
  60. server = await serve(echo, "localhost", 8765)
  61. await server.serve_forever()
  62. asyncio.run(main())
  63. Here's how a client sends and receives messages with the ``threading`` API:
  64. .. code:: python
  65. #!/usr/bin/env python
  66. from websockets.sync.client import connect
  67. def hello():
  68. with connect("ws://localhost:8765") as websocket:
  69. websocket.send("Hello world!")
  70. message = websocket.recv()
  71. print(f"Received: {message}")
  72. hello()
  73. Does that look good?
  74. `Get started with the tutorial! <https://websockets.readthedocs.io/en/stable/intro/index.html>`_
  75. Why should I use ``websockets``?
  76. --------------------------------
  77. The development of ``websockets`` is shaped by four principles:
  78. 1. **Correctness**: ``websockets`` is heavily tested for compliance with
  79. :rfc:`6455`. Continuous integration fails under 100% branch coverage.
  80. 2. **Simplicity**: all you need to understand is ``msg = await ws.recv()`` and
  81. ``await ws.send(msg)``. ``websockets`` takes care of managing connections
  82. so you can focus on your application.
  83. 3. **Robustness**: ``websockets`` is built for production. For example, it was
  84. the only library to `handle backpressure correctly`_ before the issue
  85. became widely known in the Python community.
  86. 4. **Performance**: memory usage is optimized and configurable. A C extension
  87. accelerates expensive operations. It's pre-compiled for Linux, macOS and
  88. Windows and packaged in the wheel format for each system and Python version.
  89. Documentation is a first class concern in the project. Head over to `Read the
  90. Docs`_ and see for yourself.
  91. .. _Read the Docs: https://websockets.readthedocs.io/
  92. .. _handle backpressure correctly: https://vorpus.org/blog/some-thoughts-on-asynchronous-api-design-in-a-post-asyncawait-world/#websocket-servers
  93. Why shouldn't I use ``websockets``?
  94. -----------------------------------
  95. * If you prefer callbacks over coroutines: ``websockets`` was created to
  96. provide the best coroutine-based API to manage WebSocket connections in
  97. Python. Pick another library for a callback-based API.
  98. * If you're looking for a mixed HTTP / WebSocket library: ``websockets`` aims
  99. at being an excellent implementation of :rfc:`6455`: The WebSocket Protocol
  100. and :rfc:`7692`: Compression Extensions for WebSocket. Its support for HTTP
  101. is minimal — just enough for an HTTP health check.
  102. If you want to do both in the same server, look at HTTP + WebSocket servers
  103. that build on top of ``websockets`` to support WebSocket connections, like
  104. uvicorn_ or Sanic_.
  105. .. _uvicorn: https://www.uvicorn.org/
  106. .. _Sanic: https://sanic.dev/en/
  107. What else?
  108. ----------
  109. Bug reports, patches and suggestions are welcome!
  110. To report a security vulnerability, please use the `Tidelift security
  111. contact`_. Tidelift will coordinate the fix and disclosure.
  112. .. _Tidelift security contact: https://tidelift.com/security
  113. For anything else, please open an issue_ or send a `pull request`_.
  114. .. _issue: https://github.com/python-websockets/websockets/issues/new
  115. .. _pull request: https://github.com/python-websockets/websockets/compare/
  116. Participants must uphold the `Contributor Covenant code of conduct`_.
  117. .. _Contributor Covenant code of conduct: https://github.com/python-websockets/websockets/blob/main/CODE_OF_CONDUCT.md
  118. ``websockets`` is released under the `BSD license`_.
  119. .. _BSD license: https://github.com/python-websockets/websockets/blob/main/LICENSE