hi again!:)

when i use urllib.urlretreive(somthing,local_somthing)

it crushs cpu,comp.


what can i do?

sorrry for my english

that is code:

class UPDATE(wx.Frame):
	def __init__(self):
		pass
	def Download(self):
		wx.Frame.__init__(self,None,-1,"Downloading",(0,0),wx.Size(500,500))
		panel=wx.Panel(self,-1)
		self.gauge = wx.Gauge(panel, 57, 100,(100,100), size=(250, 25))
		wx.StaticText(panel,-1,"downloading please wait..",pos=(0,0))

		self.Show()
		self.geturl("http://vpython.org/contents/download/VPython-Win-Py2.5-5.11.exe","hoho")
	def _reporthook(self,numblocks, blocksize, filesize, url=None):
		#print "reporthook(%s, %s, %s)" % (numblocks, blocksize, filesize)
		base = os.path.basename(url)
		#XXX Should handle possible filesize=-1.
		try:
			percent = min((numblocks*blocksize*100)/filesize, 100)
		except:
			percent = 100
		if numblocks != 0:
			sys.stdout.write("\b"*70)
		self.gauge.SetValue(percent)
		sys.stdout.write("%-66s%3d%%" % (base, percent))
	def geturl(self,url, dst):
		print "get url '%s' to '%s'" % (url, dst)
		if sys.stdout.isatty():
			urllib.urlretrieve(url, dst,
			lambda nb, bs, fs, url=url: self._reporthook(nb,bs,fs,url))
			sys.stdout.write('\n')
		else:
			urllib.urlretrieve(url, dst)

ok.


when i have GUI program and i am downloading file with urllib.urlretreive(url,local_url) or for example urllib2.urlopen(url) computer is clushing.


and GUI programm's main frame become Not Responding.


DO YOU UNDERSTAND?

sory my FoR My pOoR english.

computer is clushing.
and GUI programm's main frame become Not Responding.

Your computer is crashing?

Why don't you try to perform the urlretrieve section by itself in the interpreter. Maybe you've provided an invalid url or the wrong syntax.

YES, frame become NotResponding. (but it still downloads file) :)

"Why don't you try to perform the urlretrieve section by itself in the interpreter"
:D,listen i want to make high professional program :)

listen i want to make high professional program

You can add GUIs and pretty stuff later. When making a "high professional program" you must make sure it works well before it looks good.

Test the lines in the interpreter to figure out why it's taking so long.

The GUI frame does not respond because it's waiting for the function that you're calling to return. If you want the GUI updated while you're running a long/complex function you'll need to run it in a separate thread.

If you don't want to bother figuring out why your function is taking so long, you could use a Busy Cursor (hour glass) to indicate to the user that they should wait.

This question has already been answered. Start a new discussion instead.