Skip to content

Commit

Permalink
Fully remove loop argument (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickw444 committed Jul 16, 2022
1 parent 1657637 commit 839d3e1
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/listening_for_events.py
Expand Up @@ -5,7 +5,7 @@
loop = asyncio.get_event_loop()
host = '127.0.0.1'
port = 65432
client = Client(host=host, port=port, loop=loop)
client = Client(host=host, port=port)


@client.on_zone_change
Expand Down
2 changes: 1 addition & 1 deletion examples/sending_commands.py
Expand Up @@ -5,7 +5,7 @@
loop = asyncio.get_event_loop()
host = '127.0.0.1'
port = 65432
client = Client(host=host, port=port, loop=loop)
client = Client(host=host, port=port)

# Send arming command via library abstraction
loop.run_until_complete(client.arm_away('1234'))
Expand Down
2 changes: 1 addition & 1 deletion nessclient/cli/events.py
Expand Up @@ -13,7 +13,7 @@
@click.option('--infer-arming-state/--no-infer-arming-state')
def events(host: str, port: int, update_interval: int, infer_arming_state: bool) -> None:
loop = asyncio.get_event_loop()
client = Client(host=host, port=port, loop=loop,
client = Client(host=host, port=port,
infer_arming_state=infer_arming_state,
update_interval=update_interval)

Expand Down
2 changes: 1 addition & 1 deletion nessclient/cli/send_command.py
Expand Up @@ -11,7 +11,7 @@
@click.argument('command')
def send_command(host: str, port: int, command: str) -> None:
loop = asyncio.get_event_loop()
client = Client(host=host, port=port, loop=loop)
client = Client(host=host, port=port)

loop.run_until_complete(client.send_command(command))
loop.run_until_complete(client.close())
Expand Down
4 changes: 1 addition & 3 deletions nessclient/client.py
Expand Up @@ -26,15 +26,13 @@ def __init__(self,
connection: Optional[Connection] = None,
host: Optional[str] = None,
port: Optional[int] = None,
loop: Optional[asyncio.AbstractEventLoop] = None,
update_interval: int = 60,
infer_arming_state: bool = False,
alarm: Optional[Alarm] = None):
if connection is None:
assert host is not None
assert port is not None
assert loop is not None
connection = IP232Connection(host=host, port=port, loop=loop)
connection = IP232Connection(host=host, port=port)

if alarm is None:
alarm = Alarm(infer_arming_state=infer_arming_state)
Expand Down
6 changes: 2 additions & 4 deletions nessclient/connection.py
Expand Up @@ -34,14 +34,12 @@ def connected(self) -> bool:
class IP232Connection(Connection):
"""A connection via IP232 with a Ness D8X/D16X server"""

def __init__(self, host: str, port: int,
loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()):
def __init__(self, host: str, port: int):
super().__init__()

self._write_lock = asyncio.Lock(loop=loop)
self._write_lock = asyncio.Lock()
self._host = host
self._port = port
self._loop = loop
self._reader: Optional[asyncio.StreamReader] = None
self._writer: Optional[asyncio.StreamWriter] = None

Expand Down

0 comments on commit 839d3e1

Please sign in to comment.