This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git


The following commit(s) were added to refs/heads/main by this push:
     new 1b0d01982 PROTON-2706: Allow the user to explicitly set 
Container.container_id to None
1b0d01982 is described below

commit 1b0d01982b29e8345daa02bcd5e7af3c64f287c0
Author: Andrew Stitcher <astitc...@apache.org>
AuthorDate: Wed Apr 19 16:57:27 2023 -0400

    PROTON-2706: Allow the user to explicitly set Container.container_id to None
    
    In this case we should generate a random container name for each connect
    from the container.
---
 python/proton/_reactor.py            | 2 +-
 python/tests/proton_tests/reactor.py | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/python/proton/_reactor.py b/python/proton/_reactor.py
index 69a28138c..5564263d3 100644
--- a/python/proton/_reactor.py
+++ b/python/proton/_reactor.py
@@ -1362,7 +1362,7 @@ class Container(Reactor):
             **kwargs
     ) -> Connection:
         conn = self.connection(handler)
-        conn.container = kwargs.get('container_id', self.container_id)
+        conn.container = kwargs.get('container_id', self.container_id or 
str(_generate_uuid()))
         conn.offered_capabilities = kwargs.get('offered_capabilities')
         conn.desired_capabilities = kwargs.get('desired_capabilities')
         conn.properties = kwargs.get('properties')
diff --git a/python/tests/proton_tests/reactor.py 
b/python/tests/proton_tests/reactor.py
index 1107c4143..28caad651 100644
--- a/python/tests/proton_tests/reactor.py
+++ b/python/tests/proton_tests/reactor.py
@@ -511,6 +511,15 @@ class ContainerTest(Test):
         container.run()
         assert server_handler.peer_container_id == 'container456', 
server_handler.peer_container_id
 
+    def test_container_id_3(self):
+        server_handler = ContainerTest._ServerHandler("localhost")
+        container = Container(server_handler)
+        container.container_id = None
+        conn = container.connect(url="localhost:%s" % (server_handler.port),
+                                 handler=ContainerTest._ClientHandler())
+        container.run()
+        assert server_handler.peer_container_id != '', 
server_handler.peer_container_id
+
     def test_virtual_host(self):
         ensureCanTestExtendedSASL()
         server_handler = ContainerTest._ServerHandler("localhost")


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org

Reply via email to