Only intended to be called by the Phylesystem singleton.
545081
def _make_phylesystem_cache_region(**kwargs):
    
    global _CACHE_REGION_CONFIGURED, _REGION
    if _CACHE_REGION_CONFIGURED:
        return _REGION
    _CACHE_REGION_CONFIGURED = True
    try:
        # noinspection PyPackageRequirements
        from dogpile.cache import make_region
    except:
        _LOG.debug('dogpile.cache not available')
        return
    region = None
    trial_key = 'test_key'
    trial_val = {'test_val': [4, 3]}
    trying_redis = True
    if trying_redis:
        try:
            a = {
                'host': 'localhost',
                'port': 6379,
                'db': 0,  # default is 0
                'redis_expiration_time': 60 * 60 * 24 * 2,  # 2 days
                'distributed_lock': False  # True if multiple processes will use redis
            }
            region = make_region().configure('dogpile.cache.redis', arguments=a)
            _LOG.debug('cache region set up with cache.redis.')
            _LOG.debug('testing redis caching...')
            region.set(trial_key, trial_val)
            assert trial_val == region.get(trial_key)
            _LOG.debug('redis caching works')
            region.delete(trial_key)
            _REGION = region
            return region
        except:
            _LOG.debug('redis cache set up failed.')
            region = None
    trying_file_dbm = False
    if trying_file_dbm:
        _LOG.debug('Going to try dogpile.cache.dbm ...')
        first_par = _get_phylesystem_parent(**kwargs)[0]
        cache_db_dir = os.path.split(first_par)[0]
        cache_db = os.path.join(cache_db_dir, 'phylesystem-cachefile.dbm')
        _LOG.debug('dogpile.cache region using "{}"'.format(cache_db))
        try:
            a = {'filename': cache_db}
            region = make_region().configure('dogpile.cache.dbm',
                                             expiration_time=36000,
                                             arguments=a)
            _LOG.debug('cache region set up with cache.dbm.')
            _LOG.debug('testing anydbm caching...')
            region.set(trial_key, trial_val)
            assert trial_val == region.get(trial_key)
            _LOG.debug('anydbm caching works')
            region.delete(trial_key)
            _REGION = region
            return region
        except:
            _LOG.debug('anydbm cache set up failed')
            _LOG.debug('exception in the configuration of the cache.')
    _LOG.debug('Phylesystem will not use caching')
    return None
1279967
public static NameService instance(HttpSession session)
    {
        if (session == null)
            throw new IllegalArgumentException("Session must not be null");

        // Synchronize on a session scoped mutex to ensure that only a single
        // NameService object is created within a specific user session
        Object sessionMutex = ServletUtils.getSessionMutex(session, NAME_SERVICE_MUTEX_ATTRIBUTE);
        synchronized (sessionMutex) {
            NameService nameService = (NameService) session.getAttribute(NAME_SERVICE);
            if (nameService == null) {
                nameService = new NameService();
                session.setAttribute(NAME_SERVICE,nameService);
            }
            return nameService;
        }
    }
793100
private static ConcurrentPropagationService getInstance() {
    if (instance == null) {
      synchronized (ConcurrentPropagationService.class) {
        if (instance == null) {
          instance = new ConcurrentPropagationService();
        }
      }
    }
    return instance;
  }
563687
def only(self, *fields):
        '''
        
        '''
        s = self._clone()
        if len(fields) == 1 and fields[0] == '__model':
            s._only = '__model'
        else:
            s._only = fields
        return s
687433
@Override
    public void discard() {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "discard: " + getStateName(state));

        // d639281 - Singleton instances are never actually discarded unless a
        // failure occurs during initialize().
        if (state == PRE_CREATE || state == CREATING) {
            setState(DESTROYED);

            // Release any JCDI creational contexts that may exist.      F743-29174
            this.releaseManagedObjectContext();

            if (pmiBean != null) {
                pmiBean.discardCount(); // F743-27070
                pmiBean.beanDestroyed();
            }
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "discard");
    }
440734
def initiate
      primary, *secondaries = @nodes.shuffle

      primary.promote
      secondaries.each(&:demote)

      return primary, secondaries
    end
688068
public static function singleton()
    {
        if (!isset(self::$_instance)) {
            $c = __CLASS__;
            self::$_instance = new $c;
        }

        return self::$_instance;
    }
56737
public boolean destroyDependentInstance(T instance) {
        synchronized (dependentInstances) {
            for (Iterator<ContextualInstance<?>> iterator = dependentInstances.iterator(); iterator.hasNext();) {
                ContextualInstance<?> contextualInstance = iterator.next();
                if (contextualInstance.getInstance() == instance) {
                    iterator.remove();
                    destroy(contextualInstance);
                    return true;
                }
            }
        }
        return false;
    }
225423
def endInstance(self):
        
        if self.currentInstance is None:
            return
        allInstances = self.root.findall('.instances')[0].append(self.currentInstance)
        self.currentInstance = None
327991
public synchronized static HortonMachine getInstance() {
        if (hortonMachine == null) {
            hortonMachine = new HortonMachine(null);
            hortonMachine.gatherInformations();
        }
        return hortonMachine;
    }
1296847
def single(self):
        
        nodes = super(ZeroOrOne, self).all()
        if len(nodes) == 1:
            return nodes[0]
        if len(nodes) > 1:
            raise CardinalityViolation(self, len(nodes))
650468
def single_shot(self, check_status=True, **kwargs):
        
        self.check_pid_file()
        self.set_spectator_mode(False)
        if check_status: self.check_status()
        from .launcher import PyLauncher
        return PyLauncher(self, **kwargs).single_shot()
992627
@Override
    public boolean invokeEvictable(final Mp instance) throws DempsyException {
        try {
            return instance.shouldBeEvicted();
        } catch(final RuntimeException rte) {
            throw new DempsyException(rte, true);
        }
    }
792992
def only(*onlies)
      result = self.class.new(@klass, table)
      result.default_scoped = default_scoped

      ((Relation::ASSOCIATION_METHODS + Relation::MULTI_VALUE_METHODS) & onlies).each do |method|
        result.send(:"#{method}_values=", send(:"#{method}_values"))
      end

      (Relation::SINGLE_VALUE_METHODS & onlies).each do |method|
        result.send(:"#{method}_value=", send(:"#{method}_value"))
      end

      # Apply scope extension modules
      result.send(:apply_modules, extensions)

      result
    end
135079
def define_singleton(r, sym, method)
      name = r.send(sym)

      if name && name !~ /\W/ && !r.respond_to?(name) && !respond_to?(name)
        instance_eval(%Q{def #{name}\n#{method}('#{name}')\nend})
      end
    end
614804
public static synchronized RuntimeDelegate ensureSet() {
        if (singleton == null) {
            singleton = new MuRuntimeDelegate();
            RuntimeDelegate.setInstance(singleton);
        }
        return singleton;
    }
1156461
def getInstance(cls, *args):
        '''
        
        '''
        if not cls.__singleton:
            cls.__singleton = Heroku(*args)
        return cls.__singleton