Archived

This forum has been archived. Please start a new discussion on GitHub.

Pydev debugging issue

Hi,

I am trying to use pydev, the Eclipse plug-in for Python, to debug an Ice server. I have run into a known Pydev problem, which is that breakpoints do not work in threads created by external tools (without using the "threading" module) - see http://pydev.sourceforge.net/faq.html#i_have_a_corba_program_and_i_cannot_debug_its_meth

As explained there, the solution is to make the application (in this case Ice!) call the debugger's trace function when it starts a thread. I could do with some guidance on where best to do this though.

Thanks,
Ben Keeping

Comments

  • mes
    mes California
    Hi Ben,

    Ice supports the notion of a "thread hook", in which an application-specific object is notified whenever the Ice run time starts or stops a thread that may invoke application code. This feature is also supported in Python, and it may be sufficient for your needs. Here's an example:
    class ThreadHook:
        def start(self):
            # Handle thread start
    
        def stop(self):
            # Handle thread stop
    
    id = Ice.InitializationData()
    id.threadHook = ThreadHook()
    communicator = Ice.initialize(id)
    
    Hope that helps,
    - Mark
  • Could you expound a little more on the "Handle Thread start" and "Thread Stop" options?
  • dwayne
    dwayne St. John's, Newfoundland
    The relevant section of the manual is here. Basically the start() function is called when Ice creates a new thread internally and stop() is called when a Ice thread is being stopped. You use these functions if there is any action your application needs to take whenever threads are started/stopped.
  • Thanks, but I had orginally tried that, but I thought I was doing something wrong.

    My basic code keeps crashing my python.exe. I use eclipse with pydev, but whether or not i'm running an actual debug, i get a crash (more specifically, windows forces my python.exe app to terminate)
    class Server:      
        class ThreadHook(Ice.ThreadNotification):
            def start(self):
                # Handle thread start
                print "start id: ",ThreadControl1().id()
        
            def stop(self):
                # Handle thread stop
                print "stop id: ",ThreadControl1().id()
    
        def main(self, args, configFile=None, initData=None):     
            """set the passphrase"""        
            sslPassword="thisAndthat"
            initData = Ice.InitializationData()
            initData.threadHook=self.ThreadHook()
            initData.properties = Ice.createProperties(sys.argv)
            initData.properties.load(configFile)...
    
  • I'm now convinced that it's not even pydev, i'm running it in basic idle, and i'm still having the crashes whenever i set a thread hook.
  • I'm now convinced that it's not even pydev, i'm running it in basic idle, and i'm still having the crashes whenever i set a thread hook. Even when all my start and stop functions do is call "pass"
  • mes
    mes California
    Hi,

    I just ran the following program on Windows XP using our Ice 3.3.0 MSI for Visual Studio 2005 and Python 2.5.2:
    import Ice, time
    
    class Hook(Ice.ThreadNotification):
        def start(self):
            print "Thread started"
    
        def stop(self):
            print "Thread stopped"
    
    id = Ice.InitializationData()
    id.threadHook = Hook()
    c = Ice.initialize(id)
    oa = c.createObjectAdapterWithEndpoints("OA", "tcp")
    oa.activate()
    time.sleep(1)
    c.destroy()
    
    Note that I created an object adapter just to cause a thread to be started. Are you able to run this program? If not, please describe your operating environment and software versions, and tell us exactly what output you get when it fails.

    Regards,
    Mark
  • mes
    mes California
    I should add that I ran this program from a command prompt. I suppose it's possible that your IDE is causing some conflict, so I recommend verifying that a simple program works correctly outside of the IDE first.

    Mark
  • yes it works. so i will see what else i can do for now...
  • Once again, my thread hook refuses to work when i put it into my application. The only difference is that my server -
    class Server:
        def main(self, args, configFile=None, initData=None):           
            """set the passphrase"""        
            sslPassword="thisAndthat"
            initData = Ice.InitializationData()
            initData.threadHook=self.ThreadHook()
    

    runs in a subthread of the main application already. I deliberately did not use Ice.Application, just for the sake of being able to do that. But I believe that since my thread hook works when the application itself is ran in the main thread but doesn't when it's in a sub thread, that's the only conclusion that i can arrive at.
  • matthew
    matthew NL, Canada
    The best way for us to help you is to post a self-contained complete executable application that demonstrates your issue. Don't forget to specify what OS and version of python you are using.
  • I would love to, but looking at my files - that'd be a whole lot of files. I would have to recreate my slice mappings to simplify the amount of files i had to import. But i did test over my application with the Ice Server as the main thread, and my thread hook works. Having the thread hook working still doesn't really help the overall situation. I just wanted to be able to step through one of my Ice Method calls - such as Login method just to see how my data flows...
    But, I'll just see what i can work with for now. Ice is really fast, and i really wouldn't stop using it just because of something trivial like this.