@@ -37,6 +37,7 @@ class Container(Base):
3737
3838 def __init__ (self , * args , ** kwargs ):
3939 Base .__init__ (self , * args , ** kwargs )
40+ self .diag_owner = kwargs .get ("diag_owner" , False )
4041 self .owner = None
4142 self .bases = []
4243
@@ -150,15 +151,61 @@ def on_stop(self):
150151 self .call_all ("on_stop" )
151152
152153 def add_base (self , base ):
154+ """
155+ Adds a base structure to the container, applying the
156+ container's shared poll, logger and thread identity to
157+ the base before appending it to the internal list of
158+ managed bases.
159+
160+ :type base: Base/Agent
161+ :param base: The base structure (server, client or agent)
162+ to be added to the container.
163+ """
164+
153165 self .apply_base (base )
154166 self .bases .append (base )
155167
156168 def remove_base (self , base ):
169+ """
170+ Removes a previously added base structure from the
171+ container's internal list of managed bases. After this
172+ call the base will no longer receive poll events, tick
173+ callbacks or lifecycle notifications from the container.
174+
175+ :type base: Base/Agent
176+ :param base: The base structure to be removed from the
177+ container.
178+ """
179+
157180 self .bases .remove (base )
158181
159182 def start_base (self , base ):
183+ """
184+ Starts a single base structure by propagating the
185+ container's logging level and logger and then calling
186+ the base's load operation. If the container is configured
187+ with `diag_owner` only the owner base will have its
188+ diagnostics enabled, all other bases have it disabled
189+ to avoid port binding conflicts.
190+
191+ :type base: Base/Agent
192+ :param base: The base structure to be started under
193+ the container.
194+ """
195+
196+ # shares the container's logging level and logger with the base
197+ # this is required to ensure that the base is properly configured
198+ # to use the same logging configuration as the container (required for
199+ # the proper propagation of the logging configuration to the bases)
160200 base .level = self .level
161201 base .logger = self .logger
202+
203+ # if the container is configured with `diag_owner` only the
204+ # owner base will have its diagnostics enabled, all other bases
205+ # have it disabled to avoid port binding conflicts
206+ if self .diag_owner and not base == self .owner :
207+ base .diag = False
208+
162209 base .load ()
163210
164211 def start_all (self ):
0 commit comments