Ask coding questions

← Back to all posts
Handle timeout error
QuantumCodes (25)

so, i wanted to detect whether a link exists or not (or) if it exists but the person has not run the repl. (I am making a pinger)

Repl example: https://Pinger-testing.quantumcodes.repl.co/

If the repl isnt running, then the requests.get("https://Pinger-testing.quantumcodes.repl.co/") just doesnt respond anything... so i put a timeout requests.get("https://Pinger-testing.quantumcodes.repl.co/",timeout=3) but that gives a huge error... how do i continue the program? (Pls a simple solution)

Update: seems like i figured out how to continue... but i would not know what was the error in my method...

Answered by AntarcticaAdv (36) [earned 5 cycles]
View Answer
Comments
hotnewtop
AntarcticaAdv (36)

If you want to show the error try this:

import requests
try:
  x = requests.get("https://Pinger-testing.quantumcodes.repl.co/",timeout=3)
except Exception as e:
  print(e)
InvisibleOne (3213)


It didn't give me an error.

QuantumCodes (25)

Sorry, i fixed it... do after removing try annd except @InvisibleOne

QuantumCodes (25)

a code with the answer will be helpful