Detected I/O inside the event loop
See original GitHub issueHi What about this warning in the log? It’s my fault?
WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for pyscript doing I/O at custom_components/pyscript/eval.py, line 1143: return func(*args, **kwargs)
Thank you
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Detected I/O inside the event loop · Issue #232 - GitHub
In HomeAssistant 0.109.0b0 I have the folowing warning: Log Details (WARNING) Logger: homeassistant.util.async_. Source: util/async_.py:120
Read more >Detected i/o inside the event loop - Home Assistant Community
I'm using the abandoned gtask custom component since there's no todo lists integration. I'm having the following warning making it quite ...
Read more >The event loop - JavaScript - MDN Web Docs - Mozilla
JavaScript has a runtime model based on an event loop, which is responsible for executing the code, collecting and processing events, ...
Read more >Event Loop — Python 3.11.1 documentation
Event loops run asynchronous tasks and callbacks, perform network IO operations, and run subprocesses. Application developers should typically use the high- ...
Read more >Detect an idle asyncio event loop - Stack Overflow
Say that my execution path branches in some complex way, say, using asyncio.gather(), but I know that each branch eventually awaits some idle ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
One more comment before I close this issue. If you need to do I/O from pyscript, the best solution is to find a package that is native async-based and use that. For example, instead of
requests
orurllib.request.urlopen
, consider usingaiohttp
instead.Looking at the client examples in
aiohttp
, you can fetch a URL with (there’s no need to include theawait
keyword; it is optional in pyscript):This is supported in the master code, but not the current release 0.21. So if you want to use
async with
you’ll need to run the master version instead of 0.21.I pushed a change 5908b4b that adds a new function,
task.executor()
. You can use that to call functions in packages that do I/O.task.executor()
calls the function usingrun_in_executor()
, which runs the function in a thread instead of the event loop.Its arguments are the function to call, and the arguments that should be passed to that function. So instead of doing something like:
you should do this instead:
There is no need to use
task.executor()
when the following code usesresp.text
orresp.status_code
since those don’t do I/O.This is an experimental feature at this point. Please tell me if it fixes the warning you saw.