diff --git a/thriftpy2/_compat.py b/thriftpy2/_compat.py index 34b4b6f..84d77c9 100644 --- a/thriftpy2/_compat.py +++ b/thriftpy2/_compat.py @@ -11,8 +11,8 @@ import platform import sys -from urllib.request import urlopen from urllib.parse import urlparse +from urllib.request import urlopen PY3 = sys.version_info[0] == 3 PY35 = sys.version_info >= (3, 5) diff --git a/thriftpy2/contrib/aio/rpc.py b/thriftpy2/contrib/aio/rpc.py index 097db33..6ee8445 100644 --- a/thriftpy2/contrib/aio/rpc.py +++ b/thriftpy2/contrib/aio/rpc.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- -import warnings import urllib +import warnings -from .processor import TAsyncProcessor from .client import TAsyncClient +from .processor import TAsyncProcessor from .protocol.binary import TAsyncBinaryProtocolFactory -from .transport.buffered import TAsyncBufferedTransportFactory -from .socket import TAsyncSocket, TAsyncServerSocket from .server import TAsyncServer +from .socket import TAsyncServerSocket, TAsyncSocket +from .transport.buffered import TAsyncBufferedTransportFactory async def make_client(service, host='localhost', port=9090, unix_socket=None, diff --git a/thriftpy2/http.py b/thriftpy2/http.py index e38c831..ae18c3a 100644 --- a/thriftpy2/http.py +++ b/thriftpy2/http.py @@ -32,23 +32,20 @@ from __future__ import absolute_import +import http.client as http_client +import http.server as http_server import os import socket import sys +import urllib from contextlib import contextmanager from io import BytesIO -import http.client as http_client -import http.server as http_server -import urllib - -from thriftpy2.thrift import TProcessor, TClient -from thriftpy2.server import TServer -from thriftpy2.transport import TTransportBase, TMemoryBuffer - from thriftpy2.protocol import TBinaryProtocolFactory -from thriftpy2.transport import TBufferedTransportFactory - +from thriftpy2.server import TServer +from thriftpy2.thrift import TClient, TProcessor +from thriftpy2.transport import (TBufferedTransportFactory, TMemoryBuffer, + TTransportBase) HTTP_URI = '{scheme}://{host}:{port}{path}' DEFAULT_HTTP_CLIENT_TIMEOUT_MS = 30000 # 30 seconds diff --git a/thriftpy2/rpc.py b/thriftpy2/rpc.py index 4c2ccd2..c9e7664 100644 --- a/thriftpy2/rpc.py +++ b/thriftpy2/rpc.py @@ -4,21 +4,15 @@ import contextlib import socket +import urllib import warnings from thriftpy2._compat import PY35 -import urllib - from thriftpy2.protocol import TBinaryProtocolFactory from thriftpy2.server import TThreadedServer -from thriftpy2.thrift import TProcessor, TClient -from thriftpy2.transport import ( - TBufferedTransportFactory, - TServerSocket, - TSSLServerSocket, - TSocket, - TSSLSocket, -) +from thriftpy2.thrift import TClient, TProcessor +from thriftpy2.transport import (TBufferedTransportFactory, TServerSocket, + TSocket, TSSLServerSocket, TSSLSocket) def make_client(service, host="localhost", port=9090, unix_socket=None, @@ -131,7 +125,6 @@ def client_context(service, host="localhost", port=9090, unix_socket=None, if PY35: - from thriftpy2.contrib.aio.rpc import ( # noqa - make_server as make_aio_server, - make_client as make_aio_client - ) + from thriftpy2.contrib.aio.rpc import make_client as make_aio_client + from thriftpy2.contrib.aio.rpc import \ + make_server as make_aio_server # noqa diff --git a/thriftpy2/tornado.py b/thriftpy2/tornado.py index d776bb4..95e3804 100644 --- a/thriftpy2/tornado.py +++ b/thriftpy2/tornado.py @@ -17,23 +17,22 @@ from __future__ import absolute_import +import logging +import socket +import struct +import urllib from contextlib import contextmanager -from tornado import tcpserver, iostream, gen -from tornado import version as tornado_version -from io import BytesIO from datetime import timedelta +from io import BytesIO -from .transport import TTransportException, TTransportBase -from .transport.memory import TMemoryBuffer -from .thrift import TApplicationException, TProcessor, TClient +from tornado import gen, iostream, tcpserver +from tornado import version as tornado_version # TODO need TCyTornadoStreamTransport to work with cython binary protocol from .protocol.binary import TBinaryProtocolFactory - -import urllib -import logging -import socket -import struct +from .thrift import TApplicationException, TClient, TProcessor +from .transport import TTransportBase, TTransportException +from .transport.memory import TMemoryBuffer try: from tornado.locks import Lock