Thread timeout

8 views
Skip to first unread message

Phyllipe Medeiros

unread,
Feb 12, 2012, 4:30:41 PM2/12/12
to mod...@googlegroups.com, django...@googlegroups.com
I have made this class:
"class Teste(Thread):
    def __init__(self):
        Thread.__init__(self)
    def run(self):
        try:
            print "Begin"
            from httplib2 import Http
            import time
            time.sleep(20)
            print "PASSED SLEEP"
            response, content = Http().request("http://www.spoj.pl")
            print "OUT"
except:
            print "EXCEPTION :("
"
Then I have a view that calls Teste().start(), the message that I receive on error log is only "BEGIN".
But if I do no use a thread, the "error log" will work correctly "Begin, PASSED SLEEP" and "OUT".
I think it is something related to Apache2/Mod_wsgi or even permissions in my system, because if run it with sudo using runserver it will work perfectly.
In my house it works perfectly too.



Graham Dumpleton

unread,
Feb 12, 2012, 5:37:08 PM2/12/12
to mod...@googlegroups.com, django...@googlegroups.com
On 13 February 2012 08:30, Phyllipe Medeiros <phylli...@gmail.com> wrote:
> I have made this class:
> "class Teste(Thread):
>     def __init__(self):
>         Thread.__init__(self)
>     def run(self):
>         try:
>             print "Begin"
>             from httplib2 import Http
>             import time
>             time.sleep(20)
>             print "PASSED SLEEP"
>             response, content = Http().request("http://www.spoj.pl")
>             print "OUT"
> except:

Within the except add:

import sys
import traceback
traceback.print_exception(*sys.exc_info())

If you aren't going to re raise the exception, then how else are you
going to know what the actual problem is.

Graham

>             print "EXCEPTION :("
> "
> Then I have a view that calls Teste().start(), the message that I receive on
> error log is only "BEGIN".
> But if I do no use a thread, the "error log" will work correctly "Begin,
> PASSED SLEEP" and "OUT".
> I think it is something related to Apache2/Mod_wsgi or even permissions in
> my system, because if run it with sudo using runserver it will work
> perfectly.
> In my house it works perfectly too.
>
>
>

> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To post to this group, send email to mod...@googlegroups.com.
> To unsubscribe from this group, send email to
> modwsgi+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/modwsgi?hl=en.

Phyllipe Medeiros

unread,
Feb 12, 2012, 5:43:35 PM2/12/12
to mod...@googlegroups.com
The "except" part is not being executed, I do not get "Exception :(" and now I've putted this  import sys
 import traceback
 traceback.print_exception(*sys.exc_info())
But nothing has appeared on error log ;/

Phyllipe Medeiros

unread,
Feb 12, 2012, 6:44:53 PM2/12/12
to mod...@googlegroups.com
I've changed my apache2.conf:
Timeout was 15
Now I've changed to 250 and it is working now!

Graham Dumpleton

unread,
Feb 12, 2012, 8:33:16 PM2/12/12
to mod...@googlegroups.com
The default is 300. Why had you changed it anyway?

Graham

Phyllipe Medeiros

unread,
Feb 12, 2012, 8:36:35 PM2/12/12
to mod...@googlegroups.com
Ooops, sorry my mistake.
I've changed KeepAliveTimeOut to 250
Timeout is 300 =)
I've changed KeepAliveTimeOut and it worked, but in my computer KeepAlive... is 15 and works ;/

Graham Dumpleton

unread,
Feb 12, 2012, 9:34:49 PM2/12/12
to mod...@googlegroups.com
The KeepAliveTimeout default for standard Apache distribution is
usually 5. Put it to 250 on a public site with constant traffic and
you will very quickly likely lock up your site as you run out of
process/threads for maintaining the open connections to your browser.

Unless you know what all these settings do, you should be leaving them
as the defaults that Apache supplies in its configuration.

Graham

Reply all
Reply to author
Forward
0 new messages