Skip to content
Discussion options

You must be logged in to vote

I edited your message slightly to enable syntax highlighting.

When opening a port using the with statement, you have to enumerate the messages from the port.
No need for receive() nor poll():

with mido.open_input() as port:
    for message in port:
        # do something with each "message"

Tangentially, know that receive() is blocking by default (waiting for a message).
You can use receive(block=False) or poll() but you may run into the opposite issue if the instrument takes some time to respond.

The best way to avoid these blocking issues altogether and my personal favorite is to pass a callback function to the port instead.
The function will then be called asynchronously upon incoming …

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by rdoursenaud
Comment options

You must be logged in to vote
3 replies
@rdoursenaud
Comment options

@rdoursenaud
Comment options

@DanGylez
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants