Hi everyone.
when loosing the wlan-connection (e.g. i turn of the router) my programm hangs at :
response = urequests.post(db, data=payload,timeout=timeout_sec)
it is not raising a exception, the program hangs for ever at this line.
Any idea why?
How do you implement a simple post-command?
THX
Martin
I am using this urequests.py :
https://github.com/micropython/micropyt ... equests.py
urequests and timeout?
Re: urequests and timeout?
If you lose wifi connectivity it should throw an exception.
I would try wrapping the request in a try block and check to see if the wifi goes out and handle that exception. Here is a very basic example using a get request. If you're doing a post you should check if status_code != 201.
I would try wrapping the request in a try block and check to see if the wifi goes out and handle that exception. Here is a very basic example using a get request. If you're doing a post you should check if status_code != 201.
Code: Select all
while res.status_code != 200:
try:
gc.collect()
res = req.get(url=url)
gc.collect()
except:
# no internet connection on chip
if not wlan_sta.isconnected():
time.sleep(30)
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: urequests and timeout?
I wish it were so. You might like to read my observations on this issue.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.