def connect_sync(self, connection_id, connection_string):
        """Synchronously connect to a device

        Args:
            connection_id (int): A unique identifier that will refer to this connection
            connection_string (string): A DeviceAdapter specific string that can be used to connect to
                a device using this DeviceAdapter.

        Returns:
            dict: A dictionary with two elements
                'success': a bool with the result of the connection attempt
                'failure_reason': a string with the reason for the failure if we failed
        """

        calldone = threading.Event()
        results = {}

        def connect_done(callback_connid, callback_adapterid, callback_success, failure_reason):
            results['success'] = callback_success
            results['failure_reason'] = failure_reason
            calldone.set()  # Be sure to set after all operations are done to prevent race condition

        self.connect_async(connection_id, connection_string, connect_done)
        calldone.wait()

        return results
def connect_sync ( self , connection_id , connection_string ) : calldone = threading . Event ( ) results = { } def connect_done ( callback_connid , callback_adapterid , callback_success , failure_reason ) : results [ 'success' ] = callback_success results [ 'failure_reason' ] = failure_reason calldone . set ( ) self . connect_async ( connection_id , connection_string , connect_done ) calldone . wait ( ) return results
Synchronously connect to a device

        Args:
            connection_id (int): A unique identifier that will refer to this connection
            connection_string (string): A DeviceAdapter specific string that can be used to connect to
                a device using this DeviceAdapter.

        Returns:
            dict: A dictionary with two elements
                'success': a bool with the result of the connection attempt
                'failure_reason': a string with the reason for the failure if we failed