SarkariResultess QA Bank

Python में retry logic के लिए simple loop pattern क्या है? — error आने पर developer क्या करे?

Other 0 Views Verified
Python में retry logic के लिए simple loop pattern क्या है? — error आने पर developer क्या करे?
Sarkari Result QA Bank
Editorially reviewed exam information

Answer & Explanation

4 Answers
Verified

while True with no exit

while True with no exit
Additional Explanation
यह विकल्प सही समाधान नहीं है।
Verified Correct Answer

for attempt in range(3): try: call() break except Exception: if attempt == 2: raise

for attempt in range(3): try: call() break except Exception: if attempt == 2: raise
Additional Explanation
Bounded retries infinite retry loop से safer हैं। पहले traceback की exact line और input value check करें।
Verified

call() only once

call() only once
Additional Explanation
यह विकल्प सही समाधान नहीं है।
Verified

retry forever without limit

retry forever without limit
Additional Explanation
यह विकल्प सही समाधान नहीं है।