def start(): """ Starts baboon client ! """ # Ensure the validity of the configuration file. check_config(add_mandatory_server_fields=['streamer', 'max_stanza_size']) metadirs = [] monitor = None transport = None try: transport = _start_transport() monitor = _start_monitor() metadirs = _start_metadirs(monitor.handler.exclude) # Wait until the transport is disconnected before exiting Baboon. _wait_disconnect(transport) except BaboonException as err: logger.error(err) except KeyboardInterrupt: pass finally: _start_close(monitor, transport, metadirs) logger.info("Bye !")
def _start_close(monitor, transport, metadirs): """ Clears the monitor, transport and list of metadir before finishing the start command. """ logger.info("Closing baboon...") # Close each metadir shelve index. for metadir in metadirs: metadir.index.close() # Close the transport and the monitor. If one of them is not # started, the close() method has no effect. if monitor: monitor.close() if transport: transport.close() transport.disconnected.wait(10)