mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
*** empty log message ***
This commit is contained in:
parent
f9deccc8c6
commit
f3065fbb3e
34
direct/src/extensions/HTTPChannel-extensions.py
Normal file
34
direct/src/extensions/HTTPChannel-extensions.py
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
"""
|
||||
HTTPChannel-extensions module: contains methods to extend functionality
|
||||
of the HTTPChannel class
|
||||
"""
|
||||
|
||||
def spawnTask(self, name = None, callback = None, extraArgs = []):
|
||||
"""Spawns a task to service the download recently requested
|
||||
via beginGetDocument(), etc., and/or downloadToFile() or
|
||||
downloadToRam(). If a callback is specified, that function is
|
||||
called when the download is complete, passing in the extraArgs
|
||||
given.
|
||||
|
||||
Returns the newly-spawned task.
|
||||
"""
|
||||
if not name:
|
||||
name = self.getUrl().cStr()
|
||||
|
||||
import Task
|
||||
task = Task.Task(self.doTask)
|
||||
task.callback = callback
|
||||
task.extraArgs = extraArgs
|
||||
|
||||
return taskMgr.add(task, name)
|
||||
|
||||
def doTask(self, task):
|
||||
import Task
|
||||
if self.run():
|
||||
return Task.cont
|
||||
|
||||
if task.callback:
|
||||
task.callback(*task.extraArgs)
|
||||
return Task.done
|
||||
|
Loading…
x
Reference in New Issue
Block a user