Downloading a File

To download a file while the game is running without blocking the connections one has to use HTTPClient and HTTPChannel objects. This will allow the file to be downloaded in the background using the downloadTask task.

self.http = HTTPClient() = self.http.makeChannel(True)'http://my.url/'))
self.rf = Ramfile()
taskMgr.add(self.downloadTask, 'download')

def downloadTask(self, task):
        # Still waiting for file to finish downloading.
        return task.cont
    if not
        print("Error downloading file.")
        return task.done
    data = self.rf.getData()
    print("got data:")
    return task.done

You can also download to file


The file channel can be queried for further information while the game is running to get the current download state.

mbDownloaded = / 1024 / 1024
percentDownloaded = 100. * / channel.getFileSize()