Skip to content

Commit d57afc1

Browse files
committed
handle potential URLError from sending shutdown, set self.process to None after it's already been quit
Fixes #1504
1 parent 9afb684 commit d57afc1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

py/selenium/webdriver/common/service.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,16 @@ def is_connectable(self):
9393
def send_remote_shutdown_command(self):
9494
try:
9595
from urllib import request as url_request
96+
URLError = url_request.URLError
9697
except ImportError:
9798
import urllib2 as url_request
99+
import urllib2
100+
URLError = urllib2.URLError
98101

99-
url_request.urlopen("http://127.0.0.1:%d/shutdown" % self.port)
102+
try:
103+
url_request.urlopen("http://127.0.0.1:%d/shutdown" % self.port)
104+
except URLError:
105+
return
100106
count = 0
101107
while self.is_connectable():
102108
if count == 30:
@@ -134,6 +140,7 @@ def stop(self):
134140
self.process.terminate()
135141
self.process.kill()
136142
self.process.wait()
143+
self.process = None
137144
except OSError:
138145
# kill may not be available under windows environment
139146
pass

0 commit comments

Comments
 (0)