Changeset - 63f82ec045bf
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 20 months ago 2023-05-31 22:25:26
drewp@bigasterisk.com
don't stop midi input on a handler error
1 file changed with 5 insertions and 1 deletions:
0 comments (0 inline, 0 general)
light9/midifade/midifade.py
Show inline comments
 
#!bin/python
 
"""
 
Read midi events, write fade levels to graph
 
"""
 
import asyncio
 
import logging
 
import traceback
 

	
 
import mido
 
from rdfdb.syncedgraph.syncedgraph import SyncedGraph
 
from rdflib import URIRef
 

	
 
from light9 import networking
 
@@ -54,14 +55,17 @@ async def main():
 

	
 
    async def reader():
 
        while True:
 
            recents = [await msgs.get()]
 
            while not msgs.empty():
 
                recents.append(msgs.get_nowait())
 

	
 
            try:
 
            onMessage(graph, ctx, recents[-1])
 
            except Exception as e:
 
                traceback.print_exc()
 
                log.warning("error in onMessage- continuing anyway")
 
            await asyncio.sleep(1 / MAX_SEND_RATE)
 

	
 
    asyncio.create_task(reader())
 

	
 
    port = mido.open_input('Keystation:Keystation MIDI 1 20:0', callback=onMessageMidoThread)
 

	
0 comments (0 inline, 0 general)