I got a problem with httpClient. I took my code from the manual, but I used downloadToFile.

After downloading file from a http server, they are locked by a processus, and when I try to execute an .exe, I got an error message, because the file is locked by another processus.

At my mind, when I download the file via the channel, it locks the file, and not free it. I don’t know how to close the channel, or what I need to free my file:

	if self.http==None:
							self.http = HTTPClient() = self.http.makeChannel(True)'http://localhost/updater/ressources/' + self.files[self.iterFile].replace("\\","/")))
							ff=Filename(self.convDirectory + "/" + self.files[self.iterFile].replace("\\","/"))

if not
									print "Error downloading file." + + str(
									return task.done
									fileHandle = open ( "./update.txt", 'a+' ) 
									fileHandle.write("file="+str(self.files[self.iterFile])+ "\n")

I think on the case of isDownloadComplete, I have to do something to close the channel.

Thank you

Note that you are using the non-blocking beginGetDocument() instead of the blocking getDocument() call. This means you have to keep calling until it returns false, and only then should you check isDownloadComplete(). It’s hard to tell whether this is what you’re doing in this code snippet.

If you are doing this, I think that the file will be closed correctly after run() returns false.

Or, you can call getDocument() instead, and then when you call downloadToFile() it will download the file completely (and close it) before it returns, which is much simpler to deal with. But it does mean you will lock up all the tasks while it downloads.


Thank for reply.

I replace beginGetDocument by getDocument, but I got the same behaviour.

The file is locked by a process.

If I restart my apps, and because the file exists already, it is not downloaded by my application, I can launch the exe without trouble.