diff options
author | Guido van Rossum <guido@python.org> | 2013-10-18 08:33:33 -0700 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2013-10-18 08:33:33 -0700 |
commit | 32bd7922d5354b28ccee2d9c9033805399fc5559 (patch) | |
tree | 20947894771f57fdc4b0f20ed58fe04b8ffdf8d5 | |
parent | 342e12a9f88c1f8fb50b8591f4590c8b0b167d83 (diff) | |
download | trollius-32bd7922d5354b28ccee2d9c9033805399fc5559.tar.gz |
Report total bytes written.
-rw-r--r-- | examples/source.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/source.py b/examples/source.py index c484224..1515dd1 100644 --- a/examples/source.py +++ b/examples/source.py @@ -32,6 +32,8 @@ def dprint(*args): class Client(Protocol): + total = 0 + def connection_made(self, tr): dprint('connecting to', tr.get_extra_info('peername')) dprint('my socket is', tr.get_extra_info('sockname')) @@ -50,7 +52,8 @@ class Client(Protocol): if self.lost: dprint('lost already') return - dprint('writing', len(data), 'bytes') + self.total += len(data) + dprint('writing', len(data), 'bytes; total', self.total) self.tr.write(data) self.loop.call_soon(self.write_some_data, data) @@ -65,8 +68,7 @@ def start(loop, host, port): tr, pr = yield from loop.create_connection(Client, host, port) dprint('tr =', tr) dprint('pr =', pr) - res = yield from pr.waiter - return res + yield from pr.waiter def main(): |