[Twisted-Python] Another tcp.Client question

Glyph Lefkowitz glyph at twistedmatrix.com
Sun Sep 2 18:36:10 EDT 2001

On Mon, Sep 03, 2001 at 12:25:08AM +0200, Benjamin Bruheim wrote:
> > A quick glance over twisted/protocols/ftp.py indicates to me that nowhere is
> > loseConnection actually called on a Port.  Where is it supposed to be?  (And
> > what's up with storing it as DTPLoseConnection?  I never see that being
> > used...)  On my machine, at least, calling loseConnection on a Port *would*
> > indeed cause it to blow up :)
> No, it was just a test. Calling DTPLoseConnection actually would remove the
> server since it would call Port.loseConnection, though trigging some unwanted
> effects.

Is the dtpPort supposed to accept more than one connection?  I was under the
impression that anywhere one would bind port 0 would be a place that one or
only a few connections would be accepted.

> I don't remember the details so don't mind. :)

I am willing to bet that the unwanted effects you saw were tracebacks on the
code we're talking about :)

> The port is created in FTP.createPassiveServer, and loseConnection is called
> in DTP.finishGet (or DTP.finish, I don't think I've commited the namechange).

You have committed it.  Still: I see no loseConnection being called on a
*Port*, only on a *Server*, which is a connection that got accepted from a

> Are you sure you get a (Port n closed) on the log? Here they are all shown
> (successive) first when I shut down. 

That's as a result of seeing connectionLost, loseConnection is never
necessarily called.

> BTW, The point with my last reply was that I can't see that some of the code
> changed are ever run, and that makes it hard to test ;)

Yes, and my point is that, as far as I understand FTP, you *should* be
exercising that code.  I still don't understand why you're not.

                      ______      __   __  _____  _     _
                     |  ____ |      \_/   |_____] |_____|
                     |_____| |_____  |    |       |     |
                     @ t w i s t e d m a t r i x  . c o m

More information about the Twisted-Python mailing list