Repository navigation
Add a Python multithread (INTERTHREAD) example - #50
Merged
Merged
Conversation
The Python counterpart of the Julia multithread example: a publisher thread produces NavigationReports on the interthread layer, a watcher thread consumes them and forwards each one to interprocess, and the application prints an alert when the vehicle is deep. The example is built around the three consequences of the layer being implemented in Python: the application is a SingleThreadApplication because the C++ side never sees these threads, the interthread groups are plain strings rather than declarations in interface.yml, and the depth alert is a dataclass that never becomes protobuf. The watcher publishes to interprocess from its own thread, which is handed to the application behind the scenes. Requires the Python interthread support in GobySoft/goby3#415, so it builds today but does not run until that is in the continuous packages. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D97Q5zTpLKwkDTYQzPRiCX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Python counterpart of the Julia multithread example added in #47, in
src/interprocess/zeromq/python/basic_multithread.A publisher thread produces
NavigationReports on the interthread layer, a watcher thread consumes them and forwards each one to interprocess, and the application prints an alert when the vehicle is deep.What it shows
The example is built around the three consequences of the layer being implemented in Python rather than through the C++
InterThreadTransporter:SingleThreadApplication. The C++ side never sees these threads, soMultiThreadApplicationis not needed.multithread.pyrather than declarations ininterface.yml— nothing is generated for the layer, so there is nothing to declare. Only the interprocess publication is in the interface file.dataclassand never becomes protobuf.The watcher publishes to interprocess from its own thread, which is handed to the application behind the scenes, the way a C++ thread's
InterProcessForwarderhands its traffic to the portal. Julia raises anAssertionErrorin that position.interface.ymldeclares the publication ongroups::navwithprotobuf::NavigationReport, the same group and message the C++ examples use, sogoby3_example_basic_interprocess_subscriberin the launch file receives what the watcher forwards.Files
multithread.py,interface.yml,multithread_config.proto,CMakeLists.txtlaunch/interprocess/zeromq/python_multithread.launchsrc/interprocess/zeromq/python/CMakeLists.txtTesting
Ran the example's own classes against stand-in bindings, with
src/messages/nav.protocompiled byprotoc:Both hops carry, the dataclass crosses interthread intact, the -300.0 report correctly does not trip the 300 m threshold, and the application is serviced at 10 Hz without having asked for a loop frequency. The generated module was also checked against the example's imports: it exports
SingleThreadApplication,Threadandgroups.nav, withinterthread()coming fromgoby.Threadrather than from any declaration.Merge order
This needs the Python interthread support in GobySoft/goby3#415. CI here installs
libgoby3-dev/python3-goby3from the continuous packages, which track goby33.0, and builds without running, so this example builds today but does not run until #415 is merged and those packages rebuild. Merge #415 first.🤖 Generated with Claude Code
https://claude.ai/code/session_01D97Q5zTpLKwkDTYQzPRiCX
Generated by Claude Code