[wingide-users] Debugging Overridden Stackless Tasklets

Simon Pickles sipickles at hotmail.com
Sun May 25 14:18:33 MDT 2008


Hello,

First my platform and versions:

Ubuntu Hardy 8.04 x64
Python 2.5.2 Stackless 3.1b3 060516 (release25-maint:63223, May 14 2008, 
20:29:45)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)]
Wing IDE personal 3.1.1-1 (rev 18164)

WingIDE has been working really well debugging stackless tasklets now.

I have, however, come across a small problem I hoped you might be able 
to help me with.

If I extend stackless by inheriting from a tasklet, the debugging no 
longer works. Here is an example program, two tasklets are run, one 
using stackless.tasklet, the other using stacklessPlus.NamedTasklet (The 
create function switches back to stackless.tasklets if no name is 
supplied):

#stacklessPlus.py
#Stackless enhancements
import stackless

class NamedTasklet(stackless.tasklet):
  __slots__ = [ "name" ]

  def __str__(self):
      return "<NamedTasklet(%s)>" % self.name
    def __call__(self, *args, **kwargs):
      oldFunction = self.tempval
      def newFunction(oldFunction, args, kwargs):
          print "%s has just been run. (%d runnable)" % (str(self), 
stackless.getruncount())
          try:
              oldFunction(*args, **kwargs)
          except Exception, e:
              print "Exception in %s" % str(self)
              raise e
          print "%s returned" % str(self)
                 self.tempval = newFunction
      stackless.tasklet.setup(self, oldFunction, args, kwargs)
      return self


def CreateNamedTasklet(name, func, *args, **kwargs):
  if name is None:
      return stackless.tasklet(func)(*args, **kwargs)
  t = NamedTasklet(func)(*args, **kwargs)
  t.name = name

  return t

#------------------------------------
#testNamedTasklets.py
import stackless
import stacklessPlus

def DoPrint(s):
  i = 0
  while 1:
      print "%s:%d" % (s, i)
      i += 1
      stackless.schedule()
      if i == 3:
          return
     if __name__ == "__main__":
  #TaskletA
  stacklessPlus.CreateNamedTasklet(None, DoPrint, "A")
  #TaskletB
  stacklessPlus.CreateNamedTasklet("TaskletB", DoPrint, "B")
  stackless.run()

#---------------------------------------
Output:

A:0
<NamedTasklet(TaskletB)> has just been run. (2 runnable)
B:0
A:1
B:1
A:2
B:2
<NamedTasklet(TaskletB)> returned

#------------------------------------

All runs fine. Putting a breakpoint in the DoCount function will only 
break during TaskletA.

Is there anyway I can educate WingIDE?

Thanks

Simon Pickles





More information about the wingide-users mailing list