Error with a task.

I get this error, randomly, when one of my task is running:

And I really do not understand what causes this error…
Here’s my task code:

class GeneratorTask:
    def __init__(self,func):#where func returns a generator
        self.generator=func
        self.__isfirstcall__=True
    def __call__(self,*args,**kwargs):
        if self.__isfirstcall__:
            self.generator=self.generator(*args,**kwargs)
            self.__isfirstcall__ = False
        try:
            yielded=self.generator.next()
        except StopIteration:
            return Task.done
        return yielded
[...]
class Player:
[...]
    def moveTo(self,newpos,x,task):
		print "moveTo",x
		speed=2
		startpos = (self.playerActor.getX(),
					self.playerActor.getY(),	
					self.playerActor.getZ())
		dx=newpos[0]-startpos[0]
		dy=newpos[1]-startpos[1]
		d=math.sqrt(dx**2+dy**2)
		if not d:
			d=0.0001
		t=d/speed
		self.walks=True
		self.playerActor.stop()
		self.playerActor.loop("walk")
		prepos=startpos
		AX=dx/t
		AY=dy/t
		z=self.current_area.computeZ((self.playerActor.getX(),self.playerActor.getY()))
		self.targetmodel.setPos(newpos[0],newpos[1],self.current_area.computeZ((newpos[0],newpos[1])))
		while self.walks:
			#if not task.frame%2:
			z=self.current_area.computeZ((self.playerActor.getX(),self.playerActor.getY()))
			#base.camera.lookAt(self.playerActor)
			pos=(startpos[0]+AX*task.time,
				 startpos[1]+AY*task.time,
				 z)
			self.playerActor.setPos(*pos)
			self.playerActor.lookAt(prepos[0],prepos[1],pos[2])
			prepos=pos
			if task.time>t:
				self.walks=False
			yield Task.cont
		self.playerActor.stop()
		self.playerActor.loop("idle")
		yield Task.done
[...]
taskMgr.add(GeneratorTask(self.moveTo),'__PLAYERmove',extraArgs=[pos,17],appendTask=True)

If you have any questions about my code, ask, I’ll be happy to answer.

Thanks for your time!

The error message indicates that when the task manager attempted to execute a task in the list, it came across a “Task” object that didn’t have an extraArgs member.

Since it’s strange that a Task might be lacking an extraArgs member, it’s more likely that it wasn’t a Task object at all. So, somehow a non-Task object got added to the task list.

How that happened isn’t immediately obvious. You might be able to determine more by using pdb. When you get the exception, use pdb.pm() to get the post-mortem, and see what object type “task” is (e.g. print task.class). That may give you some insights as to what went wrong.

David