def _wait_for_new_device(base, expected_size, time_limit=60):
 start_time = time.time()
 elapsed_time = (time.time() - start_time)
 while (elapsed_time < time_limit):
  for device in list((set(FilePath('/sys/block').children()) - set(base))):
   device_name = device.basename()
   if (device_name.startswith(('sd', 'xvd')) and (_get_device_size(device_name) == expected_size)):
    return FilePath('/dev').child(device_name)
  time.sleep(0.1)
  elapsed_time = (time.time() - start_time)
 new_devices = list((device.basename() for device in (set(FilePath('/sys/block').children()) - set(base))))
 new_devices_size = list((_get_device_size(device_name) for device_name in new_devices))
 NO_NEW_DEVICE_IN_OS(new_devices=new_devices, new_devices_size=new_devices_size, expected_size=expected_size, time_limit=time_limit).write()
 return None

def _wait_for_new_device ( base , expected_size , time_limit = 60 ) : start_time = time . time ( ) elapsed_time = ( time . time ( ) - start_time ) while ( elapsed_time < time_limit ) : for device in list ( ( set ( FilePath ( '/sys/block' ) . children ( ) ) - set ( base ) ) ) : device_name = device . basename ( ) if ( device_name . startswith ( ( 'sd' , 'xvd' ) ) and ( _get_device_size ( device_name ) == expected_size ) ) : return FilePath ( '/dev' ) . child ( device_name ) time . sleep ( 0.1 ) elapsed_time = ( time . time ( ) - start_time ) new_devices = list ( ( device . basename ( ) for device in ( set ( FilePath ( '/sys/block' ) . children ( ) ) - set ( base ) ) ) ) new_devices_size = list ( ( _get_device_size ( device_name ) for device_name in new_devices ) ) NO_NEW_DEVICE_IN_OS ( new_devices = new_devices , new_devices_size = new_devices_size , expected_size = expected_size , time_limit = time_limit ) . write ( ) return None
helper function to wait for up to 60s for new ebs block device to manifest in the os .