Thread timeout

11 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.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages