Skip to content

Commit 81d1819

Browse files
authored
Merge pull request #46 from tarasko/feature/45_clarify_docs
Feature/45 clarify send behavior in docs
2 parents e765f66 + 5b5f146 commit 81d1819

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

docs/source/reference.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,20 @@ Classes
136136
.. autoclass:: WSTransport
137137
:members:
138138

139+
.. note::
140+
141+
All `send` methods never block. The data is buffered and arranged to be sent out asynchronously in case
142+
if it can't be sent immediately.
143+
This behaviour is derived from the underlying `asyncio.WriteTransport.write`
144+
139145
.. py:attribute:: underlying_transport
140146
:type: asyncio.Transport
141147

142148
Underlying TCP or SSL transport. Can be used to set buffer limits, check connection state, etc.
143149

144150
.. note::
145151

146-
Please don't use it to send data. Use only WSTransport.send_* methods to send frames.
152+
Please don't use it to send data. Use only `WSTransport.send` methods to send frames.
147153

148154
.. py:attribute:: request
149155
:type: WSUpgradeRequest

examples/echo_client_benchmark.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def on_ws_connected(self, transport: WSTransport):
5656
self._transport.send(WSMsgType.BINARY, msg)
5757

5858
def on_ws_frame(self, transport: WSTransport, frame: WSFrame):
59-
global result
6059
self._cnt += 1
6160

6261
if time() - self._start_time >= duration:
@@ -130,7 +129,6 @@ async def aiohttp_main(url: str, data: bytes, duration: int, ssl_context):
130129

131130

132131
def run_for_websockets_library(plain_url, ssl_url, ssl_context, msg, duration):
133-
global NAMES, RPS
134132
_, rps = asyncio.run(websockets_main(plain_url, msg, duration, None))
135133
RPS["plain"].append(rps)
136134
name, rps = asyncio.run(websockets_main(ssl_url, msg, duration, ssl_context))
@@ -139,7 +137,6 @@ def run_for_websockets_library(plain_url, ssl_url, ssl_context, msg, duration):
139137

140138

141139
def run_for_aiohttp_library(plain_url, ssl_url, ssl_context, msg, duration):
142-
global NAMES, RPS
143140
_, rps = asyncio.run(aiohttp_main(plain_url, msg, duration, None))
144141
RPS["plain"].append(rps)
145142
name, rps = asyncio.run(aiohttp_main(ssl_url, msg, duration, ssl_context))
@@ -148,7 +145,6 @@ def run_for_aiohttp_library(plain_url, ssl_url, ssl_context, msg, duration):
148145

149146

150147
def run_picows_client(plain_url, ssl_url, ssl_context, msg, duration):
151-
global NAMES, RPS
152148
_, rps = asyncio.run(picows_main(plain_url, msg, duration, None))
153149
RPS["plain"].append(rps)
154150
name, rps = asyncio.run(picows_main(ssl_url, msg, duration, ssl_context))
@@ -157,22 +153,18 @@ def run_picows_client(plain_url, ssl_url, ssl_context, msg, duration):
157153

158154

159155
def run_picows_cython_plain_client(plain_url, ssl_url, ssl_context, msg, duration):
160-
global NAMES, RPS
161156
print("Run picows cython plain client")
162157
rps = asyncio.run(picows_main_cython(plain_url, msg, duration, None))
163158
RPS["plain"].append(rps)
164159

165160

166161
def run_picows_cython_ssl_client(plain_url, ssl_url, ssl_context, msg, duration):
167-
global NAMES, RPS
168162
print("Run picows cython ssl client")
169163
rps = asyncio.run(picows_main_cython(ssl_url, msg, duration, ssl_context))
170164
RPS["ssl"].append(rps)
171165

172166

173167
def run_boost_beast_client(args):
174-
global NAMES, RPS
175-
176168
print("Run boost.beast plain client")
177169
pr = subprocess.run([args.boost_client, b"0",
178170
args.host.encode(),

picows/picows.pyx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,8 +1605,7 @@ async def ws_connect(ws_listener_factory: Callable[[], WSListener],
16051605
:param enable_auto_pong:
16061606
If enabled then picows will automatically reply to incoming PING frames.
16071607
:param max_frame_size:
1608-
* Maximum allowed frame size. Disconnect will be initiated if client receives
1609-
a frame that is bigger than max size.
1608+
* Maximum allowed frame size. Disconnect will be initiated if client receives a frame that is bigger than max size.
16101609
:param extra_headers:
16111610
Arbitrary HTTP headers to add to the handshake request.
16121611
:return: :any:`WSTransport` object and a user handler returned by `ws_listener_factory()`
@@ -1722,8 +1721,7 @@ async def ws_create_server(ws_listener_factory: WSServerListenerFactory,
17221721
:param enable_auto_pong:
17231722
If enabled then picows will automatically reply to incoming PING frames.
17241723
:param max_frame_size:
1725-
* Maximum allowed frame size. Disconnect will be initiated if server side receives
1726-
frame that is bigger than max size.
1724+
* Maximum allowed frame size. Disconnect will be initiated if server side receives frame that is bigger than max size.
17271725
:return: `asyncio.Server <https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.Server>`_ object
17281726
"""
17291727

0 commit comments

Comments
 (0)