×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    61

    urllib.urlopen never returns

    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.

  2. #2
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: urllib.urlopen never returns

    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.

  3. #3
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    61

    Re: urllib.urlopen never returns

    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 07:53.

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: urllib.urlopen never returns

    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

  5. #5
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    61

    Post Re: urllib.urlopen never returns

    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.

  6. #6
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    61

    Re: urllib.urlopen never returns

    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.

Similar Threads

  1. OBEX/Bluetooth: getReceivedHeaders() returns null
    By schoenke in forum Mobile Java General
    Replies: 5
    Last Post: 2009-01-30, 16:18
  2. Publish&Subscribe problem: RProperty:Set returns KErrPermissionDenied
    By mrtj in forum Symbian Signed Support, Application Packaging and Distribution and Security
    Replies: 8
    Last Post: 2008-08-05, 00:43
  3. ExampleClientEngine ...
    By GeKI in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2005-12-16, 07:12
  4. Personal
    By JSmith77 in forum PersonalJava
    Replies: 4
    Last Post: 2003-07-30, 12:52
  5. AT Command: Nokia 6310i return “Nokia 6310i”, and others returns “Nokia 6310”
    By basti111 in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2003-07-27, 10:31

Posting Permissions

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