#can you submit a pull request?
1 messages · Page 1 of 1 (latest)
def handle_channel_info(self, client, userdata, message):
self.loop.call_soon_threadsafe(self.async_handle_channel_info,client,userdata,message)
def async_handle_channel_info(self, client, userdata, message):
response = json.loads(message.payload)
channel_info = response.get("response",{})
session_id = response.get("sessionID","unknown")
self.channels = {channel.get("channelNumber",0):NavilinkChannel(channel.get("channelNumber",0),channel.get("channel",{}),self) for channel in channel_info.get("channelInfo",{}).get("channelList",[])}
if response_event := self.response_events.get(session_id,None):
response_event.set()
def handle_channel_status(self, client, userdata, message):
self.loop.call_soon_threadsafe(self.async_handle_channel_status,client,userdata,message)
def async_handle_channel_status(self, client, userdata, message):
response = json.loads(message.payload)
channel_status = response.get("response",{}).get("channelStatus",{})
session_id = response.get("sessionID","unknown")
if channel := self.channels.get(channel_status.get("channelNumber",0),None):
channel.update_channel_status(channel_status.get("channel",{}))
if response_event := self.response_events.get(session_id,None):
response_event.set()
I'd write the code something like that
Not planning on opening a PR though as its not something I can test. I don't fully understand the integration, and its something the maintainer would need to process and integrate.
The .set() calls there are definately not safe though since they call .set_result() under the hood which will do call_soon (not call_soon_threadsafe)
My recommendation would be open an issue on that repo with the code above and point them to this discord discussion