diff --git a/buildutils/build.py b/buildutils/build.py index c85a5cc..efbe739 100644 --- a/buildutils/build.py +++ b/buildutils/build.py @@ -4,7 +4,6 @@ import subprocess import os import shutil import sys -import tempfile def build_libcapnp(bundle_dir, build_dir, verbose=False): ''' diff --git a/examples/async_calculator_client.py b/examples/async_calculator_client.py index de9c823..90f29f9 100755 --- a/examples/async_calculator_client.py +++ b/examples/async_calculator_client.py @@ -26,16 +26,16 @@ class PowerFunction(calculator_capnp.Calculator.Function.Server): async def myreader(client, reader): - while True: - data = await reader.read(4096) - client.write(data) + while True: + data = await reader.read(4096) + client.write(data) async def mywriter(client, writer): - while True: - data = await client.read(4096) - writer.write(data.tobytes()) - await writer.drain() + while True: + data = await client.read(4096) + writer.write(data.tobytes()) + await writer.drain() def parse_args(): @@ -52,16 +52,16 @@ async def main(host): port = host[1] # Handle both IPv4 and IPv6 cases try: - print("Try IPv4") - reader, writer = await asyncio.open_connection( - addr, port, - ) - except: - print("Try IPv6") - reader, writer = await asyncio.open_connection( - addr, port, - family=socket.AF_INET6 - ) + print("Try IPv4") + reader, writer = await asyncio.open_connection( + addr, port, + ) + except Exception: + print("Try IPv6") + reader, writer = await asyncio.open_connection( + addr, port, + family=socket.AF_INET6 + ) # Start TwoPartyClient using TwoWayPipe (takes no arguments in this mode) client = capnp.TwoPartyClient() diff --git a/examples/async_calculator_server.py b/examples/async_calculator_server.py index 1316571..8324902 100755 --- a/examples/async_calculator_server.py +++ b/examples/async_calculator_server.py @@ -4,23 +4,22 @@ from __future__ import print_function import argparse import asyncio import socket -import random import capnp import calculator_capnp async def myreader(client, reader): - while True: - data = await reader.read(4096) - await client.write(data) + while True: + data = await reader.read(4096) + await client.write(data) async def mywriter(client, writer): - while True: - data = await client.read(4096) - writer.write(data.tobytes()) - await writer.drain() + while True: + data = await client.read(4096) + writer.write(data.tobytes()) + await writer.drain() def read_value(value): @@ -167,7 +166,7 @@ async def main(): myserver, addr, port, ) - except: + except Exception: print("Try IPv6") server = await asyncio.start_server( myserver, diff --git a/examples/async_reconnecting_ssl_client.py b/examples/async_reconnecting_ssl_client.py index ca93836..a4967bf 100755 --- a/examples/async_reconnecting_ssl_client.py +++ b/examples/async_reconnecting_ssl_client.py @@ -6,10 +6,10 @@ import asyncio import argparse import os import time -import capnp import socket import ssl -import time + +import capnp import thread_capnp @@ -51,7 +51,6 @@ async def mywriter(client, writer): # to try again data = await asyncio.wait_for(client.read(4096), timeout=1.0) writer.write(data.tobytes()) - #await writer.drain() except asyncio.TimeoutError: continue diff --git a/test/test_examples.py b/test/test_examples.py index dfbff5e..1477f59 100644 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -1,8 +1,6 @@ -import gc import os import socket import subprocess -import sys # add examples dir to sys.path import time examples_dir = os.path.join(os.path.dirname(__file__), '..', 'examples')