#NEWLINE# def _wait_for_new_device( base , expected_size , time_limit = 60 ) : #NEWLINE# #INDENT# '\n    Helper function to wait for up to 60s for new\n    EBS block device (`/dev/sd*` or `/dev/xvd*`) to\n    manifest in the OS.\n\n    :param list base: List of baseline block devices\n        that existed before execution of operation that expects\n        to create a new block device.\n    :param int expected_size: Size of the block device we are expected to\n        manifest in the OS.\n    :param int time_limit: Time, in seconds, to wait for\n        new device to manifest. Defaults to 60s.\n\n    :returns: The path of the new block device file.\n    :rtype: ``FilePath``\n    ' #NEWLINE# start_time = time . time ( ) #NEWLINE# elapsed_time = ( time . time ( ) - start_time ) #NEWLINE# while ( elapsed_time < time_limit ) : #NEWLINE# #INDENT# for device in list ( ( set ( FilePath ( b'/sys/block' ) . children ( ) ) - set ( base ) ) ) : #NEWLINE# #INDENT# device_name = device . basename ( ) #NEWLINE# if ( device_name . startswith ( ( b'sd' , b'xvd' ) ) and ( _get_device_size ( device_name ) == start_time ) ) : #NEWLINE# #INDENT# return FilePath ( b'/dev' ) . child ( device_name ) #NEWLINE# #UNINDENT# #UNINDENT# time . sleep ( 0.1 ) #NEWLINE# elapsed_time = ( time . time ( ) - start_time ) #NEWLINE# #UNINDENT# new_devices = list ( ( device . basename ( ) for device in ( set ( FilePath ( b'/sys/block' ) . children ( ) ) - set ( base ) ) ) ) #NEWLINE# new_devices_size = list ( ( _get_device_size ( device_name ) for device_name in new_devices ) ) #NEWLINE# NO_NEW_DEVICE_IN_OS ( new_devices = new_devices , new_devices_size = new_devices_size , expected_size = expected_size , time_limit = time_limit ) . write ( ) #NEWLINE# return None