From 80e93b9c556edda5629334a751fff2d903bd9bd6 Mon Sep 17 00:00:00 2001 From: Brijesh Bittu Date: Thu, 4 Jun 2015 12:48:03 +0530 Subject: [PATCH] Updated gunicorn/pidfile.py Added a try block to convert the contents of the `pidfile.py` if it can be converted to integer or not. If not, then `wpid` is assigned 0 and the `validate` function returns as usual. If the pidfile has a valid int, the function continues to kill the process as before. --- gunicorn/pidfile.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gunicorn/pidfile.py b/gunicorn/pidfile.py index 4cf603c7..45b32de1 100644 --- a/gunicorn/pidfile.py +++ b/gunicorn/pidfile.py @@ -66,7 +66,10 @@ class Pidfile(object): return try: with open(self.fname, "r") as f: - wpid = int(f.read() or 0) + try: + wpid = int(f.read()) + except ValueError: + wpid = 0 if wpid <= 0: return