8000 fix poll_url in Python 3 (#370) · DevSw/python-client@bcccf0b · GitHub
[go: up one dir, main page]

Skip to content

Commit bcccf0b

Browse files
authored
fix poll_url in Python 3 (appium#370)
1 parent e01f998 commit bcccf0b

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

appium/webdriver/appium_service.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313
# limitations under the License.
1414

1515

16-
import httplib
1716
import os
1817
import subprocess
1918
import sys
2019
import time
21-
20+
import urllib3
2221

2322
DEFAULT_HOST = '127.0.0.1'
2423
DEFAULT_PORT = 4723
@@ -49,9 +48,10 @@ def poll_url(host, port, path, timeout_ms):
4948
time_started_sec = time.time()
5049
while time.time() < time_started_sec + timeout_ms / 1000.0:
5150
try:
52-
conn = httplib.HTTPConnection(host=host, port=port, timeout=1.0)
53-
conn.request('HEAD', path)
54-
if conn.getresponse().status < 400:
51+
conn = urllib3.PoolManager(timeout=1.0)
52+
resp = conn.request('HEAD', 'http://{host}:{port}{path}'.format(
53+
host=host, port=port, path=path))
54+
if resp.status < 400:
5555
return True
5656
except Exception:
5757
pass
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
7D5D
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from appium.webdriver.appium_service import AppiumService
16+
17+
18+
class TestAppiumService(object):
19+
def test_get_instance(self):
20+
assert AppiumService()

0 commit comments

Comments
 (0)
0