> If you are working entirely in python, you could switch some of this errno > passing into something more exception-based, it might look a little more > natural.
I personally find exceptions aesthetically displeasing. They make code hard to reason about. That said, I agree, if I were to rewrite this file in a more Python-esque style, exceptions would be appropriate. However, I'm just trying to get it to pychecker, not planning to do a lot of work in this file. Thanks for the review btw, It's nice to have someone with some python experience look over this stuff. There should be quite a bit more python code in the near future. Ethan > > On Fri, Sep 16, 2011 at 4:49 PM, Ethan Jackson <et...@nicira.com> wrote: >> >> Pychecker complains about __read_pidfile() having too may returns. >> I personally think the function is fine, but it's easy enough to >> reduce them. >> >> python/ovs/daemon.py:395: Function (__read_pidfile) has too many >> returns (12) >> --- >> python/ovs/daemon.py | 8 +++++--- >> 1 files changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/python/ovs/daemon.py b/python/ovs/daemon.py >> index b793d6e..89df99c 100644 >> --- a/python/ovs/daemon.py >> +++ b/python/ovs/daemon.py >> @@ -457,13 +457,15 @@ def __read_pidfile(pidfile, delete_if_stale): >> # Someone else has the pidfile locked. >> try: >> try: >> - return int(file_handle.readline()) >> + error = int(file_handle.readline()) >> except IOError, e: >> logging.warning("%s: read: %s" % (pidfile, e.strerror)) >> - return -e.errno >> + error = -e.errno >> except ValueError: >> logging.warning("%s does not contain a pid" % pidfile) >> - return -errno.EINVAL >> + error = -errno.EINVAL >> + >> + return error >> finally: >> try: >> file_handle.close() >> -- >> 1.7.6.1 >> >> _______________________________________________ >> dev mailing list >> dev@openvswitch.org >> http://openvswitch.org/mailman/listinfo/dev > > _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev