Fix thread-unsafe sequence counter causing heapq comparison crash
The _send_seq += 1 approach had a race condition: two threads calling
send() simultaneously could load the same counter value, producing two
queue items with identical (priority, seq) tuples. heapq then compares
the third element (protobuf message), which crashes with TypeError.

Replace with itertools.count() whose next() is GIL-atomic in CPython —
each call is a single C-level operation that cannot be interrupted mid-
increment. Also fix the legacy fallback path in LiveNodeRecord.send_message
and remove the duplicate 'import queue' in node_registry.py.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b392266 commit d759d53749402d907d1878b084ed0c6b5d98621d
@axieyangb axieyangb authored 14 days ago
Showing 2 changed files
View
ai-hub/app/core/services/node_registry.py
View
mesh-sdk/mesh_core/transport/grpc.py