Re: [casper] KATCP Python Interface doesn't exit cleanly

2009-08-06 Thread Jason Manley

Thanks Simon

I have updated CORR's katcp wrapper to do this by default now.

Jason

On 05 Aug 2009, at 14:10, Simon Cross wrote:


Hi Jason and Suraj

On Wed, 2009-08-05 at 13:55 +0200, Jason Manley wrote:

Yes, I have had similar experiences. You have to close any open
connections yourself, else the (separate) thread with the open port
stays open, hanging the exit procedure. myroachobject.stop() does
this. Take a look at some of my scripts in the corr package to see an
example.

Perhaps you can daemonise the thread or something to work around this
issue. I haven't explored it too carefully myself. I've cc'd Simon
Cross (original author of python KATCP) for his comment.


As described in [1] you can pass a daemon parameter into the call to a
client's .start() method to change whether the thread will keep the
process alive or not.

Calling client.start(daemon=True) [2] should cause the threads to be
killed when the process dies.

This is not done by default because non-shell users of the library
probably want to arrange to clean up the clients properly before  
exiting
and in that case it makes sense to wait for the thread to finish  
before

ending the process.

[1] http://packages.python.org/katcp/api.html#katcp.BlockingClient.start
[2] Why daemon=True does this becomes more understandable once you
realise that on some platforms threads outlive the process that  
created

them.

Hope this helps.

Schiavo
Simon






Re: [casper] KATCP Python Interface doesn't exit cleanly

2009-08-05 Thread Jason Manley

Hi Suraj

Yes, I have had similar experiences. You have to close any open  
connections yourself, else the (separate) thread with the open port  
stays open, hanging the exit procedure. myroachobject.stop() does  
this. Take a look at some of my scripts in the corr package to see an  
example.


Perhaps you can daemonise the thread or something to work around this  
issue. I haven't explored it too carefully myself. I've cc'd Simon  
Cross (original author of python KATCP) for his comment.


Jason

On 04 Aug 2009, at 23:43, Suraj Gowda wrote:


Hello everybody,

When using the python interface to KATCP (and the corr package),  
scripts don't seem to exit cleanly out of the python shell.  This  
isn't a serious problem but is a bit annoying because anytime a  
roach script is run, the shell becomes unresponsive and needs to be  
re-opened.  Is this a known problem with a solution?


Thanks,
-Suraj Gowda






[casper] KATCP Python Interface doesn't exit cleanly

2009-08-04 Thread Suraj Gowda

Hello everybody,

When using the python interface to KATCP (and the corr package),  
scripts don't seem to exit cleanly out of the python shell.  This  
isn't a serious problem but is a bit annoying because anytime a roach  
script is run, the shell becomes unresponsive and needs to be re- 
opened.  Is this a known problem with a solution?


Thanks,
-Suraj Gowda