Skip to content

Blocking Call Error #419

Answered by craigbarratt
tejasitraj asked this question in Q&A
Dec 30, 2022 · 3 comments · 1 reply
Discussion options

You must be logged in to vote

pyscript uses the hass main event loop, so you should not do anything that can block (eg, network requests). See the documentation.

Instead of requests, the best solution is to use aiohttp (see the 3rd example).

Also, unrelated to your question, your loop could be more compact by using get to fetch dict values, since it allows a default value, eg:

try:
    origin = find_origin_destination(aircraft["r"])[0]
except:
    origin = "-"
row_data = {
    "Airspeed": aircraft.get("tas", "-"),
    "Altitude": aircraft.get("alt_baro", "-"),
    "Origin": origin,
    ...
}

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by tejasitraj
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@craigbarratt
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants