Unable to break into cherrypy

ms_scoop
2006-04-09
2013-03-15
  • ms_scoop
    ms_scoop
    2006-04-09

    Hello,

    trying pydev extensions with web development in cherypy.
    Cherrypy uses a thread pool to serve multiple sessions. Breakpoints in pydev do not work with cherrypy threads.

    Any advice?

    Thanks,

    Marcus

     
    • Fabio Zadrozny
      Fabio Zadrozny
      2006-04-09

      Well, to use the tracing facility of python, pydev sets: threading.settrace with the tracing function. For each thread that should be done too... Probably cherrypy is passing that... so, to re-enable the tracing facility, you should do something as:

      import sys
      import pydevd
      g = pydevd.GetGlobalDebugger()
      sys.settrace(g.trace_dispatch)

      just after you create that thread... (I'm not sure where exactly does cherrypy do this, but it shouldn't be hard to find).

      Another option if you're in pydev extensions would be using the remote debugger (http://www.fabioz.com/pydev/manual_adv_remote_debugger.html), as it enables the tracing facility when it is called.

      Cheers,

      Fabio

       
      • ms_scoop
        ms_scoop
        2006-05-27

        Tried cherrypy debugging again and wanted to use your recipe.

        g = pydevd.GetGlobalDebugger() - returns None.

        Any further advice?

        Thank you.

        Marcus

         
        • ms_scoop
          ms_scoop
          2006-05-27

          Sorry,

          g = pydevd.GetGlobalDebugger()

          works only in Debug-Mode.

          I initialized every cherrypy thread now in this way. CP has an callback-API for doing so. But I can still not break into any of the running threads.

          Any idea what to do?

          Thanks,

          Marcus

           
        • Fabio Zadrozny
          Fabio Zadrozny
          2006-05-28

          Ok, as you're trying pydev extensions, have you tried using pydevd.settrace ? (as pointed in http://www.fabioz.com/pydev/manual_adv_remote_debugger.html\)

          -- You need to start the remote debugger server before that call.

          Cheers,

          Fabio

           
          • ms_scoop
            ms_scoop
            2006-05-29

            Hi Fabio,

            thanks for the response.

            I have tried pydevd.settrace(). I seems to work, but only once? If it passes pydevd.settrace() a second time the debugger does not break.

            It would be much easier to break into a regular breakpoint when you see a problem in the running program - instead ot stopping the process, changing the code and navigate to the problem again.

            Or am I making something wrong?

            Regards,

            Marcus

             
            • Fabio Zadrozny
              Fabio Zadrozny
              2006-05-29

              Actually, the remote debugger is mostly for when you're running things without the need for running it in debug mode, so, you just start the remote debugger and when it hits that code it automatically 'switches' to debug mode. You should be able to add breakpoints after switching to debug mode without problems.

              Now, if you already start CP in debug mode from within Eclipse, that should not be needed, as long as you set the tracing facility for each thread you create (as I explained before), and breakpoints should work without problems. If they're not working when you run things that way, it might be that for some reason the filename that generated the module is lost in CP, but I find that very unlikely, but as I haven't tested it, it might be the reason why that's happening.

              If you believe that the breakpoints are missed because of something like that you can report a bug, and we can do some things 'interactively', if you're willing to do it, so, I'll pass you the changes, and you do them in your environment, so that we can evaluate toghether what's happening.

              Cheers,

              Fabio

               
              • ms_scoop
                ms_scoop
                2006-05-30

                I ran the remote debugger without debug mode.
                Breakpoints still work only for the duration of one request. For the next request remote debugger has lost them.
                The regular debugger too.
                I will report a bug. I am interested that the bug is solved. If you I can help please tell me how.

                Regards,

                Marcus

                 
                • Fabio Zadrozny
                  Fabio Zadrozny
                  2006-05-30

                  Sure, please do report it -- I'm interested in making it work too ;-)