Reputation: 118
I'm helping develop a Python application which collects data from several sensors and manages a server to send those data to a web application (React) to display. The application is supposed to work on a Variscite board with Yocto.
My initial approach was based on multithreading, which worked fine on Windows and WSL, but on Yocto it went into the weirdest issues. Some methods executed up until the last line, but refused to return, literally just hanging at the return
line. In other places, data were put into queues, but an associated threading.Condition
failed to perform the notification.
We decided to try an asynchronous approach instead of multithreading, which seems to solve our issues so far. Unfortunately, the interface of one of our sensors, provided externally, inherently relies on threading
.
My question is, how bad (unsafe) would it be to have a threading
-asyncio
interface in the app? The idea would be to use threading
to collect data from the sensor and put them into a queue, which would then be periodically checked and consumed in an async way. Are there any precautions I can take to make it safer or ways to make it more elegant? I'm rather new to asyncio
, so even basic advice on that would be appreciated.
Upvotes: 0
Views: 64