Ejemplo n.º 1
0
 def testDeleteObject1(self):
     from pycompss.runtime.binding import pending_to_synchronize, objid_to_filename, get_object_id
     obj_1 = [0]
     obj_2 = increment_object(obj_1)
     obj_2 = compss_wait_on(obj_2)
     obj_1_id = get_object_id(obj_1, False, False)
     deletion_result = compss_delete_object(obj_1)
     self.assertTrue(deletion_result)
     self.assertFalse(obj_1_id in pending_to_synchronize)
     self.assertTrue(get_object_id(obj_1, False, False) is None)
Ejemplo n.º 2
0
def compss_delete_object(obj):
    import compss
    from pycompss.runtime.binding import get_object_id
    from pycompss.runtime.binding import objid_to_filename
    from pycompss.runtime.binding import pending_to_synchronize
    from pycompss.runtime.binding import id2obj
    obj_id = get_object_id(obj, False, False)
    if obj_id is None:
        return False
    try:
        id2obj.pop(obj_id)
    except:
        pass
    try:
        file_name = objid_to_filename[obj_id]
        compss.delete_file(file_name)
    except:
        pass
    try:
        objid_to_filename.pop(obj_id)
    except:
        pass
    try:
        pending_to_synchronize.pop(obj_id)
    except:
        pass
    return True
Ejemplo n.º 3
0
 def wait_on_list(l):
     # check if the object is in our pending_to_synchronize dictionary
     from pycompss.runtime.binding import get_object_id
     obj_id = get_object_id(l)
     if obj_id in pending_to_synchronize:
         return synchronize(l, compss_mode)
     else:
         if type(l) == list:
             return [wait_on_list(x) for x in l]
         else:
             return synchronize(l, compss_mode)
Ejemplo n.º 4
0
 def wait_on_iterable(iter_obj):
     """
     Wait on an iterable object.
     Currently supports lists and dictionaries (syncs the values).
     :param iter_obj: iterable object
     :return: synchronized object
     """
     # check if the object is in our pending_to_synchronize dictionary
     from pycompss.runtime.binding import get_object_id
     obj_id = get_object_id(iter_obj)
     if obj_id in pending_to_synchronize:
         return synchronize(iter_obj, compss_mode)
     else:
         if type(iter_obj) == list:
             return [wait_on_iterable(x) for x in iter_obj]
         elif type(iter_obj) == dict:
             return {
                 k: wait_on_iterable(v)
                 for k, v in iter_obj.items()
             }
         else:
             return synchronize(iter_obj, compss_mode)
Ejemplo n.º 5
0
 def must_sync(obj):
     return get_object_id(obj) in pending_to_synchronize