Question

I have a method, that uses try/catch to request with requests some urls.

If a timeout occurs (in the except), how can I modify my code to just continue to the next req in the for loop?

I've tried doing some homework with pass, break statements in python, but neither seemed to be a good fit.

try:
    request = requests.get(the_path, timeout=1.0, verify=False)
        for req in request:
            if inst.val in req:
                print req
except requests.exceptions.Timeout:
    print 'We timed out'
    <somehow continue to next iteration of req>

Can someone enlighten me on how to do this? Thank you

Was it helpful?

Solution

I think what you are looking for is the continue statement.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top