Ice.Communicator¶
- final class Ice.Communicator(args: list[str] | None = None, eventLoop: AbstractEventLoop | None = None)¶
- final class Ice.Communicator(*, initData: InitializationData | None = None)
Bases:
objectCommunicator is the central object in Ice. Its responsibilities include: - creating and managing outgoing connections - executing callbacks in its client thread pool - creating and destroying object adapters - loading plug-ins - managing properties (configuration), retries, logging, instrumentation, and more. A communicator is usually the first object you create when programming with Ice. You can create multiple communicators in a single program, but this is not common.
Example
The following example shows how to create a communicator and use the
async withstatement to ensure that the communicator is properly destroyed.async def main(): async with Ice.Communicator( sys.argv, eventLoop=asyncio.get_running_loop() ) as communicator: ... if __name__ == "__main__": asyncio.run(main())
- Parameters:
eventLoop (asyncio.AbstractEventLoop | None)
initData (InitializationData | None)
- property eventLoopAdapter: EventLoopAdapter | None¶
Returns this communicator’s event loop adapter, or
Noneif the communicator does not have one.- Returns:
The event loop adapter used by this communicator.
- Return type:
EventLoopAdapter | None
- destroy() None¶
Destroys this communicator. This function calls
shutdown()implicitly. Calling this function destroys all object adapters, and closes all outgoing connections. This function waits for all outstanding dispatches to complete before returning. This includes “bidirectional dispatches” that execute on outgoing connections.- Return type:
None
- destroyAsync() Awaitable[None]¶
Destroys this communicator asynchronously.
See
destroy().- Return type:
Awaitable[None]
- shutdown() None¶
Shuts down this communicator. This function calls
ObjectAdapter.deactivate()on all object adapters created by this communicator. Shutting down a communicator has no effect on outgoing connections.- Return type:
None
- waitForShutdown() None¶
Waits for shutdown to complete. This function calls
ObjectAdapter.waitForDeactivate()on all object adapters created by this communicator. In a client application that does not accept incoming connections, this function returns as soon as another thread callsshutdown()ordestroy()on this communicator.- Return type:
None
- shutdownCompleted() Awaitable[None]¶
Returns an
Awaitablethat completes when the communicator’s shutdown completes. This task always completes successfully.Notes
The shutdown of a communicator completes when all its incoming connections are closed. Awaiting this task is equivalent to awaiting
waitForShutdown().- Returns:
An awaitable that completes upon shutdown completion.
- Return type:
Awaitable[None]
- isShutdown() bool¶
Checks whether or not
shutdown()was called on this communicator.- Returns:
Trueifshutdown()was called on this communicator,Falseotherwise- Return type:
- stringToProxy(str: str) ObjectPrx | None¶
Converts a stringified proxy into a proxy.
- Parameters:
str (str) – The stringified proxy to convert into a proxy.
- Returns:
The proxy, or
Noneifstris an empty string.- Return type:
ObjectPrx | None
- Raises:
ParseException – If
stris not a valid proxy string.
- propertyToProxy(property: str) ObjectPrx | None¶
Converts a set of proxy properties into a proxy. The “base” name supplied in the
propertyargument refers to a property containing a stringified proxy, such asMyProxy=id:tcp -h localhost -p 10000. Additional properties configure local settings for the proxy.
- proxyToProperty(proxy: ObjectPrx, property: str) dict[str, str]¶
Converts a proxy into a set of proxy properties.
- createObjectAdapter(name: str) ObjectAdapter¶
Creates a new object adapter. The endpoints for the object adapter are taken from the property
name.Endpoints.It is legal to create an object adapter with the empty string as its name. Such an object adapter is accessible via bidirectional connections or by collocated invocations.
- Parameters:
name (str) – The object adapter name.
- Returns:
The new object adapter.
- Return type:
- createObjectAdapterWithEndpoints(name: str, endpoints: str) ObjectAdapter¶
Creates a new object adapter with endpoints. This function sets the property
name.Endpoints, and then callscreateObjectAdapter(). It is provided as a convenience function. Calling this function with an empty name will result in a UUID being generated for the name.- Parameters:
- Returns:
The new object adapter.
- Return type:
- createObjectAdapterWithRouter(name: str, router: RouterPrx) ObjectAdapter¶
Creates a new object adapter with a router. This function creates a routed object adapter. Calling this function with an empty name will result in a UUID being generated for the name.
- Parameters:
- Returns:
The new object adapter.
- Return type:
- getDefaultObjectAdapter() ObjectAdapter | None¶
Gets the object adapter that is associated by default with new outgoing connections created by this communicator. This function returns
Noneunless you set a non-Nonedefault object adapter usingsetDefaultObjectAdapter().- Returns:
The object adapter associated by default with new outgoing connections.
- Return type:
ObjectAdapter | None
- Raises:
CommunicatorDestroyedException – If the communicator has been destroyed.
- setDefaultObjectAdapter(adapter: ObjectAdapter | None)¶
Sets the object adapter that will be associated with new outgoing connections created by this communicator. This function has no effect on existing outgoing connections, or on incoming connections.
- Parameters:
adapter (ObjectAdapter | None) – The object adapter to associate with new outgoing connections.
- getImplicitContext() ImplicitContext | None¶
Gets the implicit context associated with this communicator.
- Returns:
The implicit context associated with this communicator; returns
Nonewhen the propertyIce.ImplicitContextis not set or is set toNone.- Return type:
ImplicitContext | None
- getProperties() Properties¶
Gets the properties of this communicator.
- Returns:
This communicator’s properties.
- Return type:
- getLogger() Logger¶
Gets the logger of this communicator.
- Returns:
This communicator’s logger.
- Return type:
- getDefaultRouter() RouterPrx | None¶
Gets the default router of this communicator.
- Returns:
The default router of this communicator, or
Noneif no default router has been set.- Return type:
RouterPrx | None
- Raises:
CommunicatorDestroyedException – If the communicator has been destroyed.
- setDefaultRouter(router: RouterPrx | None)¶
Sets the default router of this communicator. All newly created proxies will use this default router. This function has no effect on existing proxies.
Notes
You can set a router for an individual proxy by calling
ObjectPrx.ice_router()on the proxy.- Parameters:
router (RouterPrx | None) – The new default router. Use
Noneto remove the default router.
- getDefaultLocator() LocatorPrx | None¶
Gets the default locator of this communicator.
- Returns:
The default locator of this communicator, or
Noneif no default locator has been set.- Return type:
LocatorPrx | None
- setDefaultLocator(locator: LocatorPrx | None)¶
Sets the default locator of this communicator. All newly created proxies will use this default locator. This function has no effect on existing proxies or object adapters.
Notes
You can set a locator for an individual proxy by calling
ObjectPrx.ice_locator()on the proxy, or for an object adapter by callingObjectAdapter.setLocator()on the object adapter.- Parameters:
locator (LocatorPrx | None) – The new default locator. Use
Noneto remove the default locator.
- flushBatchRequests(compress: CompressBatch)¶
Flushes any pending batch requests of this communicator. This means all batch requests invoked on fixed proxies for all connections associated with the communicator. Errors that occur while flushing a connection are ignored.
- Parameters:
compress (CompressBatch) – Specifies whether or not the queued batch requests should be compressed before being sent over the wire.
- flushBatchRequestsAsync(compress: CompressBatch) Awaitable[None]¶
Flushes any pending batch requests of this communicator. This means all batch requests invoked on fixed proxies for all connections associated with the communicator. Errors that occur while flushing a connection are ignored.
- Parameters:
compress (CompressBatch) – Specifies whether or not the queued batch requests should be compressed before being sent over the wire.
- Returns:
An
Awaitablethat completes when all batch requests have been sent.- Return type:
Awaitable[None]
- createAdmin(adminAdapter: ObjectAdapter | None, adminId: Identity) ObjectPrx¶
Adds the Admin object with all its facets to the provided object adapter. If
Ice.Admin.ServerIdis set and the provided object adapter has aLocator, this function registers the Admin’s Process facet with theLocator’sLocatorRegistry.- Parameters:
adminAdapter (ObjectAdapter | None) – The object adapter used to host the Admin object; if it is
NoneandIce.Admin.Endpointsis set, this function uses theIce.Adminobject adapter, after creating and activating this adapter.adminId (Identity) – The identity of the Admin object.
- Returns:
A proxy to the main (“”) facet of the Admin object.
- Return type:
- Raises:
InitializationException – If this function is called more than once.
- getAdmin() ObjectPrx | None¶
Gets a proxy to the main facet of the Admin object.
getAdminalso creates the Admin object and creates and activates theIce.Adminobject adapter to host this Admin object ifIce.Admin.Endpointsis set. The identity of the Admin object created bygetAdminis{value of Ice.Admin.InstanceName}/admin, or{UUID}/adminwhenIce.Admin.InstanceNameis not set. IfIce.Admin.DelayCreationis0or not set,getAdminis called by the communicator initialization, after initialization of all plugins.- Returns:
A proxy to the main (“”) facet of the Admin object, or
Noneif no Admin object is configured.- Return type:
ObjectPrx | None
- Raises:
CommunicatorDestroyedException – If the communicator has been destroyed.
- addAdminFacet(servant: Object | None, facet: str) None¶
Adds a new facet to the Admin object.
- Parameters:
- Raises:
AlreadyRegisteredException – If a facet with the same name is already registered.
- Return type:
None
- removeAdminFacet(facet: str) Object¶
Removes a facet from the Admin object.
- Parameters:
facet (str) – The name of the Admin facet.
- Returns:
The servant associated with this Admin facet.
- Return type:
- Raises:
NotRegisteredException – If no facet with the given name is registered.