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
It is always preferable to clean up even if a keyboardinterrupt has been raised, because the user may catch the keyboardinterrupt in his code and continue to use httpcore.ConnectionPool.
For such cases we should refer to where those objects will re-use if we don't cleanup immediately. For example:
try:
connection=awaitstatus.wait_for_connection(timeout=timeout)
except (Exception, self._cancelled_exc) asexc:
# If we timeout here, or if the task is cancelled, then make# sure to remove the request from the queue before bubbling# up the exception.asyncwithself._pool_lock:
# Ensure only remove when task exists.ifstatusinself._requests:
self._requests.remove(status)
raiseexc
This will cleanup status in self._requests immediately if an exception occurred, IMO the well based cleanup system should not block the process, we should do the cleanup when the object needs to be cleaned, re-used again, (e.g. for current example we should check where self._requests accessed then do the cleanups.)
What I mean from block the process?
Assume user hit Ctrl+C, he expects get reaction fast and don't care about cleanups, so we should not wait for cleanup that is maybe IO blocking process.
So when do the cleanups?
Answer is object needed to be cleaned, where accessed again, there we should check if object needs to be cleaned or not!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Ref: #805
Originally posted by @karosis88 in #805 (reply in thread)
For such cases we should refer to where those objects will re-use if we don't cleanup immediately. For example:
This will cleanup
status
inself._requests
immediately if an exception occurred, IMO the well based cleanup system should not block the process, we should do the cleanup when the object needs to be cleaned, re-used again, (e.g. for current example we should check where self._requests accessed then do the cleanups.)What I mean from block the process?
Assume user hit
Ctrl+C
, he expects get reaction fast and don't care about cleanups, so we should not wait for cleanup that is maybe IO blocking process.So when do the cleanups?
Answer is object needed to be cleaned, where accessed again, there we should check if object needs to be cleaned or not!
Beta Was this translation helpful? Give feedback.
All reactions