def finalize(self):
        if (self._wrap_mode == pypetconstants.WRAP_MODE_QUEUE and
                    self._queue_process is not None):
            self._logger.info('The Storage Queue will no longer accept new data. '
                              'Hang in there for a little while. '
                              'There still might be some data in the queue that '
                              'needs to be stored.')
            # We might have passed the queue implicitly,
            # to be sure we add the queue here again
            self._traj.v_storage_service.queue = self._queue
            self._traj.v_storage_service.send_done()
            self._queue_process.join()
            if hasattr(self._queue, 'join'):
                self._queue.join()
            if hasattr(self._queue, 'close'):
                self._queue.close()
            if hasattr(self._queue, 'join_thread'):
                self._queue.join_thread()
            self._logger.info('The Storage Queue has joined.')

        elif (self._wrap_mode == pypetconstants.WRAP_MODE_PIPE and
                    self._pipe_process is not None):
            self._logger.info('The Storage Pipe will no longer accept new data. '
                              'Hang in there for a little while. '
                              'There still might be some data in the pipe that '
                              'needs to be stored.')
            self._traj.v_storage_service.conn = self._pipe[1]
            self._traj.v_storage_service.send_done()
            self._pipe_process.join()
            self._pipe[1].close()
            self._pipe[0].close()
        elif (self._wrap_mode == pypetconstants.WRAP_MODE_NETLOCK and
                self._lock_process is not None):
            self._lock.send_done()
            self._lock.finalize()
            self._lock_process.join()
        elif (self._wrap_mode == pypetconstants.WRAP_MODE_NETQUEUE and
                self._queue_process is not None):
            self._queue.send_done()
            self._queue.finalize()
            self._queue_process.join()

        if self._manager is not None:
            self._manager.shutdown()

        self._manager = None
        self._queue_process = None
        self._queue = None
        self._queue_wrapper = None
        self._lock = None
        self._lock_wrapper = None
        self._lock_process = None
        self._reference_wrapper = None
        self._pipe = None
        self._pipe_process = None
        self._pipe_wrapper = None
        self._logging_manager = None

        self._traj._storage_service = self._storage_service
Blocks until this backend has connected to and initialized the modem,
dataset/ETHPy150Open SmokinCaterpillar/pypet/pypet/environment.py/MultiprocContext.finalize--crossover with--dataset/ETHPy150Open rapidsms/rapidsms-core-dev/lib/rapidsms/backends/gsm.py/Backend._wait_for_modem