Skip to content

Commit

Permalink
bug fix for aiohttp and update version
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed Dec 24, 2018
1 parent c4194a4 commit 6db8a83
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion wwqLyParse/common/get_url/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ def __exit__(self, exc_type, exc_val, exc_tb):
asyncio.run_coroutine_threadsafe(self.resp.__aexit__(exc_type, exc_val, exc_tb), loop=self.loop).result()


async def __close_connector( connector: TCPConnector):
logging.debug("close %s" % connector)
await connector.close()


def _close_connector(loop: asyncio.AbstractEventLoop, connector: TCPConnector):
asyncio.run_coroutine_threadsafe(__close_connector(connector), loop).result()


class AioHttpGetUrlImpl(GetUrlImpl):

def __init__(self, service):
Expand All @@ -51,7 +60,7 @@ def __init__(self, service):
self.common_client_timeout = aiohttp.ClientTimeout(sock_connect=GET_URL_CONNECT_TIMEOUT,
sock_read=GET_URL_RECV_TIMEOUT)
logging.debug("init %s" % self.common_connector)
weakref.finalize(self, self.common_connector.close)
weakref.finalize(self, _close_connector, self.common_loop, self.common_connector)

def new_cookie_jar(self):
return aiohttp.CookieJar(loop=self.common_loop)
Expand Down
2 changes: 1 addition & 1 deletion wwqLyParse/common/simplepool.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def spawn(self, call_method, *k, **kk):
def join(self, *k, timeout=None, **kk):
while True:
try:
return _wait(self.pool_threads, timeout)
return wait(self.pool_threads, timeout)
except ValueError:
pass

Expand Down
2 changes: 1 addition & 1 deletion wwqLyParse/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6.3
1.6.4

0 comments on commit 6db8a83

Please sign in to comment.