You Are Here:

Community: Developer Discussion Boards

#1 Old urllib.urlopen never returns - 2009-06-29, 20:17

Join Date: Mar 2003
Posts: 56
albgarse
Offline
Regular Contributor
Hi!

I'm developing an application that makes an http connection every minute. It seems to work fine, but when it's working for a while, it stop to make connections. In the app log, I can see that the function urllib.urlopen is called, but it never returns. There is not timeouts or exceptions, what seems very rare.

Any idea of what could be happening?

Best regards.
Reply With Quote

#2 Old Re: urllib.urlopen never returns - 2009-06-30, 02:51

Join Date: Nov 2007
Posts: 319
Location: Sertaozinho/Brazil
Send a message via MSN to marcelobarrosalmeida Send a message via Skype™ to marcelobarrosalmeida
marcelobarrosalmeida's Avatar
marcelobarrosalmeida
Offline
Forum Nokia Champion
Hi albgarse

Are you using PyS60 1.4.5 or PyS60 1.9.5 ? Even we do not have timeout option in urllib in 1.9.5 as well (I tested today), at least it is newer and probably more stable.


Marcelo Barros
Nokia E71, N800, N95 and XM 5800
http://www.croozeus.com
http://wordmobi.wordpress.com
http://jedizone.wordpress.com
Reply With Quote

#3 Old Re: urllib.urlopen never returns - 2009-06-30, 08:24

Join Date: Mar 2003
Posts: 56
albgarse
Offline
Regular Contributor
I'm working with 1.4.5. I'm going to try with 1.9.5.

EDIT:
Just tried, but my app won't start with the new runtime. I use some extensions that propably are no compatible.

Best regards.

Quote:
Originally Posted by marcelobarrosalmeida View Post
Hi albgarse

Are you using PyS60 1.4.5 or PyS60 1.9.5 ? Even we do not have timeout option in urllib in 1.9.5 as well (I tested today), at least it is newer and probably more stable.
Last edited by albgarse : 2009-06-30 at 08:53.
Reply With Quote

#4 Old Re: urllib.urlopen never returns - 2009-06-30, 09:58

Join Date: Feb 2008
Posts: 2,543
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Online
Forum Nokia Champion
Quote:
Originally Posted by albgarse View Post
I'm working with 1.4.5. I'm going to try with 1.9.5.

EDIT:
Just tried, but my app won't start with the new runtime. I use some extensions that propably are no compatible.

Best regards.
hello albgarse

ya all extensions are not working with 1.9.x releases so always make a note of that.

Regards


Gargi Das- http://gargidas.blogsot.com

Forum Nokia Python Wiki


Learn Python at http://mobapps.org/PyS60
Reply With Quote

#5 Old Post Re: urllib.urlopen never returns - 2009-06-30, 13:32

Join Date: Mar 2003
Posts: 56
albgarse
Offline
Regular Contributor
I found a possible solution here:
http://mail.python.org/pipermail/pyt...il/001307.html

It uses a code like this to force a timeout:
Code:
import signal

def alarmHandler(*args):
    """
    signal handler for SIGALRM, just raise an exception
    """
    raise "TimeOut"

....
    signal.signal(signal.SIGALRM, alarmHandler)
    try:
        # set timeout
        signal.alarm(120)

        #... urllib.urlretrieve pages

    except "TimeOut":
        # some error handling
    signal.alarm(0)
But it seems like the signal module is not present in py60.

I'm trying with e32.Ao_Timer()

Code:
def timeoutHandler():
    raise IOError, "Timeout error"
    
try:
    timer = e32.Ao_timer()
    timer.after(120,timeoutHandler)
    # comms. function here...
    timer.cancel()
except:
    # capture exception here...
The timer calls timeoutHandler, and the exception is raised (I can see it in the python console), but not captured by the try. Seems like it's launched in a different thread.
is there a solution to raise the exception to the thread from where the timer was triggered?

regards.
Reply With Quote

#6 Old Re: urllib.urlopen never returns - 2009-07-02, 09:00

Join Date: Mar 2003
Posts: 56
albgarse
Offline
Regular Contributor
I've been making some more tryings. It's a bit rare.
The phone opens a communication every minute with urllib.urlopen() and it works fine. Some hours after, one communication fails. it don't return from urlopen() and every call to urlopen() after this fails in the same way.
There is not any memory problem. The free ram don't go down.

Is urlopen() function reentrant? so if one fails, could I make another urlopen() from other thread (have two urlopen() working at the same time)?
It seems a little rare that once one communication fails, every communication after fails too.

Regards.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
OBEX/Bluetooth: getReceivedHeaders() returns null schoenke Mobile Java General 5 2009-01-30 17:18
Publish&Subscribe problem: RProperty:Set returns KErrPermissionDenied mrtj Installation, Certification and Security 8 2008-08-05 01:43
ExampleClientEngine ... GeKI Symbian Networking & Messaging 2 2005-12-16 08:12
Personal JSmith77 PersonalJava 4 2003-07-30 13:52
AT Command: Nokia 6310i return “Nokia 6310i”, and others returns “Nokia 6310” basti111 PC Suite API and PC Connectivity SDK 1 2003-07-27 11:31

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia