class_docstr: a ssh-tunnel launcher for parallel and distributed computing.
class_docstr_tok: ["a","ssh-tunnel","launcher","for","parallel","and","distributed","computing","."]
docstr: establish a secure shell tunnel between local and remote host
  
  Input:
      host     -- remote hostname  [user@host:path is also valid]
      port     -- remote port number
  
  Additional Input:
      through  -- 'tunnel-through' hostname  [default = None]
          
docstr_tok: ["establish","a","secure","shell","tunnel","between","local","and","remote","host","Input",":","host","--","remote","hostname","[","user","@","host",":","path","is","also","valid","]","port","--","remote","port","number","Additional","Input",":","through","--","'tunnel-through","'","hostname","[","default","=","None","]"]
code: def connect(self, host, port=None, through=None):
      """establish a secure shell tunnel between local and remote host
  
      Input:
          host     -- remote hostname  [user@host:path is also valid]
          port     -- remote port number
  
      Additional Input:
          through  -- 'tunnel-through' hostname  [default = None]
      """
      from pathos.portpicker import portnumber
  
      if port is None:
          from pathos.core import randomport
  
          port = randomport(through) if through else randomport(host)
  
      pick = portnumber(self.MINPORT, self.MAXPORT)
      while True:
          localport = pick()
          if localport < 0:
              raise TunnelException("No available local port")
          # print('Trying port %d...' % localport)
  
          try:
              self._connect(localport, host, port, through=through)
              # print('SSH tunnel %d:%s:%d' % (localport, host, port))
          except TunnelException as e:  # breaks 2.5 compatibility
              if e.args[0] == "bind":
                  self.disconnect()
                  continue
              else:
                  self.__disconnect()
                  raise TunnelException("Connection failed")
  
          self.connected = True
          return localport
  
file_path: pathos/pathos/secure/tunnel.py
imports: import os
  import signal
  import random
  import string
  from pathos.secure import Pipe
label_desc: Use image node_id 1 for calling the Tunnel obj's underlying member method code with example usage: obj.connect(host, port, through) and returns: localport