Shayne O'Neill wrote: > Does python have a sort of cooperative "pass" command? Whilst little > (other than an external monitoring process, assuming the monitor gets a > chance to do its thing) will stop someone writing this code;- > > while 1==1: > echo "hi mum" > > a call like > > while 1==1: > one_of_our_calls() > echo "hi mum" > > could be dealt with by having regular 'pass' type commands liberally > inserted into various api calls. Now, granted it's a little bit hacky to > do that, but it may well work. > Unfortunately they often won't call any of my functions within their loops. After looking around for other people's solutions to the general problem of killing Python threads I've discovered that I could install a debugging interrupt into all my threads, but I think searching for a kill between every byte code will be too slow. > One thing to keep in mind, is that python (and most any language, except > perhaps 'managed' code like java or .net) threading implementations will > change from OS to OS. > > but there should be some sort of 'pass' command. > > Actually, now I think about it , a simple 'wait' type thingo should do the > job. >
Sensible people point out that killing a thread is a dangerous business because it may hold locks and is O/S-specific. The alternative is to trigger an exception in another thread. This is safe, but won't help with blocked I/O calls, which is fine with me. There is a patch to do this (http://mail.python.org/pipermail/python-list/2003-February/148999.html), but it appears not to have been adopted. I'm not game to apply a Python 2.2 patch to the latest Python code so I think that line of inquiry is closed. That leaves me with the option of monitoring my running threads. If I discover that more than two-thirds of them are unresponsive then I can kill and restart AppServer. If I do this quickly then there won't be any interruption in service. Oliver _______________________________________________ Webware-discuss mailing list Webware-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/webware-discuss