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.
🎉 New feature
Closes #531
Summary
Currently the transport architecture restricts a single
NodeShared
object per process. This is achieved by mapping process id to an instance ofNodeShared
class. However, recently, I had some use cases where I need to isolate several nodes, each with their ownDISCOVERY
variables, such asGZ_DISCOVERY_MSG_PORT
,GZ_DISCOVERY_SRV_PORT
,GZ_DISCOVERY_MULTICAST_IP
,GZ_PARTITION
, in a single process. Due to the limitation mentioned above, this is not possible becauseDISCOVERY
is tied to a process, and when instantiating multiple Nodes per process, all of them obtain the same NodeShared object and hence the sameDISCOVERY
variables.To overcome this, one approach is to also use a
thread_id
to create a unique identifier that maps to aNodeShared
object. This pins down the uniqueness ofNodeShared
object to each thread, not the process. The proposed modification performs this by the following logic:This allows specification of
DISCOVERY
variables per thread.Test it
For testing the proposed improvement, I added two test files
nodeDiscoveryPubs_TEST.py
andnodeDiscoverySubs_TEST.py
underpython/test
directory. Each one shall be run in a separate terminal before and after modifications to see the results. Before modification, it is not possible to receive the messages by the subscribers due to the issue I mentioned. However, after my modification, the subscribers are able to receive their messages.Finally, the proposed modification can also be verified from
CLI
. When the publisher TEST is run, it prints the command that can be run in a shell to set theDISCOVERY
vars to listen to their publications.NOTE: The following tests failed:
NodeTest.ScopeProcess
andNodeTest.ScopeProcessRemap
, because the test runs by creating publisher and subscriber in different threads. Due to the proposed modification, these 2 tests will fail.Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸