Skip to content

Commit eeb5c55

Browse files
committed
Improve docstrings
1 parent b4ae2b7 commit eeb5c55

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

unpythonic/net/msg.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ def decodemsg(buf, source):
8989
of two messages, it will contain the start of the next message,
9090
which is needed for the next run of `decodemsg`.
9191
92+
For an OOP API to `decodemsg` that manages the `ReceiveBuffer`
93+
internally, see `MessageDecoder`.
94+
9295
source: *Message source*: an iterator that yields chunks of data from some
9396
data stream, and raises `StopIteration` when it reaches EOF.
9497
@@ -130,12 +133,14 @@ def decodemsg(buf, source):
130133
131134
buf = ReceiveBuffer()
132135
source = socketsource(sock)
133-
while not terminated:
136+
while True:
134137
data = decodemsg(buf, source) # get the next message
138+
if not data:
139+
break
135140
...
136141
137-
See also `MessageDecoder` for an OOP API, abstracting away the
138-
`ReceiveBuffer`.
142+
See also `MessageDecoder` for an OOP API in which you don't need to care
143+
about the `ReceiveBuffer`.
139144
"""
140145
source = iter(source)
141146

@@ -264,8 +269,10 @@ class MessageDecoder:
264269
# ...open a TCP socket `sock`...
265270
266271
decoder = MessageDecoder(socketsource(sock))
267-
while not terminated:
272+
while True:
268273
data = decoder.decode() # get the next message
274+
if not data:
275+
break
269276
...
270277
271278
A `ReceiveBuffer` is created internally. If you need to access it (e.g.

0 commit comments

Comments
 (0)