Пример #1
0
    def test_num_instances(self):

        self.assertEquals(Singleton._num_instances(), 2)

        Singleton.__del_instance__('s1')

        self.assertEquals(Singleton._num_instances(), 1)
Пример #2
0
    def __new_instance__( self, name ):
        """
        Initialize Class note that this constructor returns a shared state instance
        """
        Singleton.__new_instance__(self, name)

        self.setplugins( )
Пример #3
0
    def testcreate_singleton(self):

        s1 = self.s1
        s2 = self.s2
        s1.foo = 1
        s2.foo = 2

        s3 = Singleton('s1')

        self.assertNotEqual(s1.foo, s2.foo)
        self.assertEqual(s1.foo, s3.foo)

        s3.__del_instance__('s1')

        s4 = Singleton('s1')

        self.assertRaises(AttributeError, getattr, s4, 'foo')

        error_singleton = type('newsingleton', (Singleton, ),
                               {'__init__': lambda self: None})

        self.assertRaises(TypeError, error_singleton, 's1')

        newsingleton = type('newsingleton', (Singleton, ), {})

        ns = newsingleton('s2')

        self.assertEquals(ns._instance_name, 's2')
        self.assertRaises(AttributeError, getattr, ns, 'foo')
Пример #4
0
    def __new_instance__(self, name):
        '''
        create a new instance
        '''
        Singleton.__new_instance__(self, name)

        self.lock = RLock()

        with self:
            self._jobs_posted = 0
            self._jobs_finished = 0
            self._done = False
            self._error = False
            self._error_message = None
            self._pids = set()
            self._aborted_pids = set()
            self._waiting_list = set()
            self._event = Event()
            self.__node_names = []
            self.nodes = {}
            self._idle = set()
            self._fin = set()
            self._head_node = ("__main__", "__main__")

            self.env = InstanceManager()

        self._semaphore = None
Пример #5
0
    def __new_instance__(self, name):

        Singleton.__new_instance__(self, name)
        self._hash = {}
        self._scalars = {}
        self._no_clean = False
        #===============================================================================
        # Make sure that at exit the clean function is set
        #===============================================================================
        __register__(self.clear_at_exit)
Пример #6
0
    def __new_instance__(self, name):
        Singleton.__new_instance__(self, name)
         
        self._built_graph = None
        self.msg_record = []
        self.command_records = []
        self.trace_back_records = {}
        
        self._filters = set( )
        self._filter_type = "any"
        
        self._abridge = False 
#        print traceback.extract_stack()
        __register__( self.dump )
Пример #7
0
    def __new_instance__(self, name):
        Singleton.__new_instance__(self, name)
        self.slimGlobals = {}

        self.PATHS = ["datapath", 'localtmpdir', 'globaltmpdir']
        self.INTS = ["memsize", "verbose", 'ispipe', "eps"]
        self.BOOLS = ['ispipe']
        self.EVALS = ['nwin']

        self.slimdoc = {
            # PATHS
            "datapath": "path where perminant data files will be built",
            #            "tmpdir":       "temporary header files will be built",
            #            'tmpdatapath':  "perminant data files will be built",
            'localtmpdir':
            'mpi - temp header files will be built (local to each node) ',
            'globaltmpdir':
            'mpi - temp header files will be built (global for every node) ',
            "memsize": 'set the memory available to each program',
            "verbose": 'set the verbosity from 1 to 10',
            "eps": 'Domain decomposition overlap',
            'nwin': 'dimentions to split the data into - mpi',
            'MPIRUN': 'executable for mpi, used with MPIFLAGS',
            'NODEFILE': 'file containing list of node names for mpi',
            "MPIFLAGS": "defaults to '${MPIRUN} -np=${np} ${NODEFILE}'",
            'NODELIST': 'python list containing node names for mpi',
            'abridge': 'abridge output with abridge-map',
            'check_path': 'bool - check if all executable paths exist',
            'debug':
            'print extra info to logfile eg. print >> log(10,"foo") will print if debug=foo',
            'logfile': 'file to print to',
            'mpi': 'bool - force running mpi  or not',
            'np': 'number of processors running in mpi',
            'runtype': '"normal" or "dryrun" ',
            'strict_check':
            '0,1 or 2. On 0 no domain/range checking. 1 checking. 2 no void Spaces will be accepted',
            'test_devel': 'run developer tests, usualy known bugs',
            'abridgeMap':
            "dictionary of strings to call 'output.replace(key,val)' before printing",
            'no_del':
            "bool, if true SLIMpy will not delete data until the end",
            'walltime': 'amount of time a command is allowed to take',
            'rsh':
            'distributed mode: command used to talk with nodes [default "ssh"]',
            'sync_disk_om_rm': 'calls $SYNC_CMD before removing data on disk'
        }

        self.update(**DEFAULTS)
Пример #8
0
    def __new_instance__(self, name):
        """
        simalar to init but for singleton
        initializes the class when  a new instance is created
        """

        Singleton.__new_instance__(self, name)

        #        self.log = Log()
        self.env = InstanceManager()

        self.graph = DiGraph()

        self.__breakpoints = set()
        self.__sources = set()
        self.__targets = set()

        self.runner = defaultRunner()
        self.builder = PipeBuilder()
Пример #9
0
    def tearDown(self):
        Singleton.__del_instance__('s1')
        Singleton.__del_instance__('s2')

        self.assertEquals(Singleton._num_instances(), 0)
Пример #10
0
 def setUp(self):
     self.s1 = Singleton('s1')
     self.s2 = Singleton('s2')