How to use the wrapt.decorators.synchronized function in wrapt

To help you get started, we’ve selected a few wrapt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hsnlab / escape / escape / escape / adapt / virtualization.py View on Github external
  @synchronized(__DoV_lock)
  def remove_deployed_elements (self):
    """
    Remove all the NFs, flowrules and dynamic ports from DoV.

    :return: updated Dov
    :rtype: :class:`NFFG`
    """
    if self.__global_nffg.is_empty():
      log.debug("DoV is empty! Skip DoV cleanup")
      return self.__global_nffg
    NFFGToolBox.remove_deployed_services(nffg=self.__global_nffg, log=log)
    log.debug("DoV stat:\n%s" % self.__global_nffg.get_stat())
    log.log(VERBOSE, "Cleared Dov:\n%s" % self.__global_nffg.dump())
    self.raiseEventNoErrors(DoVChangedEvent, cause=DoVChangedEvent.TYPE.CHANGE)
    return self.__global_nffg
github hsnlab / escape / escape / escape / adapt / virtualization.py View on Github external
  @synchronized(__DoV_lock)
  def set_domain_as_global_view (self, domain, nffg):
    """
    Set the copy of given NFFG as the global view of DoV.

    Add the specific :attr:`DoV` id and generated name to the global view.

    :param nffg: NFFG instance intended to use as the global view
    :type nffg: :class:`NFFG`
    :param domain: name of the merging domain
    :type domain: str
    :return: updated Dov
    :rtype: :class:`NFFG`
    """
    log.debug("Set domain: %s as the global view!" % domain)
    if not self.__global_nffg.is_empty():
      log.warning("Global view is not empty! Current state will be lost!")
github hsnlab / escape / escape / escape / adapt / virtualization.py View on Github external
  @synchronized(__DoV_lock)
  def remove_domain_from_dov (self, domain):
    """
    Remove the nodes and edges with the given from Global view.

    :param domain: domain name
    :type domain: str
    :return: updated Dov
    :rtype: :class:`NFFG`
    """
    NFFGToolBox.remove_domain(base=self.__global_nffg, domain=domain, log=log)
    if self.__global_nffg.is_empty():
      log.warning("No Node had been remained after updating the domain part: "
                  "%s! DoV is empty!" % domain)
    log.debug("DoV stat:\n%s" % self.__global_nffg.get_stat())
    log.log(VERBOSE, "Reduced Dov:\n%s" % self.__global_nffg.dump())
    # Raise event for observing Virtualizers about topology change
github hsnlab / escape / escape / escape / adapt / virtualization.py View on Github external
  @synchronized(__DoV_lock)
  def remerge_domain_in_dov (self, domain, nffg):
    """
    Update the existing domain in the merged Global view with explicit domain
    remove and re-add.

    :param nffg: changed infrastructure info
    :type nffg: :class:`NFFG`
    :param domain: name of the merging domain
    :type domain: str
    :return: updated Dov
    :rtype: :class:`NFFG`
    """
    NFFGToolBox.remove_domain(base=self.__global_nffg, domain=domain, log=log)
    # log.log(VERBOSE, "Reduced Dov:\n%s" % self.__global_nffg.dump())
    NFFGToolBox.merge_new_domain(base=self.__global_nffg, nffg=nffg, log=log)
    log.debug("DoV stat:\n%s" % self.__global_nffg.get_stat())
github hsnlab / escape / escape / escape / adapt / virtualization.py View on Github external
  @synchronized(__DoV_lock)
  def is_empty (self):
    """
    Return True if the stored topology is empty.

    :return: topology is empty or not
    :rtype: bool
    """
    # If Dov has not been set yet
    if self.__global_nffg is None:
      return True
    # If Dov does not contain any Node
    elif self.__global_nffg.is_empty():
      return True
    else:
      return False
github hsnlab / escape / escape / escape / adapt / virtualization.py View on Github external
  @synchronized(__DoV_lock)
  def update_domain_status_in_dov (self, domain, nffg):
    """
    Set status of initiated NFs and flowrules related to BiSBiS nodes of the
    given domain.

    :param domain: domain name
    :type domain: str
    :param nffg: changed infrastructure info
    :type nffg: :class:`NFFG`
    :return: updated Dov
    :rtype: :class:`NFFG`
    """
    if self.__global_nffg.is_empty():
      log.debug("DoV is empty! Skip cleanup domain: %s" % domain)
      return self.__global_nffg
    NFFGToolBox.update_status_info(nffg=nffg, status=NFFG.STATUS_DEPLOY)
github hsnlab / escape / escape / escape / adapt / virtualization.py View on Github external
  @synchronized(__DoV_lock)
  def clean_domain_from_dov (self, domain):
    """
    Clean domain by removing initiated NFs and flowrules related to BiSBiS
    nodes of the given domain

    :param domain: domain name
    :type domain: str
    :return: updated Dov
    :rtype: :class:`NFFG`
    """
    if self.__global_nffg.is_empty():
      log.debug("DoV is empty! Skip cleanup domain: %s" % domain)
      return self.__global_nffg
    if self.__global_nffg.is_bare():
      log.debug("No initiated service has been detected in DoV! "
                "Skip cleanup domain: %s" % domain)
github DataDog / dd-trace-py / ddtrace / utils / install.py View on Github external
@synchronized(_post_import_hooks_lock)
def _deregister_post_import_hook(modulename, matcher):
    """
    Deregisters post import hooks for a module given the module name and a
    matcher function. All hooks matching the matcher function will be removed.
    """
    hooks = _post_import_hooks.get(modulename, []) or []
    hooks = list(filter(lambda h: not matcher(h), hooks))

    # Work around for wrapt since wrapt assumes that if
    # _post_import_hooks.get(modulename) is not None then the module must have
    # been imported.
    if not len(hooks):
        hooks = None
    _post_import_hooks[modulename] = hooks
github hsnlab / escape / escape / escape / adapt / virtualization.py View on Github external
  @synchronized(__DoV_lock)
  def update_full_global_view (self, nffg):
    """
    Update the merged Global view with the given probably modified global view.

    Reserve id, name values of the global view.

    :param nffg: updated global view which replace the stored one
    :type nffg: :class:`NFFG`
    :return: updated Dov
    :rtype: :class:`NFFG`
    """
    dov_id = self.__global_nffg.id
    dov_name = self.__global_nffg.name
    self.__global_nffg = nffg.copy()
    self.__global_nffg.id, self.__global_nffg.name = dov_id, dov_name
    log.debug("DoV stat:\n%s" % self.__global_nffg.get_stat())
github hsnlab / escape / escape / escape / adapt / virtualization.py View on Github external
  @synchronized(__DoV_lock)
  def get_resource_info (self):
    """
    Return the copy of the global resource info represented this class.

    :return: global resource info
    :rtype: :class:`NFFG`
    """
    return self.__global_nffg.copy()