diff --git a/.circleci/config.yml b/.circleci/config.yml index 7f85513d..822415cc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -73,7 +73,7 @@ jobs: binaries: machine: true environment: - - PYTHON_VERSIONS: 3.5 3.6 3.7 + - PYTHON_VERSIONS: 3.5 3.6 3.7 3.8 - PYMODULE: pulsar steps: - checkout diff --git a/.travis.yml b/.travis.yml index 2dd6a79e..406f79c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,10 @@ matrix: env: PYTHON_VERSION=3.6.3 - os: osx - env: PYTHON_VERSION=3.7.0 + env: PYTHON_VERSION=3.7.4 + + - os: osx + env: PYTHON_VERSION=3.8.0 install: - ci/mac-pre-install.sh diff --git a/pulsar/__init__.py b/pulsar/__init__.py index 4bd85de7..8d446aa1 100644 --- a/pulsar/__init__.py +++ b/pulsar/__init__.py @@ -3,7 +3,7 @@ from .utils.version import get_version -VERSION = (2, 0, 2, 'final', 0) +VERSION = (2, 0, 3, 'final', 0) __version__ = version = get_version(VERSION) diff --git a/pulsar/asynclib/clients.py b/pulsar/asynclib/clients.py index 9e2ed081..17a0fc62 100644 --- a/pulsar/asynclib/clients.py +++ b/pulsar/asynclib/clients.py @@ -37,7 +37,7 @@ def __init__(self, creator, pool_size=10, loop=None, timeout=None, **kw): self._creator = creator self._closed = False self._timeout = timeout - self._queue = asyncio.Queue(maxsize=pool_size, loop=loop) + self._queue = asyncio.Queue(maxsize=pool_size) self._connecting = 0 self._loop = self._queue._loop self._logger = logger diff --git a/pulsar/asynclib/mixins.py b/pulsar/asynclib/mixins.py index e3c69ef5..204c7ca1 100644 --- a/pulsar/asynclib/mixins.py +++ b/pulsar/asynclib/mixins.py @@ -178,7 +178,7 @@ class ResponsePipeline: def __init__(self, connection): self.connection = connection - self.queue = Queue(loop=connection._loop) + self.queue = Queue() self.debug = connection._loop.get_debug() self.worker = self.queue._loop.create_task(self._process()) self.put = self.queue.put_nowait diff --git a/pulsar/asynclib/protocols.py b/pulsar/asynclib/protocols.py index 68a7c8a1..4f6d59ea 100644 --- a/pulsar/asynclib/protocols.py +++ b/pulsar/asynclib/protocols.py @@ -228,10 +228,14 @@ async def start_serving(self, address=None, sockets=None, sock=sock, backlog=backlog, ssl=sslcontext) - if server: - server.sockets.extend(srv.sockets) - else: - server = srv + # scailer: I'm don't know why this code was written + # if server: + # server.sockets.extend(srv.sockets) + # else: + # server = srv + + server = srv + elif isinstance(address, tuple): server = await create_server(self.create_protocol, host=address[0], diff --git a/pulsar/asynclib/timeout.py b/pulsar/asynclib/timeout.py index 70b6949f..5eecd9e1 100644 --- a/pulsar/asynclib/timeout.py +++ b/pulsar/asynclib/timeout.py @@ -1,4 +1,4 @@ -from asyncio import Task, CancelledError, TimeoutError +from asyncio import CancelledError, TimeoutError, current_task class timeout: @@ -16,7 +16,7 @@ def __init__(self, loop, timeout): def __enter__(self): if self._timeout is None: return self - self._task = Task.current_task(self._loop) + self._task = current_task() tm = self._loop.time() + self._timeout self._cancel_handler = self._loop.call_at(tm, self._cancel_task) return self diff --git a/pulsar/utils/httpurl.py b/pulsar/utils/httpurl.py index 455e354b..007ccaf1 100644 --- a/pulsar/utils/httpurl.py +++ b/pulsar/utils/httpurl.py @@ -7,7 +7,7 @@ from io import BytesIO from urllib import request as urllibr from http import client as httpclient -from urllib.parse import quote, splitport +from urllib.parse import quote from http.cookiejar import CookieJar, Cookie from http.cookies import SimpleCookie @@ -20,6 +20,8 @@ HTTPError = urllibr.HTTPError URLError = urllibr.URLError parse_http_list = urllibr.parse_http_list +re_port = re.compile('(.*):([0-9]*)$', re.DOTALL) + tls_schemes = ('https', 'wss') @@ -123,6 +125,15 @@ def iri_to_uri(iri, kwargs=None): return urlquote(unquote_unreserved(iri)) +def splitport(host): + match = re_port.match(host) + if match: + host, port = match.groups() + if port: + return host, port + return host, None + + def host_and_port(host): host, port = splitport(host) return host, int(port) if port else None diff --git a/tests/utils/test_tools.py b/tests/utils/test_tools.py index b4b91def..4dc57d1c 100755 --- a/tests/utils/test_tools.py +++ b/tests/utils/test_tools.py @@ -148,7 +148,7 @@ def test_py_file(self): def __test_import_modules(self): self.assertEqual(import_modules(['gggggggggggg']), []) - mods = import_modules(['pulsar.async.*']) + mods = import_modules(['pulsar.asynclib.*']) self.assertTrue(mods) def test_date2timestamp(self):