Skip to content

Commit beca293

Browse files
committed
ensure the self.process exist, to reduce possibilities of AttributeError
1 parent 755860c commit beca293

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

browsermobproxy/server.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def __init__(self, path, options={}):
3232

3333
self.path = path
3434
self.port = options.get('port', 8080)
35+
self.process = None
3536

3637
if platform.system == 'darwin':
3738
self.command = ['sh']
@@ -56,10 +57,12 @@ def stop(self):
5657
"""
5758
This will stop the process running the proxy
5859
"""
60+
if self.process.poll() != None:
61+
return
62+
5963
try:
60-
if self.process:
61-
self.process.kill()
62-
self.process.wait()
64+
self.process.kill()
65+
self.process.wait()
6366
except AttributeError:
6467
# kill may not be available under windows environment
6568
pass

0 commit comments

Comments
 (0)