[Twisted-Python] How to improve response time of twisted.web?

Drew Smathers drew.smathers at gmail.com
Thu Mar 27 12:26:10 EDT 2008


On Wed, Mar 26, 2008 at 10:53 PM, Pavel <pbastov at gmail.com> wrote:
> Yes, I wrote my own resource. Looks like this:
>
>  class MyRoot(Resource):
>         def getChild(self, name, request):
>                 if "" == name:
>                         return self
>                 return Resource
>
>         def render_GET(self, request):
>                 path = "/path/to/file"
>                 f = open(path)
>                 content = f.read()
>                 f.close()
>                 return content
>
>

You should probably be using twisted.web.static.File for a better
comparison of static file serving performance. In fact, you could do
this without writing any code at all:

$ twistd web --path=<dir>


Cheers,
-- 
\\\\\/\"/\\\\\\\\\\\
\\\\/ // //\/\\\\\\\
\\\/ \\// /\ \/\\\\
\\/ /\/ / /\/ /\ \\\
\/ / /\/ /\ /\\\ \\
/ /\\\ /\\\ \\\\\/\
\/\\\\\/\\\\\/\\\\\\
 d.p.s




More information about the Twisted-Python mailing list