25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

180 lines
6.7 KiB

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