diff --git a/py/execnet/gateway.py b/py/execnet/gateway.py index b1ad35169..5b45c722e 100644 --- a/py/execnet/gateway.py +++ b/py/execnet/gateway.py @@ -31,12 +31,12 @@ debug = 0 # open('/tmp/execnet-debug-%d' % os.getpid() , 'wa') sysex = (KeyboardInterrupt, SystemExit) class Gateway(object): - num_worker_threads = 2 ThreadOut = ThreadOut + remoteaddress = "" def __init__(self, io, startcount=2, maxthreads=None): global registered_cleanup - self._execpool = WorkerPool() + self._execpool = WorkerPool(maxthreads=maxthreads) ## self.running = True self.io = io self._outgoing = Queue.Queue() @@ -50,7 +50,7 @@ class Gateway(object): sender = self.thread_sender) def __repr__(self): - addr = self._getremoteaddress() + addr = self.remoteaddress if addr: addr = '[%s]' % (addr,) else: @@ -67,9 +67,6 @@ class Gateway(object): return "<%s%s %s/%s (%s active channels)>" %( self.__class__.__name__, addr, r, s, i) - def _getremoteaddress(self): - return None - ## def _local_trystopexec(self): ## self._execpool.shutdown() diff --git a/py/execnet/register.py b/py/execnet/register.py index c2afbf1a2..b027f8c1c 100644 --- a/py/execnet/register.py +++ b/py/execnet/register.py @@ -136,9 +136,7 @@ class SocketGateway(InstallableGateway): sock.connect((host, port)) io = inputoutput.SocketIO(sock) super(SocketGateway, self).__init__(io=io) - - def _getremoteaddress(self): - return '%s:%d' % (self.host, self.port) + self.remoteaddress = '%s:%d' % (self.host, self.port) def remote_install(cls, gateway, hostport=None): """ return a connected socket gateway through the @@ -167,7 +165,7 @@ class SocketGateway(InstallableGateway): class SshGateway(PopenCmdGateway): def __init__(self, sshaddress, remotepython='python', identity=None): - self.sshaddress = sshaddress + self.remoteaddress = sshaddress remotecmd = '%s -u -c "exec input()"' % (remotepython,) cmdline = [sshaddress, remotecmd] # XXX Unix style quoting @@ -179,9 +177,6 @@ class SshGateway(PopenCmdGateway): cmdline.insert(0, cmd) super(SshGateway, self).__init__(' '.join(cmdline)) - def _getremoteaddress(self): - return self.sshaddress - class ExecGateway(PopenGateway): def remote_exec_sync_stdcapture(self, lines, callback): # hack: turn the content of the cell into diff --git a/py/execnet/rsync.py b/py/execnet/rsync.py index f9638a6df..ab1fa5f4b 100644 --- a/py/execnet/rsync.py +++ b/py/execnet/rsync.py @@ -110,7 +110,7 @@ class RSync(object): # sharing multiple copies of the file's data data = intern(data) print '%s <= %s' % ( - channel.gateway._getremoteaddress(), + channel.gateway.remoteaddress, modified_rel_path) channel.send(data) del data diff --git a/py/execnet/testing/test_gateway.py b/py/execnet/testing/test_gateway.py index de6690724..1ad33c0e2 100644 --- a/py/execnet/testing/test_gateway.py +++ b/py/execnet/testing/test_gateway.py @@ -62,8 +62,8 @@ class PopenGatewayTestSetup: def setup_class(cls): cls.gw = py.execnet.PopenGateway() -## def teardown_class(cls): -## cls.gw.exit() + def teardown_class(cls): + cls.gw.exit() class BasicRemoteExecution: def test_correct_setup(self): @@ -455,7 +455,7 @@ class TestSshGateway(BasicRemoteExecution): cls.gw = py.execnet.SshGateway(option.sshtarget) def test_sshaddress(self): - assert self.gw.sshaddress == option.sshtarget + assert self.gw.remoteaddress == option.sshtarget def test_failed_connexion(self): gw = py.execnet.SshGateway('nowhere.codespeak.net')