Skip to content

Commit 5675248

Browse files
committed
polishing
1 parent 77d25d3 commit 5675248

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

splitio/api/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import urllib
55
import abc
66

7-
import splitio.util.load_asyncio
7+
from splitio.optional.loaders import aiohttp
88

99
SDK_URL = 'https://sdk.split.io/api'
1010
EVENTS_URL = 'https://events.split.io/api'
@@ -183,7 +183,7 @@ def __init__(self, timeout=None, sdk_url=None, events_url=None, auth_url=None, t
183183
"""
184184
self._timeout = timeout/1000 if timeout else None # Convert ms to seconds.
185185
self._urls = _construct_urls(sdk_url, events_url, auth_url, telemetry_url)
186-
self._session = splitio.util.load_asyncio.aiohttp.ClientSession()
186+
self._session = aiohttp.ClientSession()
187187

188188
async def get(self, server, path, apikey, query=None, extra_headers=None): # pylint: disable=too-many-arguments
189189
"""
@@ -213,7 +213,7 @@ async def get(self, server, path, apikey, query=None, extra_headers=None): # py
213213
) as response:
214214
body = await response.text()
215215
return HttpResponse(response.status, body, response.headers)
216-
except splitio.util.aiohttp.ClientError as exc: # pylint: disable=broad-except
216+
except aiohttp.ClientError as exc: # pylint: disable=broad-except
217217
raise HttpClientException('aiohttp library is throwing exceptions') from exc
218218

219219
async def post(self, server, path, apikey, body, query=None, extra_headers=None): # pylint: disable=too-many-arguments
@@ -247,5 +247,5 @@ async def post(self, server, path, apikey, body, query=None, extra_headers=None)
247247
) as response:
248248
body = await response.text()
249249
return HttpResponse(response.status, body, response.headers)
250-
except Exception as exc: # pylint: disable=broad-except
250+
except aiohttp.ClientError as exc: # pylint: disable=broad-except
251251
raise HttpClientException('aiohttp library is throwing exceptions') from exc

splitio/optional/__init__.py

Whitespace-only changes.

splitio/push/splitworker.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import threading
44
import abc
55

6-
import splitio.util.load_asyncio
6+
from splitio.optional.loaders import asyncio
77

88
_LOGGER = logging.getLogger(__name__)
99

@@ -99,7 +99,6 @@ def __init__(self, synchronize_split, split_queue):
9999
self._split_queue = split_queue
100100
self._handler = synchronize_split
101101
self._running = False
102-
self._worker = None
103102

104103
def is_running(self):
105104
"""Return whether the working is running."""
@@ -130,7 +129,7 @@ def start(self):
130129
self._running = True
131130

132131
_LOGGER.debug('Starting Split Worker')
133-
splitio.util.load_asyncio.asyncio.gather(self._run())
132+
asyncio.gather(self._run())
134133

135134
async def stop(self):
136135
"""Stop worker."""

tests/push/test_split_worker.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from splitio.api import APIException
77
from splitio.push.splitworker import SplitWorker, SplitWorkerAsync
88
from splitio.models.notification import SplitChangeNotification
9-
import splitio.util.load_asyncio
9+
from splitio.optional.loaders import asyncio
1010

1111
change_number_received = None
1212

@@ -65,7 +65,7 @@ def test_handler(self):
6565
class SplitWorkerAsyncTests(object):
6666

6767
async def test_on_error(self):
68-
q = splitio.util.load_asyncio.asyncio.Queue()
68+
q = asyncio.Queue()
6969

7070
def handler_sync(change_number):
7171
raise APIException('some')
@@ -82,21 +82,21 @@ def handler_sync(change_number):
8282
assert(self._worker_running())
8383

8484
await split_worker.stop()
85-
await splitio.util.load_asyncio.asyncio.sleep(.1)
85+
await asyncio.sleep(.1)
8686

8787
assert not split_worker.is_running()
8888
assert(not self._worker_running())
8989

9090
def _worker_running(self):
9191
worker_running = False
92-
for task in splitio.util.load_asyncio.asyncio.Task.all_tasks():
92+
for task in asyncio.Task.all_tasks():
9393
if task._coro.cr_code.co_name == '_run' and not task.done():
9494
worker_running = True
9595
break
9696
return worker_running
9797

9898
async def test_handler(self):
99-
q = splitio.util.load_asyncio.asyncio.Queue()
99+
q = asyncio.Queue()
100100
split_worker = SplitWorkerAsync(handler_async, q)
101101

102102
assert not split_worker.is_running()
@@ -106,12 +106,12 @@ async def test_handler(self):
106106

107107
global change_number_received
108108
await q.put(SplitChangeNotification('some', 'SPLIT_UPDATE', 123456789))
109-
await splitio.util.load_asyncio.asyncio.sleep(1)
109+
await asyncio.sleep(1)
110110

111111
assert change_number_received == 123456789
112112

113113
await split_worker.stop()
114-
await splitio.util.load_asyncio.asyncio.sleep(.1)
114+
await asyncio.sleep(.1)
115115

116116
assert not split_worker.is_running()
117117
assert(not self._worker_running())

0 commit comments

Comments
 (0)