[Twisted-Python] Hep and Twisted (Was: Twisted-webserver hangs when serving big files)

Moshe Zadka m at moshez.org
Tue Jun 10 02:48:09 EDT 2003

On 10 Jun 2003, Abe Fettig <abe at fettig.net> wrote:

> This is a really natural fit for Hep and looks easy as pie to
> implement.  One question, though.  Say I run a server by creating a
> Factory and running application.listenTCP(myFactory, port).  What's the
> preferred way to access services from inside that Factory?

When the service creates the factory, it can set a .service on the

class FooService(app.ApplicationService):

    def makeFactory(self):
        f = protocol.Factory()
        f.service = self
        return f

service = FooService()
application.listenTCP(1000, service.makeFactory())

> The only variable that I think I'd want to maintain in the Application
> is the location of it's data directory.  That way when the app starts it
> knows where to look to find messages, user prefs, etc, and I can ditch
> the hep.ini file.

That's good.
In fact, .ini files should die, in favour of a service holding that
information. Then, it's easy to configure HEP either via mktap hep,
or manually

% cat hep.tpy
from twisted.internet import app
from hep import service

application = app.Application("HEP")
s = service.HEPService(datadir="blah/blah")
application.listenTCP(25, s.makeMailFactory())
application.listenTCP(80, s.makeWebFactory())
% twistd -y hep.tpy

[This is written to an assumed HEP API, which probably has nothing
currently to do with the HEP API, and possibly is not the correct
way at all...this is just to give you an idea of what kind of flexibility
is easily available, once you drink the kool-aid]

Moshe Zadka -- http://moshez.org/
Buffy: I don't like you hanging out with someone that... short.
Riley: Yeah, a lot of young people nowadays are experimenting with shortness.
Agile Programming Language -- http://www.python.org/

More information about the Twisted-Python mailing list