Package paramiko :: Class SubsystemHandler |
[frames] | no frames]

# Class SubsystemHandler

source code

            object --+
                     |
    threading._Verbose --+
                         |
          threading.Thread --+
                             |
                            SubsystemHandler

Known Subclasses:
  - SFTPServer

Handler for a subsytem in server mode. If you create a subclass of this class and pass it to Transport.set_subsystem_handler, an object of this class will be created for each request for this subsystem. Each new object will be executed within its own new thread by calling start_subsystem. When that method completes, the channel is closed.

For example, if you made a subclass `MP3Handler` and registered it as the handler for subsystem `"mp3"`, then whenever a client has successfully authenticated and requests subsytem `"mp3"`, an object of class `MP3Handler` will be created, and start_subsystem will be called on it from a new thread.

Instance Methods
__init__(self, channel, name, server) Create a new handler for a channel. | source code
finish_subsystem(self) Perform any cleanup at the end of a subsystem. | source code
ServerInterface |
get_server(self) Return the ServerInterface object associated with this channel and subsystem. | source code
start_subsystem(self, name, transport, channel) Process an ssh subsystem in server mode. | source code
Inherited from `threading.Thread`: `__repr__`, `getName`, `isAlive`, `isDaemon`, `is_alive`, `join`, `run`, `setDaemon`, `setName`, `start` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties
Inherited from `threading.Thread`: `daemon`, `ident`, `name` Inherited from `object`: `__class__`

Method Details

### __init__(self, channel, name, server) (Constructor) | source code
Create a new handler for a channel. This is used by ServerInterface to start up a new handler when a channel requests this subsystem. You don't need to override this method, but if you do, be sure to pass the `channel` and `name` parameters through to the original `__init__` method here. Parameters: `channel` (Channel) - the channel associated with this subsystem request. `name` (str) - name of the requested subsystem. `server` (ServerInterface) - the server object for the session that started this subsystem Overrides: object.__init__

### finish_subsystem(self) | source code
Perform any cleanup at the end of a subsystem. The default implementation just closes the channel. Since: 1.1

### start_subsystem(self, name, transport, channel) | source code
Process an ssh subsystem in server mode. This method is called on a new object (and in a new thread) for each subsystem request. It is assumed that all subsystem logic will take place here, and when the subsystem is finished, this method will return. After this method returns, the channel is closed. The combination of `transport` and `channel` are unique; this handler corresponds to exactly one Channel on one Transport. Parameters: `name` (str) - name of the requested subsystem. `transport` (Transport) - the server-mode Transport. `channel` (Channel) - the channel associated with this subsystem request. Note: It is the responsibility of this method to exit if the underlying Transport is closed. This can be done by checking Transport.is_active or noticing an EOF on the Channel. If this method loops forever without checking for this case, your python interpreter may refuse to exit because this thread will still be running.