[Twisted-Python] help! - listenTCP failing

Jp Calderone exarkun at intarweb.us
Wed Mar 26 20:54:48 EST 2003

On Wed, Mar 26, 2003 at 04:32:11PM +1200, David McNab wrote:
> Hi,
> I'm building an app that will need the ability to start and stop
> protocol servers dynamically.
> As part of figuring this out, I've added an ApplicationService to the
> app, and within ApplicationService.startService(), I'm calling
> self.get_application.listenTCP(portnum, myprotocol).
> This is having no visible effect, since the port is not getting opened.
> I tried, within startService(), calling reactor.listenTCP() instead.
> This starts up the protocol and opens the port just fine, but when I
> later call app.unlistenTCP(port) to shut down the protocol, I get the
> exception (see below).
> What am I doing wrong?
> What's the best and simplest way to dynamically start and stop server
> protocols at runtime()?

  It seems as though reactor.listenTCP() is never being invoked.  The
traceback you got below is a result of this.  I've fixed it in CVS so that
it raises twisted.internet.error.NotListeningError now, instead of a
confusing UnboundLocalError.

  Why reactor.listenTCP() isn't being invoked is unclear.  You might try
adding some debug prints to the critical portions of the code, or stepping
through it with pdb.

  If you are still stuck after some attempts, post a little code (keyword:
little) that demonstrates the problem, so a developer can easily duplicate
and then fix it.


"There is no reason for any individual to have a computer in their
                -- Ken Olson, President of DEC, World Future Society
                   Convention, 1977
 up 6 days, 21:59, 4 users, load average: 0.52, 0.41, 0.19

More information about the Twisted-Python mailing list