Skip to content

fix: fix p2p connection to use loop call soon threadsafe#407

Merged
mark-neuracore merged 1 commit intodevelopfrom
fix/fix-p2p-connection-to-use-loop-call-soon-threadsafe
Feb 19, 2026
Merged

fix: fix p2p connection to use loop call soon threadsafe#407
mark-neuracore merged 1 commit intodevelopfrom
fix/fix-p2p-connection-to-use-loop-call-soon-threadsafe

Conversation

@mark-neuracore
Copy link
Contributor

Bugfixes

  • p2p gives "no current event loop in this thread" error
⚠️  Failed to call log_parallel_gripper_target_open_amounts to Neuracore: There is no current event loop in thread 'Thread-2 (joint_state_thread)'.
/home/mark/neuracore_ws/example_elephant_robotics/examples/2_collect_teleop_data_with_neuracore.py:102: RuntimeWarning: coroutine 'RTCSctpTransport._data_channel_flush' was never awaited
print(f"\n⚠️  Failed to call {name} to Neuracore: {e}")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
  • This was due to adding event sources needed to use an event loop, which if called from a different thread (that never initialised an event loop) causes this error. This method uses self.loop instead.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 16, 2026

PR source branch is valid

  • Source: fix/fix-p2p-connection-to-use-loop-call-soon-threadsafe
  • Target: develop

@mark-neuracore mark-neuracore added the version:patch non-breaking bug fixes; no input/output changes (except defaults) label Feb 16, 2026
@mark-neuracore mark-neuracore changed the base branch from main to develop February 16, 2026 15:45
@mark-neuracore mark-neuracore changed the base branch from develop to fix/use-shared-async-event-loop February 16, 2026 15:45
@mark-neuracore mark-neuracore changed the title Fix/fix p2p connection to use loop call soon threadsafe fix: fix p2p connection to use loop call soon threadsafe Feb 16, 2026
@mark-neuracore mark-neuracore force-pushed the fix/fix-p2p-connection-to-use-loop-call-soon-threadsafe branch from 24f9d1e to c5b72a2 Compare February 16, 2026 17:14
@mark-neuracore mark-neuracore changed the base branch from fix/use-shared-async-event-loop to develop February 16, 2026 17:14
@mark-neuracore mark-neuracore force-pushed the fix/fix-p2p-connection-to-use-loop-call-soon-threadsafe branch from c5b72a2 to 850a986 Compare February 17, 2026 11:21
Copy link
Contributor

@CougarTasker CougarTasker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: This solution feels like we are just smothing over the issue. Mixing blocking and non-blocking code like this raises alarm-bells for me.

Suggestion: I suspect there is a more elegant approach to provide the event loop context to the required code.

Question: Does this issue apprear for other senesor types that are not parallel grippers, If not why?

@mark-neuracore mark-neuracore force-pushed the fix/fix-p2p-connection-to-use-loop-call-soon-threadsafe branch 2 times, most recently from cfd10cc to 13735c8 Compare February 17, 2026 18:20
@mark-neuracore
Copy link
Contributor Author

@CougarTasker found this way to avoid modifying aiortc.

still happy to raise a pr with our previous solution to pass the self.loop in aiortc

@mark-neuracore mark-neuracore force-pushed the fix/fix-p2p-connection-to-use-loop-call-soon-threadsafe branch 5 times, most recently from 2de4733 to 506fc37 Compare February 19, 2026 11:31
Copy link
Contributor

@CougarTasker CougarTasker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice tests!

)
future.result(timeout=5.0)

async def _add_event_source_impl(self, source: JSONSource) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: These callback functions can look a little neater if inline

@mark-neuracore mark-neuracore force-pushed the fix/fix-p2p-connection-to-use-loop-call-soon-threadsafe branch from 506fc37 to 7b027ee Compare February 19, 2026 14:25
@mark-neuracore mark-neuracore merged commit 8c1a815 into develop Feb 19, 2026
8 checks passed
@mark-neuracore mark-neuracore deleted the fix/fix-p2p-connection-to-use-loop-call-soon-threadsafe branch February 19, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

version:patch non-breaking bug fixes; no input/output changes (except defaults)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments