Re: urllib.urlretrieve never returns???

Discussion in 'Python' started by Laszlo Nagy, Mar 19, 2012.

  1. Laszlo Nagy

    Laszlo Nagy Guest

    The pythonw.exe may not have the rights to access network resources.
    >> Have you set a default timeout for sockets?
    >>
    >> import socket
    >> socket.setdefaulttimeout(10) # 10 seconds

    I have added pythonw.exe to allowed exceptions. Disabled firewall
    completely. Set socket timeout to 10 seconds. Still nothing.

    urllib.urlretrieve does not return from call....

    any other ideas?
     
    Laszlo Nagy, Mar 19, 2012
    #1
    1. Advertising

  2. Laszlo Nagy

    Jon Clements Guest

    On Monday, 19 March 2012 19:32:03 UTC, Laszlo Nagy wrote:
    > The pythonw.exe may not have the rights to access network resources.
    > >> Have you set a default timeout for sockets?
    > >>
    > >> import socket
    > >> socket.setdefaulttimeout(10) # 10 seconds

    > I have added pythonw.exe to allowed exceptions. Disabled firewall
    > completely. Set socket timeout to 10 seconds. Still nothing.
    >
    > urllib.urlretrieve does not return from call....
    >
    > any other ideas?


    Maybe try using the reporthook option for urlretrieve, just to see if that does anything... If it constantly calls the hook or never calls it, that's one thing.

    Alternately, tcpdump/wireshark whatever, to see what the heck is going on with traffic - if any.

    hth

    Jon
     
    Jon Clements, Mar 19, 2012
    #2
    1. Advertising

  3. Laszlo Nagy

    Jon Clements Guest

    On Monday, 19 March 2012 19:32:03 UTC, Laszlo Nagy wrote:
    > The pythonw.exe may not have the rights to access network resources.
    > >> Have you set a default timeout for sockets?
    > >>
    > >> import socket
    > >> socket.setdefaulttimeout(10) # 10 seconds

    > I have added pythonw.exe to allowed exceptions. Disabled firewall
    > completely. Set socket timeout to 10 seconds. Still nothing.
    >
    > urllib.urlretrieve does not return from call....
    >
    > any other ideas?


    Maybe try using the reporthook option for urlretrieve, just to see if that does anything... If it constantly calls the hook or never calls it, that's one thing.

    Alternately, tcpdump/wireshark whatever, to see what the heck is going on with traffic - if any.

    hth

    Jon
     
    Jon Clements, Mar 19, 2012
    #3
  4. On Mon, 19 Mar 2012 20:32:03 +0100, Laszlo Nagy wrote:

    > The pythonw.exe may not have the rights to access network resources.
    >>> Have you set a default timeout for sockets?
    >>>
    >>> import socket
    >>> socket.setdefaulttimeout(10) # 10 seconds

    > I have added pythonw.exe to allowed exceptions. Disabled firewall
    > completely. Set socket timeout to 10 seconds. Still nothing.
    >
    > urllib.urlretrieve does not return from call....
    >
    > any other ideas?



    I'm sorry if I have missed something, or making suggestions you have
    already tried, but your original post describing the problem is missing
    from my news server.

    I gather you are running urlretrieve in a separate thread, inside a GUI?

    I have learned that whenever I have inexplicable behaviour in a function,
    I should check my assumptions. In this case, (1) are you sure you have
    the right urlretrieve, and (2) are you sure that your self.Log() method
    is working correctly? Just before the problematic call, do this:

    # was:
    fpath = urllib.urlretrieve(imgurl)[0]

    # becomes:
    print(urllib.__file__, urlretrieve)
    self.Log(urllib.__file__, urlretrieve)
    fpath = urllib.urlretrieve(imgurl)[0]


    and ensure that you haven't accidentally shadowed them with something
    unexpected. Does the output printed to the console match the output
    logged?

    What happens if you take the call to urlretrieve out of the thread and
    call it by hand? Run urllib.urlretrieve(imgurl) directly in the
    interactive interpreter. Does it still hang forever?

    When you say it "never" returns, do you mean *never* or do you mean "I
    gave up waiting after five minutes"? What happens if you leave it to run
    all day?

    Perhaps it returns after e.g. seven hours, which would be a mystery in
    itself, but at least you have perturbed the problem and have another data
    point. Maybe it isn't dead, just really slow. How big are the files you
    are trying to retrieve? Try retrieving a really small file. Then try
    retrieving a non-existent file.

    What happens if you call urlretrieve with a reporthook argument? Does it
    print anything?

    What happens if you try to browse to imgurl in your web browser? Are you
    sure the problem is with urlretrieve and not the source?


    --
    Steven
     
    Steven D'Aprano, Mar 19, 2012
    #4
  5. Laszlo Nagy

    Laszlo Nagy Guest

    Here you can find the example program and the original post.

    http://code.activestate.com/lists/python-list/617894/
    >
    > I gather you are running urlretrieve in a separate thread, inside a GUI?

    Yes.
    >
    > I have learned that whenever I have inexplicable behaviour in a function,
    > I should check my assumptions. In this case, (1) are you sure you have
    > the right urlretrieve, and (2) are you sure that your self.Log() method
    > is working correctly? Just before the problematic call, do this:
    >
    > # was:
    > fpath = urllib.urlretrieve(imgurl)[0]
    >
    > # becomes:
    > print(urllib.__file__, urlretrieve)
    > self.Log(urllib.__file__, urlretrieve)
    > fpath = urllib.urlretrieve(imgurl)[0]

    I called self.Log() after each line, and also from a general "except:"
    clause. Definitely, the line after urlretrieve is not executed, and no
    exception is raised. Number of threads goes up (visible from task manager).

    It is true that the program uses another module that uses the socket
    module and multiple threads. (These are written in pure python.)

    If I remove the other module, then there is no error, however it renders
    the application useless. If I start the program with a console (e.g.
    with python.exe instead of pythonw.exe) then it works. Looks like
    opening a console solves the problem, although nothing is ever printed
    on the console.
    > and ensure that you haven't accidentally shadowed them with something
    > unexpected. Does the output printed to the console match the output
    > logged?

    Well, this cannot be tested. If there is a console, then there is no
    problem.
    >
    > What happens if you take the call to urlretrieve out of the thread and
    > call it by hand?

    Then it works.
    > Run urllib.urlretrieve(imgurl) directly in the
    > interactive interpreter. Does it still hang forever?

    Then it works perfectly.
    >
    > When you say it "never" returns, do you mean *never* or do you mean "I
    > gave up waiting after five minutes"? What happens if you leave it to run
    > all day?

    I did not try that. But I have already set socket timeout to 10 seconds,
    and definitely it is not waiting for a response from the server.
    >
    > How big are the files you are trying to retrieve?

    34 KB
    > Try retrieving a really small file. Then try retrieving a non-existent file.

    Good point. I'll try to retrieve a nonexistent file when I get home. :)
    >
    > What happens if you call urlretrieve with a reporthook argument? Does it
    > print anything?

    I'll try this too. I'll also try using pycurl or the low level socket
    module instead.
    >
    > What happens if you try to browse to imgurl in your web browser? Are you
    > sure the problem is with urlretrieve and not the source?

    Yes.
     
    Laszlo Nagy, Mar 20, 2012
    #5
  6. Laszlo Nagy

    Laszlo Nagy Guest

    2012.03.20. 8:08 keltezéssel, Laszlo Nagy írta:
    > Here you can find the example program and the original post.
    >
    > http://code.activestate.com/lists/python-list/617894/
    >>
    >> I gather you are running urlretrieve in a separate thread, inside a GUI?

    > Yes.
    >>
    >> I have learned that whenever I have inexplicable behaviour in a
    >> function,
    >> I should check my assumptions. In this case, (1) are you sure you have
    >> the right urlretrieve, and (2) are you sure that your self.Log() method
    >> is working correctly? Just before the problematic call, do this:
    >>
    >> # was:
    >> fpath = urllib.urlretrieve(imgurl)[0]
    >>
    >> # becomes:
    >> print(urllib.__file__, urlretrieve)
    >> self.Log(urllib.__file__, urlretrieve)
    >> fpath = urllib.urlretrieve(imgurl)[0]

    > I called self.Log() after each line, and also from a general "except:"
    > clause. Definitely, the line after urlretrieve is not executed, and no
    > exception is raised. Number of threads goes up (visible from task
    > manager).
    >
    > It is true that the program uses another module that uses the socket
    > module and multiple threads. (These are written in pure python.)
    >
    > If I remove the other module, then there is no error, however it
    > renders the application useless. If I start the program with a console
    > (e.g. with python.exe instead of pythonw.exe) then it works. Looks
    > like opening a console solves the problem, although nothing is ever
    > printed on the console.
    >> and ensure that you haven't accidentally shadowed them with something
    >> unexpected. Does the output printed to the console match the output
    >> logged?

    > Well, this cannot be tested. If there is a console, then there is no
    > problem.
    >>
    >> What happens if you take the call to urlretrieve out of the thread and
    >> call it by hand?

    > Then it works.
    >> Run urllib.urlretrieve(imgurl) directly in the
    >> interactive interpreter. Does it still hang forever?

    > Then it works perfectly.
    >>
    >> When you say it "never" returns, do you mean *never* or do you mean "I
    >> gave up waiting after five minutes"? What happens if you leave it to run
    >> all day?

    > I did not try that. But I have already set socket timeout to 10
    > seconds, and definitely it is not waiting for a response from the server.
    >>
    >> How big are the files you are trying to retrieve?

    > 34 KB
    >> Try retrieving a really small file. Then try retrieving a
    >> non-existent file.

    > Good point. I'll try to retrieve a nonexistent file when I get home. :)


    Today I got a different error message printed on console (program
    started with python.exe)



    Unhandled exception in thread started by <bound method
    FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy of <Swig
    Object of type 'wxPanel *' at 0x4f85300>
    >>Unhandled exception in thread started by <bound method

    FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy of <Swig
    Object of type 'wxPanel *' at 0x4f85300>
    >>Unhandled exception in thread started by <bound method

    FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy of <Swig
    Object of type 'wxPanel *' at 0x4f85300>
    >>Unhandled exception in thread started by

    Traceback (most recent call last):

    Traceback (most recent call last):

    Traceback (most recent call last):
    <bound method FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy
    of <Swig Object of type 'wxPanel *' at 0x4f85300>
    >> File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917,

    in GetThumbnail
    File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917,
    in GetThumbnail
    File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917,
    in GetThumbnail

    sys.excepthook is missing
    Traceback (most recent call last):

    I have never seen a traceback like this before. I didn't install any
    excepthook myself.

    Program is using wxPython, socket, threads, threading, PIL.

    Here is something even more strange. If I click on the button three
    times, then absolutely nothing gets printed on stdout. However, if I
    close the program with file/exit (actually, calling
    wx.PySimpleApp.ExitMainLoop) then suddenly three stack traces are
    printed on stdout, all lines mixed up:

    Unhandled exception in thread started by <bound method
    FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy of <Swig
    Object of type 'wxPanel *' at 0x4fb530
    0>
    >>Unhandled exception in thread started by Unhandled exception in

    thread started by <bound method FrameLocEdit.GetThumbnail of
    <locedit.FrameLocEdit; proxy of <Swig Object of type 'wxPanel *' at
    0x4fb5300>
    >>Unhandled exception in thread started by Unhandled exception in

    thread started by <bound method FrameLocEdit.GetThumbnail of
    <locedit.FrameLocEdit; proxy of <Swig Object of type 'wxPanel *' at
    0x4fb5300>
    >>Traceback (most recent call last):<bound method

    FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy of <Swig
    Object of type 'wxPanel *' at 0x4fb5300>
    >>Traceback (most recent call last):<bound method

    FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy of <Swig
    Object of type 'wxPanel *' at 0x4fb5300>
    >>Traceback (most recent call last): File

    "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917, in
    GetThumbnail


    Traceback (most recent call last):

    File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917,
    in GetThumbnail
    Traceback (most recent call last):
    File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917,
    in GetThumbnail
    File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line
    917, in GetThumbnail
    File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line
    917, in GetThumbnail
    self.Log(traceback.format_exc())
    self.Log(traceback.format_exc())
    self.Log(traceback.format_exc())
    AttributeErrorself.Log(traceback.format_exc())
    AttributeErrorself.Log(traceback.format_exc())
    AttributeError: AttributeError: AttributeError:
    C:\Python\Projects\Warehouserclient_v3>


    And the last attributerror doesn't tell what attribute is missing.
    Probably I'll have to use a different library (pycurl, for example). But
    the error itself is getting more interesting.

    Also tried to use an invalid file (that should return with HTTP 404 not
    found) but the effect is exactly the same. Nothing is printed on stdout
    until I try to close the program (stop wxPython's mainloop). Then all
    previously threads throw an AttributeError and all of them print a stack
    trace (at the same time, lines mixed up).

    I'll be experimenting with pyCurl now.

    Thanks,

    Laszlo
     
    Laszlo Nagy, Mar 20, 2012
    #6
  7. Laszlo Nagy

    Laszlo Nagy Guest

    Re: urllib.urlretrieve never returns??? [SOLVED] - workaround


    > I'll be experimenting with pyCurl now.

    By replacing the GetThumbnail method with this brainless example, taken
    from the pyCurl demo:


    def GetThumbnail(self,imgurl):
    class Test:
    def __init__(self):
    self.contents = ''

    def body_callback(self, buf):
    self.contents = self.contents + buf

    self.Log("#1: "+repr(imgurl))
    try:
    t = Test()
    c = pycurl.Curl()
    c.setopt(c.URL, imgurl)
    c.setopt(c.WRITEFUNCTION, t.body_callback)
    self.Log("#2")
    c.perform()
    self.Log("#3")
    c.close()
    self.Log("#4")
    fpath = os.path.join(os.environ["TEMP"],"thumbnail.jpg")
    fout = open(fpath,"wb+")
    self.Log("#5: "+repr(fpath))
    try:
    fout.write(t.contents)
    finally:
    fout.close()
    self.Log("#6")
    except:
    self.Log(traceback.format_exc())
    return
    self.Log("#7")
    wx.CallAfter(self.imgProduct.SetPage,"""<html><body><img
    src="%s"></body></html>"""%fpath)
    self.Log("#8")

    Everything works perfectly, in all modes: console, no console, started
    directly and started in separate thread.

    So the problem with urllib must be. Maybe wxPython installs some except
    hooks, or who knows? If somebody feels up to it, I can start narrowing
    down the problem to the smallest possible application. But only if
    someone knows how to debug core code because I don't. Otherwise I'll
    just use pyCURL.

    Thank you for your help!

    Laszlo
     
    Laszlo Nagy, Mar 20, 2012
    #7
  8. > Today I got a different error message printed on console (program

    > started with python.exe)
    >
    >
    >
    > Unhandled exception in thread started by <bound method
    > FrameLocEdit.GetThumbnail of<locedit.FrameLocEdit; proxy of <Swig
    > Object of type 'wxPanel *' at 0x4f85300>

    > >>Unhandled exception in thread started by <bound method

    > FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy of<Swig
    > Object of type 'wxPanel *' at 0x4f85300>

    > >>Unhandled exception in thread started by <bound method

    > FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy of <Swig
    > Object of type 'wxPanel *' at 0x4f85300>

    > >>Unhandled exception in thread started by

    > Traceback (most recent call last):
    >
    > Traceback (most recent call last):
    >
    > Traceback (most recent call last):
    > <bound method FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy
    > of <Swig Object of type 'wxPanel *' at 0x4f85300>

    > >> File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917,

    > in GetThumbnail
    > File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917,
    > in GetThumbnail
    > File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917,
    > in GetThumbnail
    >
    > sys.excepthook is missing
    > Traceback (most recent call last):
    >
    > I have never seen a traceback like this before. I didn't install any
    > excepthook myself.
    >
    > Program is using wxPython, socket, threads, threading, PIL.
    >
    > Here is something even more strange. If I click on the button three
    > times, then absolutely nothing gets printed on stdout. However, if I
    > close the program with file/exit (actually, calling
    > wx.PySimpleApp.ExitMainLoop) then suddenly three stack traces are
    > printed on stdout, all lines mixed up:
    >


    Maybe in self.Log you should add a sys.stdout.flush and
    sys.stderr.flush(). I am not very familiar with stdin/out but
    maybe it will help.


    > Unhandled exception in thread started by <bound method
    > FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy of <Swig
    > Object of type 'wxPanel*' at 0x4fb530
    > 0>

    > >>Unhandled exception in thread started by Unhandled exception in

    > thread started by <bound method FrameLocEdit.GetThumbnail of
    > <locedit.FrameLocEdit; proxy of <Swig Object of type 'wxPanel *' at
    > 0x4fb5300>

    > >>Unhandled exception in thread started by Unhandled exception in

    > thread started by <bound method FrameLocEdit.GetThumbnail of
    > <locedit.FrameLocEdit; proxy of <Swig Object of type 'wxPanel *' at
    > 0x4fb5300>

    > >>Traceback (most recent call last):<bound method

    > FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy of <Swig
    > Object of type 'wxPanel *' at 0x4fb5300>

    > >>Traceback (most recent call last):<bound method

    > FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy of <Swig
    > Object of type 'wxPanel *' at 0x4fb5300>

    > >>Traceback (most recent call last): File

    > "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917, in
    > GetThumbnail
    >
    >
    > Traceback (most recent call last):
    >
    > File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917,
    > in GetThumbnail
    > Traceback (most recent call last):
    > File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917,
    > in GetThumbnail
    > File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line
    > 917, in GetThumbnail
    > File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line
    > 917, in GetThumbnail
    > self.Log(traceback.format_exc())
    > self.Log(traceback.format_exc())
    > self.Log(traceback.format_exc())
    > AttributeErrorself.Log(traceback.format_exc())
    > AttributeErrorself.Log(traceback.format_exc())
    > AttributeError: AttributeError: AttributeError:
    > C:\Python\Projects\Warehouserclient_v3>
    >
    >
    > And the lastattributerror doesn't tell what attribute is missing.
    > Probably I'll have to use a different library (pycurl, for example). But
    > the error itself is getting more interesting.


    This makes me think self does not have a .Log() or the traceback
    import is being overridden by something else that does not have
    .format_exc(). Or possibly this is in a function that does not have a
    self (maybe a typo in the function def?).


    >
    > Also tried to use an invalid file (that should return with HTTP 404 not
    > found) but the effect is exactly the same. Nothing is printed on stdout
    > until I try to close theprogram (stop wxPython's mainloop). Then all
    > previously threads throw an AttributeError and all of them print a stack
    > trace (at the same time, lines mixed up).
    >
    > I'll be experimenting with pyCurl now.



    Ramit


    Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
    712 Main Street | Houston, TX 77002
    work phone: 713 - 216 - 5423

    --

    This email is confidential and subject to important disclaimers and
    conditions including on offers for the purchase or sale of
    securities, accuracy and completeness of information, viruses,
    confidentiality, legal privilege, and legal entity disclaimers,
    available at http://www.jpmorgan.com/pages/disclosures/email.
     
    Prasad, Ramit, Mar 20, 2012
    #8
  9. RE: urllib.urlretrieve never returns??? [SOLVED] - workaround

    > Everything works perfectly, in all modes: console, no console, started

    > directly and started in separate thread.
    >
    > So the problem with urllib must be. Maybe wxPython installs some except
    > hooks,or who knows? If somebody feels up to it, I can start narrowing
    > down the problem to the smallest possible application. But only if
    > someone knows how to debug core code because I don't. Otherwise I'll
    >just use pyCURL.


    Have you tried urllib2? Have you tried a small program without using wx?

    To be honest, I doubt the problem is wx or urllib as they are both fairly
    broadly used. Try to come up with an example that is as minimal as possible.


    >>> imgurl = "http://www.shopzeus.hu/thumbnail.php?width=200&image=pyramid/PP0830.jpg"
    >>> urllib.urlretrieve( imgurl )

    ('c:\\[...]\\tmpkhixgt.php', <httplib.HTTPMessage instance at 0x0F2D75A8>)

    And I have Windows 7 64 with Python 2.6.6 (32 bit) and wx installed.

    Ramit


    Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
    712 Main Street | Houston, TX 77002
    work phone: 713 - 216 - 5423

    --


    This email is confidential and subject to important disclaimers and
    conditions including on offers for the purchase or sale of
    securities, accuracy and completeness of information, viruses,
    confidentiality, legal privilege, and legal entity disclaimers,
    available at http://www.jpmorgan.com/pages/disclosures/email.
     
    Prasad, Ramit, Mar 20, 2012
    #9
  10. On Tue, 20 Mar 2012 21:12:12 +0100, Laszlo Nagy <>
    declaimed the following in gmane.comp.python.general:


    > >>Unhandled exception in thread started by

    > Traceback (most recent call last):
    >
    > Traceback (most recent call last):
    >
    > Traceback (most recent call last):
    > <bound method FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy
    > of <Swig Object of type 'wxPanel *' at 0x4f85300>


    I'm not even going to attempt to figure out the traces -- the mere
    presence of THREE "Traceback (most..." lines in a row seems to be a
    clear indication that at least three failed threads are interleaving
    their output.

    At this point, I'd probably try to install a thread specific
    exception handler (even a wild card that catches all exceptions), which
    uses a logger instance to IDENTIFY which thread is involved, and adds
    that identification to the exception traceback data (or each thread logs
    to a separate file named by the thread ID).
    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Mar 20, 2012
    #10
  11. RE: urllib.urlretrieve never returns??? [SOLVED] - workaround


    > > Everything works perfectly, in all modes: console, no console, started
    > > directly and started in separate thread.
    > >
    > >So the problem with urllib must be. Maybe wxPython installs some except
    > > hooks, or who knows? If somebody feels up to it, I can start narrowing
    > > down the problem to the smallest possible application. Butonly if
    > > someone knows how to debug core code because I don't. Otherwise I'll
    > > just use pyCURL.

    >
    > Have you tried urllib2? Have you tried a small program without using wx?
    >
    > To behonest, I doubt the problem is wx or urllib as they are both fairly
    >broadly used. Try to come up with an example that is as minimal as
    > possible.
    >

    > >>> imgurl =

    > "http://www.shopzeus.hu/thumbnail.php?width=200&image=pyramid/PP0830.jpg"

    > >>> urllib.urlretrieve( imgurl )

    > ('c:\\[...]\\tmpkhixgt.php', <httplib.HTTPMessage instance at 0x0F2D75A8>)
    >
    > And I have Windows 7 64 with Python 2.6.6 (32 bit) and wx installed.
    >



    Your program on ActiveState worked for me which tells me that it might be
    a network or machine specific problem. You are missing an import which I
    mentioned in another post. Fixing that should tellwhat the error you are
    getting is; you would not be getting the AttributeError without some
    other error first.

    Ramit


    Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
    712 Main Street | Houston, TX 77002
    work phone: 713 - 216 - 5423

    --


    This email is confidential and subject to important disclaimers and
    conditions including on offers for thepurchase or sale of
    securities, accuracy and completeness of information, viruses,
    confidentiality, legal privilege, and legal entity disclaimers,
    available at http://www.jpmorgan.com/pages/disclosures/email.
     
    Prasad, Ramit, Mar 20, 2012
    #11
  12. > > Traceback (most recent call last):
    > >
    > > File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917,
    > > in GetThumbnail
    > > Traceback (most recent call last):
    > > File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917,
    > > in GetThumbnail
    > > File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line
    > > 917, in GetThumbnail
    > > File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line
    > > 917, in GetThumbnail
    > > self.Log(traceback.format_exc())
    > > self.Log(traceback.format_exc())
    > > self.Log(traceback.format_exc())
    > > AttributeErrorself.Log(traceback.format_exc())
    > > AttributeErrorself.Log(traceback.format_exc())
    > > AttributeError: AttributeError: AttributeError:
    > > C:\Python\Projects\Warehouserclient_v3>
    > >
    > >
    > > And the last attributerror doesn't tell what attribute is missing.
    > > Probably I'll have to use a different library (pycurl, for example). But
    > > the error itself is getting more interesting.

    >
    > This makes me think self does not have a .Log() or the traceback
    > import is being overridden by something else that does not have
    > .format_exc(). Or possibly this is in a function that does not have a
    > self (maybe a typo in the function def?).



    > Here you can find the example program and the original post.
    >
    > http://code.activestate.com/lists/python-list/617894/


    I just looked at your source file on ActiveState and noticed that
    you do not import traceback. That is why you are getting the
    AttributeError. Now you should be getting a much better error
    once you import it :)



    Ramit


    Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
    712 Main Street | Houston, TX 77002
    work phone: 713 - 216 - 5423

    --


    > -----Original Message-----
    > From: python-list-bounces+ramit.prasad=
    > [mailto:python-list-bounces+ramit.prasad=] On Behalf
    > Of Prasad, Ramit
    > Sent: Tuesday, March 20, 2012 3:52 PM
    > To:
    > Subject: RE: urllib.urlretrieve never returns???
    >
    > > Today I got a different error message printed on console (program
    > > started with python.exe)
    > >
    > >
    > >
    > > Unhandled exception in thread started by <bound method
    > > FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy of <Swig
    > > Object of type 'wxPanel *' at 0x4f85300>
    > > >>Unhandled exception in thread started by <bound method

    > > FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy of <Swig
    > > Object of type 'wxPanel *' at 0x4f85300>
    > > >>Unhandled exception in thread started by <bound method

    > > FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy of <Swig
    > > Object of type 'wxPanel *' at 0x4f85300>
    > > >>Unhandled exception in thread started by

    > > Traceback (most recent call last):
    > >
    > > Traceback (most recent call last):
    > >
    > > Traceback (most recent call last):
    > > <bound method FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy
    > > of <Swig Object of type 'wxPanel *' at 0x4f85300>
    > > >> File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917,

    > > in GetThumbnail
    > > File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917,
    > > in GetThumbnail
    > > File "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917,
    > > in GetThumbnail
    > >
    > > sys.excepthook is missing
    > > Traceback (most recent call last):
    > >
    > > I have never seen a traceback like this before. I didn't install any
    > > excepthook myself.
    > >
    > > Program is using wxPython, socket, threads, threading, PIL.
    > >
    > > Here is something even more strange. If I click on the button three
    > > times, then absolutely nothing gets printed on stdout. However, if I
    > > close the program with file/exit (actually, calling
    > > wx.PySimpleApp.ExitMainLoop) then suddenly three stack traces are
    > > printed on stdout, all lines mixed up:
    > >

    >
    > Maybe in self.Log you should add a sys.stdout.flush and
    > sys.stderr.flush(). I am not very familiar with stdin/out but
    > maybe it will help.
    >
    > > Unhandled exception in thread started by <bound method
    > > FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy of <Swig
    > > Object of type 'wxPanel *' at 0x4fb530
    > > 0>
    > > >>Unhandled exception in thread started by Unhandled exception in

    > > thread started by <bound method FrameLocEdit.GetThumbnail of
    > > <locedit.FrameLocEdit; proxy of <Swig Object of type 'wxPanel *' at
    > > 0x4fb5300>
    > > >>Unhandled exception in thread started by Unhandled exception in

    > > thread started by <bound method FrameLocEdit.GetThumbnail of
    > > <locedit.FrameLocEdit; proxy of <Swig Object of type 'wxPanel *' at
    > > 0x4fb5300>
    > > >>Traceback (most recent call last):<bound method

    > > FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy of <Swig
    > > Object of type 'wxPanel *' at 0x4fb5300>
    > > >>Traceback (most recent call last):<bound method

    > > FrameLocEdit.GetThumbnail of <locedit.FrameLocEdit; proxy of <Swig
    > > Object of type 'wxPanel *' at 0x4fb5300>
    > > >>Traceback (most recent call last): File

    > > "C:\Python\Projects\Warehouserclient_v3\locedit.py", line 917, in
    > > GetThumbnail
    > >
    > >

    >
    > >
    > > Also tried to use an invalid file (that should return with HTTP 404 not
    > > found) but the effect is exactly the same. Nothing is printed on stdout
    > > until I try to close the program (stop wxPython's mainloop). Then all
    > > previously threads throw an AttributeError and all of them print a stack
    > > trace (at the same time, lines mixed up).
    > >
    > > I'll be experimenting with pyCurl now.

    >
    >
    > Ramit
    >
    >
    > Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
    > 712 Main Street | Houston, TX 77002
    > work phone: 713 - 216 - 5423
    >
    > --
    >
    > This email is confidential and subject to important disclaimers and
    > conditions including on offers for the purchase or sale of
    > securities, accuracy and completeness of information, viruses,
    > confidentiality, legal privilege, and legal entity disclaimers,
    > available at http://www.jpmorgan.com/pages/disclosures/email.
    > --
    > http://mail.python.org/mailman/listinfo/python-list
     
    Prasad, Ramit, Mar 20, 2012
    #12
  13. Laszlo Nagy

    Laszlo Nagy Guest

    On 2012-03-20 22:26, Prasad, Ramit wrote:
    > I just looked at your source file on ActiveState and noticed that
    > you do not import traceback. That is why you are getting the
    > AttributeError. Now you should be getting a much better error
    > once you import it:)

    Nope. That would result in a NameError. After adding "import traceback",
    I still get several AttributeError messages. The traceback should
    contain the exact line number, and a description about what object is
    missing what attribute anyway. My code is pure Python, and under no
    circumstances should it be able to start a blocked call for a system
    library function.
     
    Laszlo Nagy, Mar 21, 2012
    #13
  14. > > I just looked at your source file on ActiveState and noticed that

    > > you do not import traceback. That is why you are getting the
    > >AttributeError. Now you should be getting a much better error
    > > once you import it:)

    > Nope. That would result in a NameError. After adding "import traceback",
    > I still get several AttributeError messages. The traceback should
    > contain the exact line number, and a description about what object is
    > missing what attribute anyway. My code is pure Python, and under no
    > circumstances should it be able to start a blocked call for a system
    > library function.


    Your code works for me, so the problem should be your system
    and/or network. Try a different Python version? I tested using 2.6.6.
    Also, check your proxy or firewall. If you are using Python 2.x
    try using urllib2.

    Ramit


    Ramit Prasad | JPMorganChase Investment Bank | Currencies Technology
    712 Main Street | Houston, TX 77002
    work phone: 713 - 216 - 5423

    This email is confidential and subject to important disclaimers and
    conditions including on offers for the purchase or sale of
    securities, accuracy and completeness of information, viruses,
    confidentiality, legal privilege, andlegal entity disclaimers,
    available at http://www.jpmorgan.com/pages/disclosures/email.
     
    Prasad, Ramit, Mar 22, 2012
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sam Sungshik Kong

    urllib.urlretrieve error

    Sam Sungshik Kong, May 23, 2004, in forum: Python
    Replies:
    2
    Views:
    611
    Sam Sungshik Kong
    May 24, 2004
  2. ralobao

    Problem with urllib.urlretrieve

    ralobao, Jun 12, 2004, in forum: Python
    Replies:
    1
    Views:
    811
    fishboy
    Jun 12, 2004
  3. Kingsley

    urllib (in thread) never returns

    Kingsley, Jul 17, 2006, in forum: Python
    Replies:
    1
    Views:
    312
    Rene Pijlman
    Jul 18, 2006
  4. Abandoned

    configure urllib.urlretrieve timeout

    Abandoned, Oct 7, 2007, in forum: Python
    Replies:
    1
    Views:
    626
    Steve Holden
    Oct 7, 2007
  5. samwyse
    Replies:
    3
    Views:
    2,103
Loading...

Share This Page