Python module/program

McCann, Brian bmccann at andmore.com
Thu Jan 27 17:30:32 CET 2011


The python module is currently catching NO exceptions.  There are no try/except blocks.  Right now I just have the module simply printing something and returning "OK" for everything...just as a proof of concept.

Thanks though,
--Brian

From: freeradius-users-bounces+bmccann=andmore.com at lists.freeradius.org [mailto:freeradius-users-bounces+bmccann=andmore.com at lists.freeradius.org] On Behalf Of Terry Simons
Sent: Wednesday, January 26, 2011 6:07 PM
To: FreeRadius users mailing list
Subject: Re: Python module/program

Is the python module catching all exceptions?

You need to make sure you don't mask out the KeyboardInterrupt exception... otherwise, you may prevent Control-C from being passed up the stack.

I'm not sure if that's your issue, but it sounds like it could be.  It's considered a Python best practice to explicitly catch the exact exceptions that you know how to handle, and let exceptions that you're not going to handle directly trickle up.

That is to say that you should never do something like:

try:
    <some code>
except:
   <some code>

because you *will* end up masking things like KeyboardInterrupt.

You should always do something like:

try:
    <some code>
except TheExceptionClass:
    <some code>

HTH,

- Terry

On Wed, Jan 26, 2011 at 2:47 PM, McCann, Brian <bmccann at andmore.com<mailto:bmccann at andmore.com>> wrote:
Hi all.  I've got freeradius working using a python library for auth, but something interesting happened when I did.  When I run "radius -X", and press  CRTL+C, it no longer exits.  It just returns "Ready to process requests.".  The PID doesn't change, so it's not like its exiting and restarting.

I looked at http://wiki.freeradius.org/Rlm_perl (yes...I know...perl != python, but as the python page doesn't say much, I'm going on the perl page for a starting point) and it doesn't look like the script has to do anything to handle exits.  Does anyone know what I'm missing?

Thanks,
--Brian

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20110127/72a12aa5/attachment.html>


More information about the Freeradius-Users mailing list