Projet

Général

Profil

0001-avoid-function-parameters-named-async-28450.patch

Paul Marillonnet, 28 juin 2018 14:16

Télécharger (2,25 ko)

Voir les différences:

Subject: [PATCH] avoid function parameters named 'async' (#28450)

 tests/test_storage.py | 2 +-
 wcs/qommon/storage.py | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
tests/test_storage.py
406 406
                test = Foobar()
407 407
                test.value = 'x'
408 408
                test.dict_value = {'plop': random.randint(0, 10)}
409
                test.store(async=False)
409
                test.store(async_ops=False)
410 410
            os._exit(0)
411 411

  
412 412
    for pid in children_pids:
wcs/qommon/storage.py
56 56
    if not k: return k
57 57
    return str(k).replace('/', '-')
58 58

  
59
def atomic_write(path, content, async=False):
59
def atomic_write(path, content, async_ops=False):
60 60
    '''Rewrite a complete file automatically, that is write to new file with
61 61
    temporary name, fsync, then rename to final name. Use threads to remove blocking.'''
62 62
    def doit():
......
76 76
        os.fsync(f.fileno())
77 77
        f.close()
78 78
        os.rename(temp, path)
79
    if async:
79
    if async_ops:
80 80
        _thread.start_new_thread(doit, ())
81 81
    else:
82 82
        doit()
......
497 497
    def storage_dumps(cls, object):
498 498
        return pickle.dumps(object)
499 499

  
500
    def store(self, async=False):
500
    def store(self, async_ops=False):
501 501
        objects_dir = self.get_objects_dir()
502 502
        new_object = False
503 503
        if self._filename:
......
526 526
                            ignore_errors=True, ignore_migration=True)
527 527

  
528 528
        s = self.storage_dumps(self)
529
        atomic_write(object_filename, s, async)
529
        atomic_write(object_filename, s, async_ops)
530 530
        # update last modified time
531 531
        if os.path.exists(objects_dir):
532 532
            os.utime(objects_dir, None)
533
-