Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

edgify / rook   python

Repository URL to install this package:

Version: 0.1.176 

/ services / exception_capturing_location_service.py

import threading


class ExceptionCapturingLocationService(object):
    NAME = "exception_capturing"

    def __init__(self):
        self._lock = threading.RLock()
        self._aug_ids = []

    def get_ids(self):
        return self._aug_ids

    def add_exception_capturing_aug(self, aug):
        with self._lock:
            self._aug_ids.append(aug.aug_id)
            aug.set_active()

    def remove_aug(self, aug_id):
        with self._lock:
            try:
                self._aug_ids.remove(aug_id)
            except ValueError: # if value is not the array then there's nothing to do here
                pass

    def clear_augs(self):
        with self._lock:
            del self._aug_ids[:]

    def close(self):
        self.clear_augs()

    def pre_fork(self):
        if self._lock:
            self._lock.acquire()

    def post_fork(self):
        if self._lock:
            self._lock.release()

    def activation_status(self):
        return len(self._aug_ids) > 0