def __init__(self, identifier, lock_dir):
        super(FileSynchronizer, self).__init__()
        self._filedescriptor = util.ThreadLocal()

        if lock_dir is None:
            lock_dir = tempfile.gettempdir()
        else:
            lock_dir = lock_dir

        self.filename = util.encoded_path(lock_dir, [identifier],
                                          extension='.lock')
예제 #2
0
    def __init__(self, identifier):
        self.tlocalstate = util.ThreadLocal(creator=lambda: SyncState())

        # counts how many asynchronous methods are executing
        self. async = 0

        # pointer to thread that is the current sync operation
        self.current_sync_operation = None

        # condition object to lock on
        self.condition = _threading.Condition(_threading.Lock())
예제 #3
0
    def __init__(self,
                 identifier=None,
                 use_files=False,
                 lock_dir=None,
                 digest_filenames=True):
        if not has_flock:
            use_files = False

        if use_files:
            syncs = Synchronizer.conditions.sync_get(
                "file_%s" % identifier,
                lambda: util.ThreadLocal(creator=lambda: FileSynchronizer(
                    identifier, lock_dir, digest_filenames)))
            self._get_impl = lambda: syncs.get()
        else:
            condition = Synchronizer.conditions.sync_get(
                "condition_%s" % identifier,
                lambda: ConditionSynchronizer(identifier))
            self._get_impl = lambda: condition
예제 #4
0
 def __init__(self):
     self._state = util.ThreadLocal()