Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #21905 > unrolled thread
| Started by | Laszlo Nagy <gandalf@shopzeus.com> |
|---|---|
| First post | 2012-03-19 20:32 +0100 |
| Last post | 2012-03-22 15:25 +0000 |
| Articles | 14 — 5 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: urllib.urlretrieve never returns??? Laszlo Nagy <gandalf@shopzeus.com> - 2012-03-19 20:32 +0100
Re: urllib.urlretrieve never returns??? Jon Clements <joncle@googlemail.com> - 2012-03-19 16:04 -0700
Re: urllib.urlretrieve never returns??? Jon Clements <joncle@googlemail.com> - 2012-03-19 16:04 -0700
Re: urllib.urlretrieve never returns??? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-03-19 23:26 +0000
Re: urllib.urlretrieve never returns??? Laszlo Nagy <gandalf@shopzeus.com> - 2012-03-20 08:08 +0100
Re: urllib.urlretrieve never returns??? Laszlo Nagy <gandalf@shopzeus.com> - 2012-03-20 21:12 +0100
Re: urllib.urlretrieve never returns??? [SOLVED] - workaround Laszlo Nagy <gandalf@shopzeus.com> - 2012-03-20 21:42 +0100
RE: urllib.urlretrieve never returns??? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-20 20:52 +0000
Re: urllib.urlretrieve never returns??? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-03-20 17:14 -0400
RE: urllib.urlretrieve never returns??? [SOLVED] - workaround "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-20 21:25 +0000
RE: urllib.urlretrieve never returns??? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-20 21:26 +0000
RE: urllib.urlretrieve never returns??? [SOLVED] - workaround "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-20 21:01 +0000
Re: urllib.urlretrieve never returns??? Laszlo Nagy <gandalf@shopzeus.com> - 2012-03-21 13:38 +0100
RE: urllib.urlretrieve never returns??? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-22 15:25 +0000
| From | Laszlo Nagy <gandalf@shopzeus.com> |
|---|---|
| Date | 2012-03-19 20:32 +0100 |
| Subject | Re: urllib.urlretrieve never returns??? |
| Message-ID | <mailman.815.1332185597.3037.python-list@python.org> |
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?
[toc] | [next] | [standalone]
| From | Jon Clements <joncle@googlemail.com> |
|---|---|
| Date | 2012-03-19 16:04 -0700 |
| Message-ID | <mailman.817.1332198302.3037.python-list@python.org> |
| In reply to | #21905 |
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
[toc] | [prev] | [next] | [standalone]
| From | Jon Clements <joncle@googlemail.com> |
|---|---|
| Date | 2012-03-19 16:04 -0700 |
| Message-ID | <11279707.1159.1332198294121.JavaMail.geo-discussion-forums@vbfl9> |
| In reply to | #21905 |
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
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2012-03-19 23:26 +0000 |
| Message-ID | <4f67c09b$0$29981$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #21905 |
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
[toc] | [prev] | [next] | [standalone]
| From | Laszlo Nagy <gandalf@shopzeus.com> |
|---|---|
| Date | 2012-03-20 08:08 +0100 |
| Message-ID | <mailman.821.1332227299.3037.python-list@python.org> |
| In reply to | #21910 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Laszlo Nagy <gandalf@shopzeus.com> |
|---|---|
| Date | 2012-03-20 21:12 +0100 |
| Message-ID | <mailman.840.1332274347.3037.python-list@python.org> |
| In reply to | #21910 |
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
[toc] | [prev] | [next] | [standalone]
| From | Laszlo Nagy <gandalf@shopzeus.com> |
|---|---|
| Date | 2012-03-20 21:42 +0100 |
| Subject | Re: urllib.urlretrieve never returns??? [SOLVED] - workaround |
| Message-ID | <mailman.843.1332276159.3037.python-list@python.org> |
| In reply to | #21910 |
> 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
[toc] | [prev] | [next] | [standalone]
| From | "Prasad, Ramit" <ramit.prasad@jpmorgan.com> |
|---|---|
| Date | 2012-03-20 20:52 +0000 |
| Message-ID | <mailman.844.1332277337.3037.python-list@python.org> |
| In reply to | #21910 |
> 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 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?). > > 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.
[toc] | [prev] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2012-03-20 17:14 -0400 |
| Message-ID | <mailman.845.1332278055.3037.python-list@python.org> |
| In reply to | #21910 |
On Tue, 20 Mar 2012 21:12:12 +0100, Laszlo Nagy <gandalf@shopzeus.com>
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
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [next] | [standalone]
| From | "Prasad, Ramit" <ramit.prasad@jpmorgan.com> |
|---|---|
| Date | 2012-03-20 21:25 +0000 |
| Subject | RE: urllib.urlretrieve never returns??? [SOLVED] - workaround |
| Message-ID | <mailman.847.1332278736.3037.python-list@python.org> |
| In reply to | #21910 |
> > 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.
>
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 tell what 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 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.
[toc] | [prev] | [next] | [standalone]
| From | "Prasad, Ramit" <ramit.prasad@jpmorgan.com> |
|---|---|
| Date | 2012-03-20 21:26 +0000 |
| Message-ID | <mailman.848.1332278837.3037.python-list@python.org> |
| In reply to | #21910 |
> > 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=jpmorgan.com@python.org > [mailto:python-list-bounces+ramit.prasad=jpmorgan.com@python.org] On Behalf > Of Prasad, Ramit > Sent: Tuesday, March 20, 2012 3:52 PM > To: python-list@python.org > 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
[toc] | [prev] | [next] | [standalone]
| From | "Prasad, Ramit" <ramit.prasad@jpmorgan.com> |
|---|---|
| Date | 2012-03-20 21:01 +0000 |
| Subject | RE: urllib.urlretrieve never returns??? [SOLVED] - workaround |
| Message-ID | <mailman.849.1332278973.3037.python-list@python.org> |
| In reply to | #21910 |
> 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.
[toc] | [prev] | [next] | [standalone]
| From | Laszlo Nagy <gandalf@shopzeus.com> |
|---|---|
| Date | 2012-03-21 13:38 +0100 |
| Message-ID | <mailman.857.1332333501.3037.python-list@python.org> |
| In reply to | #21910 |
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.
[toc] | [prev] | [next] | [standalone]
| From | "Prasad, Ramit" <ramit.prasad@jpmorgan.com> |
|---|---|
| Date | 2012-03-22 15:25 +0000 |
| Message-ID | <mailman.893.1332429924.3037.python-list@python.org> |
| In reply to | #21910 |
> > 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 | 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.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web