def testEqualityFailsIfDifferentGeneratingAddress(self): genAddr = ActorAddress(id(self)) genAddr2 = ActorAddress('hi') self.assertNotEqual(genAddr, genAddr2) addr1 = ActorLocalAddress(genAddr, 0, None) addr2 = ActorLocalAddress(genAddr2, 0, None) self.assertNotEqual(addr1, addr2)
def testEqualityFailsIfDifferentGeneratingAddress(self): genAddr = ActorAddress(id(self)) genAddr2 = ActorAddress('hi') assert genAddr != genAddr2 addr1 = ActorLocalAddress(genAddr, 0, None) addr2 = ActorLocalAddress(genAddr2, 0, None) assert addr1 != addr2
def startAdmin(adminClass, addrOfStarter, endpointPrep, transportClass, adminAddr, capabilities, logDefs): # Unix Daemonization; skipped if not available import os, sys if hasattr(os, 'setsid'): os.setsid() try: import resource resource.setrlimit(resource.RLIMIT_CORE, (0, 0)) # No core dumps except Exception: pass if hasattr(os, 'fork'): if os.fork(): sys.exit(0) # Slight trickiness here. There may *already* be an admin bound # to this start address. However, the external process attempting # to start is going to wait for the EndpointConnected message # before continuing, so ensure that message is *not* sent until # the local admin Transport has had time to bind and listen to the # local address, but also ensure that the message is *always* sent # even if the local admin could not start (caller will use # _verifyAdminRunning to ensure things are OK. transport = transportClass(endpointPrep) try: admin = adminClass(transport, adminAddr, capabilities, logDefs) except Exception: transport.scheduleTransmit( None, TransmitIntent(addrOfStarter, EndpointConnected(0))) raise # Send of EndpointConnected is deferred until the logger is setup. See MultiProcReplicator.h_LoggerConnected below. admin.addrOfStarter = addrOfStarter setProcName(adminClass.__name__, admin.transport.myAddress) # Generate the "placeholder" loggerAddr directly instead of going # through the AddressManager because the logger is not managed as # a normal child. loggerAddr = ActorAddress(ActorLocalAddress(transport.myAddress, -1, None)) admin.asLogger = None logAggregator = capabilities.get('Convention Address.IPv4', None) if logAggregator: try: logAggregator = transportClass.getAddressFromString(logAggregator) except Exception as ex: thesplog( 'Unable to adapt log aggregator address "%s" to a transport address: %s', logAggregator, ex, level=logging.WARNING) admin.asLogProc = startASLogger( loggerAddr, logDefs, transport, capabilities, logAggregator if logAggregator != admin.transport.myAddress else None) #closeUnusedFiles(transport) admin.run()
def _startLogger(transportClass, transport, admin, capabilities, logDefs, concurrency_context): # Generate the "placeholder" loggerAddr directly instead of going # through the AddressManager because the logger is not managed as # a normal child. loggerAddr = ActorAddress(ActorLocalAddress(transport.myAddress, -1, None)) admin.asLogger = None logAggregator = capabilities.get('Convention Address.IPv4', None) if logAggregator: try: logAggregator = transportClass.getAddressFromString(logAggregator) except Exception as ex: thesplog( 'Unable to adapt log aggregator address "%s" to a transport address: %s', logAggregator, ex, level=logging.WARNING) admin.asLogProc = startASLogger( loggerAddr, logDefs, transport, capabilities, logAggregator if logAggregator != admin.transport.myAddress else None, concurrency_context)
def testGetValidLocalAddress(self): am = ActorAddressManager(None, "I am me") addr = ActorAddress(ActorLocalAddress('I am me', 12, am)) assert isinstance(addr.addressDetails, ActorLocalAddress)
def testInstanceID(self): assert 5 == ActorLocalAddress(ActorAddress(id(self)), 5, None).addressInstanceNum
def testStringForm(self): assert '' != str(ActorLocalAddress(ActorAddress(id(self)), 0, None))
def testEqualityFailsIfDifferentInstanceNums(self): genAddr = ActorAddress(id(self)) addr1 = ActorLocalAddress(genAddr, 0, None) addr2 = ActorLocalAddress(genAddr, 1, None) assert addr1 != addr2
def testEquality(self): genAddr = ActorAddress(id(self)) addr1 = ActorLocalAddress(genAddr, 0, None) addr2 = ActorLocalAddress(genAddr, 0, None) assert addr1 == addr2
def testNonHashable(self): genAddr = ActorAddress(id(self)) lclAddr1 = ActorLocalAddress(genAddr, 0, None) lclAddr2 = ActorLocalAddress(genAddr, 1, None) raises(TypeError, hash, lclAddr1) raises(TypeError, hash, lclAddr2)
def testCreate(self): genAddr = ActorAddress(id(self)) addr = ActorLocalAddress(genAddr, 0, None) # No exception thrown assert True
def testGetValidLocalAddress(self): addr = ActorAddress(ActorLocalAddress(self.myAddress, 12, self.am)) self.assertIsInstance(addr.addressDetails, ActorLocalAddress)
def testInstanceID(self): self.assertEqual( 5, ActorLocalAddress(ActorAddress(id(self)), 5, None).addressInstanceNum)
def testStringForm(self): self.assertNotEqual( '', str(ActorLocalAddress(ActorAddress(id(self)), 0, None)))
def testEquality(self): genAddr = ActorAddress(id(self)) addr1 = ActorLocalAddress(genAddr, 0, None) addr2 = ActorLocalAddress(genAddr, 0, None) self.assertEqual(addr1, addr2)
def testUniqueHash(self): genAddr = ActorAddress(id(self)) addrs = [ActorLocalAddress(genAddr, N, None) for N in range(32)] hashes = set([hash(A) for A in addrs]) self.assertEqual(len(addrs), len(hashes))