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
While the pattern of scoped_iter and aclosing solves resource leaks (see PEP 533 as always) it feels a bit unwieldy to use. Many functions need the resource in the entire scope and only scope it as a safety measure, not for functionality. The explicit async with for scoping increases the indentation level and pulls in unrelated resource management; a practical shortcoming is that adding scoping leads to a diff of the entire function due to indent.
It would be interesting to have a decorator to automatically scope arguments to the entire function:
This isn't quite straightforward, since it needs a mechanism to identify which arguments to scope how. For example, many utilities of asyncstdlib itself take *iterables: AnyIterable[T] and would have to scope each iterable.
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
-
While the pattern of
scoped_iter
andaclosing
solves resource leaks (see PEP 533 as always) it feels a bit unwieldy to use. Many functions need the resource in the entire scope and only scope it as a safety measure, not for functionality. The explicitasync with
for scoping increases the indentation level and pulls in unrelated resource management; a practical shortcoming is that adding scoping leads to a diff of the entire function due to indent.It would be interesting to have a decorator to automatically scope arguments to the entire function:
This isn't quite straightforward, since it needs a mechanism to identify which arguments to scope how. For example, many utilities of
asyncstdlib
itself take*iterables: AnyIterable[T]
and would have to scope each iterable.Beta Was this translation helpful? Give feedback.
All reactions