MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / disable_on_exception

Method disable_on_exception

pager_lib/tqdm/utils.py:188–211  ·  view source on GitHub ↗

Quietly set `tqdm_instance.miniters=inf` if `func` raises `errno=5`.

(tqdm_instance, func)

Source from the content-addressed store, hash-verified

186 """
187 @staticmethod
188 def disable_on_exception(tqdm_instance, func):
189 """
190 Quietly set `tqdm_instance.miniters=inf` if `func` raises `errno=5`.
191 """
192 tqdm_instance = proxy(tqdm_instance)
193
194 def inner(*args, **kwargs):
195 try:
196 return func(*args, **kwargs)
197 except OSError as e:
198 if e.errno != 5:
199 raise
200 try:
201 tqdm_instance.miniters = float('inf')
202 except ReferenceError:
203 pass
204 except ValueError as e:
205 if 'closed' not in str(e):
206 raise
207 try:
208 tqdm_instance.miniters = float('inf')
209 except ReferenceError:
210 pass
211 return inner
212
213 def __init__(self, wrapped, tqdm_instance): # noqa: B042
214 super().__init__(wrapped)

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected