You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're currently considering whether to support non-AsyncContextManager usage in the BaseClient class. We've noted several potential issues associated with this, including the possibility of resource and memory leaks if BaseClient instances aren't properly shut down after use.
The main concerns are as follows:
Resource Leakage: HTTP clients typically open network connections to send requests. If a client isn't correctly closed, these connections could remain open, consuming system resources. Over time, if new clients are frequently created and not closed, this could lead to a gradual consumption of system resources, potentially causing performance issues or system errors.
Memory Leakage: Python's garbage collector usually releases memory occupied by an object when it's no longer referenced. However, if an object keeps references to system resources (like open files or network connections) and doesn't provide a method to release these resources, they might not be garbage collected, leading to memory leaks.
Application Errors: Some HTTP client libraries may throw an error when trying to destroy a client object that hasn't been correctly closed. This could cause application crashes or create hard-to-debug issues.
To avoid these problems, the best practice would be to always shut down BaseClient instances when they're no longer needed. Currently, we're using an AsyncContextManager to manage the lifecycle of our AsyncClient instances automatically, but we're considering whether we need to support non-AsyncContextManager usage as well.
We need to carefully consider the implications of this decision, as supporting non-AsyncContextManager usage could potentially introduce more complexity and opportunities for errors in our code. Please share your thoughts and insights on this matter.
The text was updated successfully, but these errors were encountered:
luoshuijs
changed the title
Decide on Supporting Non-AsyncContextManager Usage in BaseClient
Decide on Supporting Non-AsyncContextManager Usage in BaseClientJun 11, 2023
luoshuijs
changed the title
Decide on Supporting Non-AsyncContextManager Usage in BaseClient
✨ Decide on Supporting Non-AsyncContextManager Usage in BaseClientAug 6, 2023
We're currently considering whether to support non-AsyncContextManager usage in the BaseClient class. We've noted several potential issues associated with this, including the possibility of resource and memory leaks if BaseClient instances aren't properly shut down after use.
The main concerns are as follows:
Resource Leakage
: HTTP clients typically open network connections to send requests. If a client isn't correctly closed, these connections could remain open, consuming system resources. Over time, if new clients are frequently created and not closed, this could lead to a gradual consumption of system resources, potentially causing performance issues or system errors.Memory Leakage
: Python's garbage collector usually releases memory occupied by an object when it's no longer referenced. However, if an object keeps references to system resources (like open files or network connections) and doesn't provide a method to release these resources, they might not be garbage collected, leading to memory leaks.Application Errors
: Some HTTP client libraries may throw an error when trying to destroy a client object that hasn't been correctly closed. This could cause application crashes or create hard-to-debug issues.To avoid these problems, the best practice would be to always shut down BaseClient instances when they're no longer needed. Currently, we're using an AsyncContextManager to manage the lifecycle of our AsyncClient instances automatically, but we're considering whether we need to support non-AsyncContextManager usage as well.
We need to carefully consider the implications of this decision, as supporting non-AsyncContextManager usage could potentially introduce more complexity and opportunities for errors in our code. Please share your thoughts and insights on this matter.
The text was updated successfully, but these errors were encountered: