Skip to content

Commit

Permalink
Fix lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
taras committed Sep 12, 2024
1 parent 16e75a9 commit 72aac67
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
16 changes: 8 additions & 8 deletions examples/echo_client_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import subprocess

from logging import getLogger
from ssl import SSLContext
from typing import List, Dict, Tuple
from typing import List, Dict

import numpy as np
import websockets
Expand Down Expand Up @@ -35,6 +34,7 @@ def create_client_ssl_context():
async def picows_main(endpoint: str, msg: bytes, duration: int, ssl_context):
cl_type = "plain" if ssl_context is None else "ssl"
print(f"Run picows python {cl_type} client")

class PicowsClientListener(WSListener):
def __init__(self):
super().__init__()
Expand Down Expand Up @@ -69,7 +69,7 @@ async def websockets_main(endpoint: str, msg: bytes, duration: int, ssl_context)
start_time = time()
cnt = 0
while True:
reply = await websocket.recv()
await websocket.recv()
cnt += 1
if time() - start_time >= duration:
break
Expand Down Expand Up @@ -163,12 +163,12 @@ async def aiohttp_main(url: str, data: bytes, duration: int, ssl_context):
try:
from examples.echo_client_cython import picows_main_cython
if not args.picows_ssl_only:
print(f"Run picows cython plain client")
print("Run picows cython plain client")
rps = asyncio.run(picows_main_cython(plain_url, msg, duration, None))
RPS["plain"].append(rps)

if not args.picows_plain_only:
print(f"Run picows cython ssl client")
print("Run picows cython ssl client")
rps = asyncio.run(picows_main_cython(ssl_url, msg, duration, ssl_context))
RPS["ssl"].append(rps)

Expand All @@ -177,7 +177,7 @@ async def aiohttp_main(url: str, data: bytes, duration: int, ssl_context):
pass

if not args.picows_plain_only and not args.picows_ssl_only and args.boost_client is not None:
print(f"Run boost.beast plain client")
print("Run boost.beast plain client")
pr = subprocess.run([args.boost_client, b"0",
args.host.encode(),
args.plain_port.encode(),
Expand All @@ -186,15 +186,15 @@ async def aiohttp_main(url: str, data: bytes, duration: int, ssl_context):
_, rps = pr.stdout.split(b":", 2)
RPS["plain"].append(int(rps.decode()))

print(f"Run boost.beast ssl client")
print("Run boost.beast ssl client")
pr = subprocess.run([args.boost_client, b"1",
args.host.encode(),
args.ssl_port.encode(),
args.msg_size, args.duration],
shell=False, check=True, capture_output=True)
name, rps = pr.stdout.split(b":", 2)
RPS["ssl"].append(int(rps.decode()))
NAMES.append(f"c++ boost.beast")
NAMES.append("c++ boost.beast")

if args.picows_plain_only or args.picows_ssl_only:
exit()
Expand Down
1 change: 0 additions & 1 deletion examples/echo_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import pathlib
import ssl
from logging import getLogger, INFO, basicConfig
from ssl import SSLContext

from picows import WSFrame, WSTransport, ws_create_server, WSListener, WSMsgType, WSUpgradeRequest

Expand Down
2 changes: 1 addition & 1 deletion examples/readme_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ async def main(url):

if __name__ == '__main__':
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
asyncio.run(main("ws://127.0.0.1:9001"))
asyncio.run(main("ws://127.0.0.1:9001"))
2 changes: 0 additions & 2 deletions tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import picows
import pytest
import async_timeout
import os


TIMEOUT = 0.5
Expand Down Expand Up @@ -291,7 +290,6 @@ class ServerClientListener(picows.WSListener):
def on_ws_connected(self, transport: picows.WSTransport):
raise RuntimeError("exception from on_ws_connected")


server = await picows.ws_create_server(lambda _: ServerClientListener(),
"127.0.0.1", 0)
async with ServerAsyncContext(server):
Expand Down

0 comments on commit 72aac67

Please sign in to comment.