This commit is contained in:
yumoqing 2024-02-28 17:53:44 +08:00
parent 52ae7b8187
commit c0d901ec72
2 changed files with 5 additions and 2 deletions

View File

@ -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]

View File

@ -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')