[Twisted-Python] Re: Debugging client programs

John Goerzen jgoerzen at complete.org
Wed Jul 30 17:30:29 EDT 2003

Bob Ippolito <bob at redivi.com> writes:

>> What's worse, the application HOWTO also doesn't show how to choose
>> which reactor one is using, which is going to be a critical issue for
>> me.  I have all these things solved outside the twistd/Application
>> framework, but am not sure how to do it inside that framework.
> twistd does this when you start the tap.. man twistd

That's not what I need; I need to be able to choose it in my
program.  It would be a step backwards in usability to force people to
specify this on the command line when the system can detect it
automatically now.

As an example, the app might do something roughly like this:

 1. Am I running in X?  If yes, use wxPython; otherwise:
 2. Are stdin and stdout TTYs?  If yes, use curses; otherwise:
 3. Is stdin a TTY?  If yes, use the TTY interface; otherwise:
 4. Use Noninteractive.

twistd -r does not have the expressivity necessary to convey that
idea, nor does it have the capability of handling it based on a
configuration file.  Also, according to the --help, it also does not
have the capability to use the "add-on" reactors necessary for things
like wxPython.

> make a shell script called offlineimap that runs twistd
> offlineimap.tap instead of python.

I wouldn't be asking if the answer was that obvious!

It's not quite that easy either, because now I have to worry about
where twistd is installed on their system (a detail that setup.py
doesn't take care of for me), making sure I get the one for the
version of Python I want, etc.  This may involve prompting them for it
at install time, and worse, system changes could render OfflineIMAP

As an example, on Debian you can get /usr/bin/twistd2.3 and
/usr/bin/twistd2.2.  /usr/bin/twistd will end up being a symlink to
one or the other.  Now, say I'm writing a cross-platform installer and
I want Python 2.3 or above.  I find a twistd on my path -- maybe it's
what I want, maybe not.  Maybe the one I want isn't on the path.
Maybe it's in /opt/python2.3/bin/twistd or something like that.

If I can stick to importing bits from my plain Python program, all
those problems go away, since the administrator can just run setup.py
under the Python installation that's correct, and there it is.

More information about the Twisted-Python mailing list