[Twisted-Python] Getting splitted data with SSHChannel.dataReceived

Jean-Paul Calderone exarkun at divmod.com
Thu Mar 23 13:40:46 EST 2006


On Thu, 23 Mar 2006 20:06:59 +0200, Mustafa Sakalsiz <mustafa at liqia.com> wrote:
>Hi,
>
>I am using twisted conch to execute a remote program (say ProgA) through 
>ssh. In ProgA, I print some datas and catch them in the dataReceived method 
>of SSHChannel.
>
>Sometimes, the data comes partially, like this
>
>ProgA                                    dataReceived
>------------                              --------------------------------
>prints TWISTED                    gets TWISTED  and appends it to TOTAL
>.
>.
>.
>prints TWISTED                    if len(TOTAL) is 1020 gets TWIS (gets at 
>most 1024)
>                                               => then gets TED (next time)
>
>I think there's a buffer of something else, so dataReceived couldn't get the 
>datas as they are printed.  They  are splitted if TOTAL reaches  1024. I am 
>looking for a solution to prevent getting splitted data.

If you want to treat your data as line-oriented, you should be using LineReceiver and overriding the lineReceived method.  The dataReceived method is always subject to this kind of fragmentation.

Jean-Paul




More information about the Twisted-Python mailing list