Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

METADATA 7.4KB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. Metadata-Version: 2.1
  2. Name: websocket-client
  3. Version: 1.6.1
  4. Summary: WebSocket client for Python with low level API options
  5. Home-page: https://github.com/websocket-client/websocket-client.git
  6. Download-URL: https://github.com/websocket-client/websocket-client/releases
  7. Author: liris
  8. Author-email: liris.pp@gmail.com
  9. License: Apache-2.0
  10. Project-URL: Documentation, https://websocket-client.readthedocs.io/
  11. Project-URL: Source, https://github.com/websocket-client/websocket-client/
  12. Keywords: websockets client
  13. Classifier: Development Status :: 4 - Beta
  14. Classifier: License :: OSI Approved :: Apache Software License
  15. Classifier: Programming Language :: Python :: 3
  16. Classifier: Programming Language :: Python :: 3.7
  17. Classifier: Programming Language :: Python :: 3.8
  18. Classifier: Programming Language :: Python :: 3.9
  19. Classifier: Programming Language :: Python :: 3.10
  20. Classifier: Programming Language :: Python :: 3.11
  21. Classifier: Operating System :: MacOS :: MacOS X
  22. Classifier: Operating System :: POSIX
  23. Classifier: Operating System :: Microsoft :: Windows
  24. Classifier: Topic :: Internet
  25. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  26. Classifier: Intended Audience :: Developers
  27. Requires-Python: >=3.7
  28. Description-Content-Type: text/markdown
  29. License-File: LICENSE
  30. Provides-Extra: docs
  31. Requires-Dist: Sphinx (>=3.4) ; extra == 'docs'
  32. Requires-Dist: sphinx-rtd-theme (>=0.5) ; extra == 'docs'
  33. Provides-Extra: optional
  34. Requires-Dist: python-socks ; extra == 'optional'
  35. Requires-Dist: wsaccel ; extra == 'optional'
  36. Provides-Extra: test
  37. Requires-Dist: websockets ; extra == 'test'
  38. [![docs](https://readthedocs.org/projects/websocket-client/badge/?style=flat)](https://websocket-client.readthedocs.io/)
  39. [![Build Status](https://github.com/websocket-client/websocket-client/actions/workflows/build.yml/badge.svg)](https://github.com/websocket-client/websocket-client/actions/workflows/build.yml)
  40. [![codecov](https://codecov.io/gh/websocket-client/websocket-client/branch/master/graph/badge.svg?token=pcXhUQwiL3)](https://codecov.io/gh/websocket-client/websocket-client)
  41. [![PyPI Downloads](https://pepy.tech/badge/websocket-client)](https://pepy.tech/project/websocket-client)
  42. [![PyPI version](https://img.shields.io/pypi/v/websocket_client)](https://pypi.org/project/websocket_client/)
  43. # websocket-client
  44. websocket-client is a WebSocket client for Python. It provides access
  45. to low level APIs for WebSockets. websocket-client implements version
  46. [hybi-13](https://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-13)
  47. of the WebSocket protocol. This client does not currently support the
  48. permessage-deflate extension from
  49. [RFC 7692](https://tools.ietf.org/html/rfc7692).
  50. ## Documentation
  51. This project's documentation can be found at
  52. [https://websocket-client.readthedocs.io/](https://websocket-client.readthedocs.io/)
  53. ## Contributing
  54. Please see the [contribution guidelines](https://github.com/websocket-client/websocket-client/blob/master/CONTRIBUTING.md)
  55. ## Installation
  56. You can use either `python3 setup.py install` or `pip3 install websocket-client`
  57. to install. This module is tested on Python 3.7+.
  58. There are several optional dependencies that can be installed to enable
  59. specific websocket-client features.
  60. - To install `python-socks` for proxy usage and `wsaccel` for a minor performance boost, use:
  61. `pip3 install websocket-client[optional]`
  62. - To install `websockets` to run unit tests using the local echo server, use:
  63. `pip3 install websocket-client[test]`
  64. - To install `Sphinx` and `sphinx_rtd_theme` to build project documentation, use:
  65. `pip3 install websocket-client[docs]`
  66. While not a strict dependency, [rel](https://github.com/bubbleboy14/registeredeventlistener)
  67. is useful when using `run_forever` with automatic reconnect. Install rel with `pip3 install rel`.
  68. Footnote: Some shells, such as zsh, require you to escape the `[` and `]` characters with a `\`.
  69. ## Usage Tips
  70. Check out the documentation's FAQ for additional guidelines:
  71. [https://websocket-client.readthedocs.io/en/latest/faq.html](https://websocket-client.readthedocs.io/en/latest/faq.html)
  72. Known issues with this library include lack of WebSocket Compression
  73. support (RFC 7692) and [minimal threading documentation/support](https://websocket-client.readthedocs.io/en/latest/threading.html).
  74. ## Performance
  75. The `send` and `validate_utf8` methods can sometimes be bottleneck.
  76. You can disable UTF8 validation in this library (and receive a
  77. performance enhancement) with the `skip_utf8_validation` parameter.
  78. If you want to get better performance, install wsaccel. While
  79. websocket-client does not depend on wsaccel, it will be used if
  80. available. wsaccel doubles the speed of UTF8 validation and
  81. offers a very minor 10% performance boost when masking the
  82. payload data as part of the `send` process. Numpy used to
  83. be a suggested performance enhancement alternative, but
  84. [issue #687](https://github.com/websocket-client/websocket-client/issues/687)
  85. found it didn't help.
  86. ## Examples
  87. Many more examples are found in the
  88. [examples documentation](https://websocket-client.readthedocs.io/en/latest/examples.html).
  89. ### Long-lived Connection
  90. Most real-world WebSockets situations involve longer-lived connections.
  91. The WebSocketApp `run_forever` loop will automatically try to reconnect
  92. to an open WebSocket connection when a network
  93. connection is lost if it is provided with:
  94. - a `dispatcher` argument (async dispatcher like rel or pyevent)
  95. - a non-zero `reconnect` argument (delay between disconnection and attempted reconnection)
  96. `run_forever` provides a variety of event-based connection controls
  97. using callbacks like `on_message` and `on_error`.
  98. `run_forever` **does not automatically reconnect** if the server
  99. closes the WebSocket gracefully (returning
  100. [a standard websocket close code](https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1)).
  101. [This is the logic](https://github.com/websocket-client/websocket-client/pull/838#issuecomment-1228454826) behind the decision.
  102. Customizing behavior when the server closes
  103. the WebSocket should be handled in the `on_close` callback.
  104. This example uses [rel](https://github.com/bubbleboy14/registeredeventlistener)
  105. for the dispatcher to provide automatic reconnection.
  106. ```python
  107. import websocket
  108. import _thread
  109. import time
  110. import rel
  111. def on_message(ws, message):
  112. print(message)
  113. def on_error(ws, error):
  114. print(error)
  115. def on_close(ws, close_status_code, close_msg):
  116. print("### closed ###")
  117. def on_open(ws):
  118. print("Opened connection")
  119. if __name__ == "__main__":
  120. websocket.enableTrace(True)
  121. ws = websocket.WebSocketApp("wss://api.gemini.com/v1/marketdata/BTCUSD",
  122. on_open=on_open,
  123. on_message=on_message,
  124. on_error=on_error,
  125. on_close=on_close)
  126. ws.run_forever(dispatcher=rel, reconnect=5) # Set dispatcher to automatic reconnection, 5 second reconnect delay if connection closed unexpectedly
  127. rel.signal(2, rel.abort) # Keyboard Interrupt
  128. rel.dispatch()
  129. ```
  130. ### Short-lived Connection
  131. This is if you want to communicate a short message and disconnect
  132. immediately when done. For example, if you want to confirm that a WebSocket
  133. server is running and responds properly to a specific request.
  134. ```python
  135. from websocket import create_connection
  136. ws = create_connection("ws://echo.websocket.events/")
  137. print(ws.recv())
  138. print("Sending 'Hello, World'...")
  139. ws.send("Hello, World")
  140. print("Sent")
  141. print("Receiving...")
  142. result = ws.recv()
  143. print("Received '%s'" % result)
  144. ws.close()
  145. ```