MCPcopy
hub / github.com/tornadoweb/tornado / __new__

Method __new__

tornado/httpclient.py:198–214  ·  view source on GitHub ↗
(cls, force_instance: bool = False, **kwargs: Any)

Source from the content-addressed store, hash-verified

196 return getattr(cls, attr_name)
197
198 def __new__(cls, force_instance: bool = False, **kwargs: Any) -> "AsyncHTTPClient":
199 io_loop = IOLoop.current()
200 if force_instance:
201 instance_cache = None
202 else:
203 instance_cache = cls._async_clients()
204 if instance_cache is not None and io_loop in instance_cache:
205 return instance_cache[io_loop]
206 instance = super().__new__(cls, **kwargs) # type: ignore
207 # Make sure the instance knows which cache to remove itself from.
208 # It can't simply call _async_clients() because we may be in
209 # __new__(AsyncHTTPClient) but instance.__class__ may be
210 # SimpleAsyncHTTPClient.
211 instance._instance_cache = instance_cache
212 if instance_cache is not None:
213 instance_cache[instance.io_loop] = instance
214 return instance
215
216 def initialize(self, defaults: Optional[Dict[str, Any]] = None) -> None:
217 self.io_loop = IOLoop.current()

Callers

nothing calls this directly

Calls 2

currentMethod · 0.80
_async_clientsMethod · 0.80

Tested by

no test coverage detected