mirror of
https://github.com/pablorevilla-meshtastic/meshview.git
synced 2026-08-06 08:53:20 +02:00
Basic documentation of the notify feature. This is still reporting the "Missing return Statement on request handler"
This commit is contained in:
+8
-2
@@ -37,13 +37,11 @@ def remove_event(node_event):
|
||||
print("removing event")
|
||||
waiting_node_ids_events[node_event.node_id].remove(node_event)
|
||||
|
||||
|
||||
def notify_packet(node_id, packet):
|
||||
for event in waiting_node_ids_events[node_id]:
|
||||
event.packets.append(packet)
|
||||
event.set()
|
||||
|
||||
|
||||
def notify_uplinked(node_id, packet):
|
||||
for event in waiting_node_ids_events[node_id]:
|
||||
event.uplinked.append(packet)
|
||||
@@ -52,8 +50,16 @@ def notify_uplinked(node_id, packet):
|
||||
|
||||
@contextlib.contextmanager
|
||||
def subscribe(node_id):
|
||||
"""
|
||||
Context manager for subscribing to events for a node_id.
|
||||
Automatically manages event creation and cleanup.
|
||||
"""
|
||||
event = create_event(node_id)
|
||||
try:
|
||||
yield event
|
||||
print("adding event...")
|
||||
except Exception as e:
|
||||
print(f"Error during subscription for node_id={node_id}: {e}")
|
||||
raise
|
||||
finally:
|
||||
remove_event(event)
|
||||
|
||||
Reference in New Issue
Block a user