<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[Solved]Exceptions &amp; timeouts with GET Requests]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Thanks everyone on this forum for their help. Currently finishing off my project. However, somtimes my GET request fails, and it's causing my device to crash. What's the proper way to set a timeout or catch an error?</p>
<p dir="auto">I'm currently trying the following.</p>
<pre><code>try:
        lResponse = urequests.get( URL , headers = self.fHeaders )
        content = ujson.loads( lResponse.content )
        return abs( content )
    except:
        return 0
</code></pre>
<p dir="auto">However, this doesn't seem to be solving it.  Any pointers would be greatly appreciated.</p>
<p dir="auto">Kind Regards,<br />
Fox</p>
]]></description><link>https://community.m5stack.com/topic/967/solved-exceptions-timeouts-with-get-requests</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 11:06:06 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/967.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 30 Apr 2019 07:47:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Solved]Exceptions &amp; timeouts with GET Requests on Tue, 31 Dec 2019 15:30:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/foxhound" aria-label="Profile: foxhound">@<bdi>foxhound</bdi></a> What about adding some hints if it fails return_code for example. I'm asking because the connection seems not to be stable...</p>
]]></description><link>https://community.m5stack.com/post/6819</link><guid isPermaLink="true">https://community.m5stack.com/post/6819</guid><dc:creator><![CDATA[Efried]]></dc:creator><pubDate>Tue, 31 Dec 2019 15:30:43 GMT</pubDate></item><item><title><![CDATA[Reply to [Solved]Exceptions &amp; timeouts with GET Requests on Thu, 02 May 2019 23:05:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/m5-docs" aria-label="Profile: m5-docs">@<bdi>m5-docs</bdi></a> so it turns out I was forgetting to close the response.</p>
<pre><code>try:
    lResponse = urequests.get( URL , headers = self.fHeaders )
    content = ujson.loads( lResponse.content )
    lResponse.close()
    return abs( content )
except:
    return 0
</code></pre>
<p dir="auto">Solved the issue.</p>
]]></description><link>https://community.m5stack.com/post/4097</link><guid isPermaLink="true">https://community.m5stack.com/post/4097</guid><dc:creator><![CDATA[Foxhound]]></dc:creator><pubDate>Thu, 02 May 2019 23:05:39 GMT</pubDate></item><item><title><![CDATA[Reply to [Solved]Exceptions &amp; timeouts with GET Requests on Tue, 30 Apr 2019 23:28:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/m5-docs" aria-label="Profile: m5-docs">@<bdi>m5-docs</bdi></a> said in <a href="/post/4068">Exceptions &amp; timeouts with GET Requests</a>:</p>
<blockquote>
<p dir="auto">pass</p>
</blockquote>
<p dir="auto">Thanks for your response, but a little confused with how this differs from mine?</p>
<p dir="auto">I'd love to do a timeout, is there a way to write a function that will timeout, similar to eventlib in Python? Or is there a different way I am supposed to be doing a get request that won't block.</p>
]]></description><link>https://community.m5stack.com/post/4080</link><guid isPermaLink="true">https://community.m5stack.com/post/4080</guid><dc:creator><![CDATA[Foxhound]]></dc:creator><pubDate>Tue, 30 Apr 2019 23:28:08 GMT</pubDate></item><item><title><![CDATA[Reply to [Solved]Exceptions &amp; timeouts with GET Requests on Tue, 30 Apr 2019 08:14:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/foxhound" aria-label="Profile: foxhound">@<bdi>foxhound</bdi></a></p>
<pre><code>try:
        lResponse = urequests.get( URL , headers = self.fHeaders )
        content = ujson.loads( lResponse.content )
        return abs( content )
    except:
        # print("GET failed.") # you need print some information to serial monitor. I just take an example. or write some code for catching timeout error
        pass
</code></pre>
]]></description><link>https://community.m5stack.com/post/4068</link><guid isPermaLink="true">https://community.m5stack.com/post/4068</guid><dc:creator><![CDATA[m5-docs]]></dc:creator><pubDate>Tue, 30 Apr 2019 08:14:36 GMT</pubDate></item></channel></rss>