Applying black formatting
- Fixing flake8 configuration to agree with black - Adding black validation check to github actions
This commit is contained in:
@@ -17,18 +17,20 @@ capnp.create_event_loop(threaded=True)
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(usage='Connects to the Example thread server \
|
||||
at the given address and does some RPCs')
|
||||
parser = argparse.ArgumentParser(
|
||||
usage="Connects to the Example thread server \
|
||||
at the given address and does some RPCs"
|
||||
)
|
||||
parser.add_argument("host", help="HOST:PORT")
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
class StatusSubscriber(thread_capnp.Example.StatusSubscriber.Server):
|
||||
'''An implementation of the StatusSubscriber interface'''
|
||||
"""An implementation of the StatusSubscriber interface"""
|
||||
|
||||
def status(self, value, **kwargs):
|
||||
print('status: {}'.format(time.time()))
|
||||
print("status: {}".format(time.time()))
|
||||
|
||||
|
||||
async def myreader(client, reader):
|
||||
@@ -71,28 +73,26 @@ async def background(cap):
|
||||
|
||||
|
||||
async def main(host):
|
||||
host = host.split(':')
|
||||
host = host.split(":")
|
||||
addr = host[0]
|
||||
port = host[1]
|
||||
|
||||
# Setup SSL context
|
||||
ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, cafile=os.path.join(this_dir, 'selfsigned.cert'))
|
||||
ctx = ssl.create_default_context(
|
||||
ssl.Purpose.SERVER_AUTH, cafile=os.path.join(this_dir, "selfsigned.cert")
|
||||
)
|
||||
|
||||
# Handle both IPv4 and IPv6 cases
|
||||
try:
|
||||
print("Try IPv4")
|
||||
reader, writer = await asyncio.open_connection(
|
||||
addr, port,
|
||||
ssl=ctx,
|
||||
family=socket.AF_INET
|
||||
addr, port, ssl=ctx, family=socket.AF_INET
|
||||
)
|
||||
except OSError:
|
||||
print("Try IPv6")
|
||||
try:
|
||||
reader, writer = await asyncio.open_connection(
|
||||
addr, port,
|
||||
ssl=ctx,
|
||||
family=socket.AF_INET6
|
||||
addr, port, ssl=ctx, family=socket.AF_INET6
|
||||
)
|
||||
except OSError:
|
||||
return False
|
||||
@@ -115,20 +115,21 @@ async def main(host):
|
||||
overalltasks.append(asyncio.gather(*tasks, return_exceptions=True))
|
||||
|
||||
# Run blocking tasks
|
||||
print('main: {}'.format(time.time()))
|
||||
print("main: {}".format(time.time()))
|
||||
await cap.longRunning().a_wait()
|
||||
print('main: {}'.format(time.time()))
|
||||
print("main: {}".format(time.time()))
|
||||
await cap.longRunning().a_wait()
|
||||
print('main: {}'.format(time.time()))
|
||||
print("main: {}".format(time.time()))
|
||||
await cap.longRunning().a_wait()
|
||||
print('main: {}'.format(time.time()))
|
||||
print("main: {}".format(time.time()))
|
||||
|
||||
for task in overalltasks:
|
||||
task.cancel()
|
||||
|
||||
return True
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Using asyncio.run hits an asyncio ssl bug
|
||||
# https://bugs.python.org/issue36709
|
||||
# asyncio.run(main(parse_args().host), loop=loop, debug=True)
|
||||
|
||||
Reference in New Issue
Block a user