Skip to content

Commit

Permalink
Made Sequencer an iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagocoutinho committed Nov 15, 2023
1 parent 21c84d0 commit 87d1985
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions linuxpy/midi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
PortCapability,
Sequencer,
async_event_stream,
event_stream,
iter_read_clients,
iter_read_ports,
)
Expand All @@ -26,7 +25,7 @@ def listen(seq, args):
for addr in args.addr:
port = seq.create_port(f"listen on {addr}")
port.connect_from(*addr)
for event in event_stream(seq):
for event in seq:
print(event)


Expand Down
4 changes: 4 additions & 0 deletions linuxpy/midi/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ def __init__(self, name: str = "linuxpy client", **kwargs):
self.subscriptions = set()
super().__init__(SEQUENCER_PATH, **kwargs)

def __iter__(self):
while True:
yield from self.read()

def _on_open(self):
self.client_id = read_client_id(self)
client_info = read_client_info(self, self.client_id)
Expand Down

0 comments on commit 87d1985

Please sign in to comment.