@@ -24,30 +24,20 @@ class UninitializedError(CustomError):
2424
2525
2626class HttpClient :
27- __create_key = object ()
28-
29- @classmethod
30- async def create (cls , client_configuration : ClientConfiguration ) -> 'HttpClient' :
31- session = aiohttp .ClientSession (
32- timeout = aiohttp .ClientTimeout (
33- connect = client_configuration .timeout_seconds ,
34- sock_read = client_configuration .timeout_seconds
35- )
36- )
37-
38- return cls (HttpClient .__create_key , client_configuration , session )
39-
4027 def __init__ (
4128 self ,
42- create_key ,
43- client_configuration : ClientConfiguration ,
44- session : aiohttp .ClientSession
29+ client_configuration : ClientConfiguration
4530 ):
46- assert create_key == HttpClient .__create_key , \
47- 'HttpClient objects must be created using HttpClient.create.'
48-
4931 self .__client_configuration : ClientConfiguration = client_configuration
50- self .__session : ClientSession = session
32+ self .__session : ClientSession | None = None
33+
34+ async def initialize (self ) -> None :
35+ self .__session = aiohttp .ClientSession (
36+ timeout = aiohttp .ClientTimeout (
37+ connect = self .__client_configuration .timeout_seconds ,
38+ sock_read = self .__client_configuration .timeout_seconds
39+ )
40+ )
5141
5242 async def close (self ):
5343 if self .__session is not None :
0 commit comments