Communicator Initialization and Destruction
Creating a Communicator
You create a communicator by using its constructor, for example:
import Ice
import sys
def main():
with Ice.Communicator(sys.argv) as communicator:
...
Ice.Communicator constructor accepts the argument list that is passed to the program by the operating system. The constructor scans the argument list for any command-line options that are relevant to the Ice runtime; any such options are removed from the argument list so, when Ice.Communicatorconstructor returns, the only options and arguments remaining are those that concern your application. If anything goes wrong during initialization, it throws an exception.
Communicator implements the Python context manager protocol, with cleans up the communicator automatically at the end of the with block.
async with is preferred in an async context. For example:
import Ice
import asyncio
import sys
async def main():
async with Ice.Communicator(
sys.argv,
eventLoop=asyncio.get_running_loop()) as communicator:
...
Initialization Data
When a communicator is created, its constructor or the initialize method configures several features that control its behavior. Once set, these features remain in effect for the lifetime of the communicator and cannot be changed afterward. Therefore, any customization of these features must be done at communicator creation time.
The InitializationData class or struct holds all the features (or options) that you can customize when you create a communicator.