From c0d901ec72382a41df1476805288547877b4bf5a Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 28 Feb 2024 17:53:44 +0800 Subject: [PATCH] bugfix --- appPublic/httpclient.py | 4 +++- appPublic/worker.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/appPublic/httpclient.py b/appPublic/httpclient.py index 69734da..f59925f 100755 --- a/appPublic/httpclient.py +++ b/appPublic/httpclient.py @@ -14,7 +14,9 @@ class HttpClient: self.cookies = {} async def close(self): - await self.session.close() + if self.session: + await self.session.close() + self.session = None def url2domain(self,url): parts = url.split('/')[:3] diff --git a/appPublic/worker.py b/appPublic/worker.py index 7e2b5ec..7c7b183 100755 --- a/appPublic/worker.py +++ b/appPublic/worker.py @@ -57,7 +57,8 @@ if __name__ == '__main__': async def run(): w = AsyncWorker() - g = [ asyncio.create_task(w(hello,i,'hello world')) for i in range(100) ] + f = awaitify(hello) + g = [ asyncio.create_task(w(f,i,'hello world')) for i in range(100) ] await asyncio.wait(g) print('aaaaaaaaaaaaaaaaaaa')