Communicator Initialization and Destruction
Creating a Communicator
You create a communicator by calling Ice.initialize, for example:
import Ice
import sys
def main():
with Ice.initialize(sys.argv) as communicator:
...
Ice.initialize
accepts the argument list that is passed to the program by the operating system. The function 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.initialize
returns, the only options and arguments remaining are those that concern your application. If anything goes wrong during initialization, initialize
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.initialize(sys.argv, eventLoop=asyncio.get_running_loop()) as communicator:
...
Initialization Data
During the creation of a communicator, initialize
configures a number of features that affect the communicator's operation. Once set, these features remain in effect for the life time of the communicator, that is, you cannot change these features after you have created a communicator. Therefore, if you want to customize these features, you must do so when you create the communicator.
The InitializationData class or struct holds all the features (or options) that you can customize when you create a communicator.