Understanding How Threading Writes to File in Autopilot #197
Replies: 3 comments 5 replies
-
|
This is where that magic happens: autopilot/autopilot/data/subject.py Line 716 in 04b5968 A thread is created that runs the function _data_thread (defined later in the same file). It receives data in a queue, saved as autopilot/autopilot/agents/terminal.py Line 591 in 04b5968 Because _data_thread runs in its own thread, if that thread crashes, then you will have an unpleasant scenario where everything seems to be working fine, but nothing is actually written to disk. For that reason, the whole data thread is wrapped in try/except, which is intended to keep it from crashing, although I think a SegmentationFault can still bring it down. A separate thread is used for plotting, and it receives data in a slightly different way, information is sent directly to that plotting object by its networking handle. That happens in a couple of places. The plotting networking handle begins with "P_" so you can find the relevant lines by searching for that. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
I'm messing around this evening with threads again and trying to understand the magic of continuous data recordings. And I just can't seem to understand how it works... I'm pretty confused about how the pi is set to sample pins at the appropriate timing interval. For example, if you just want like 1 sample per second how does Autopilot know how often to sample the GPIO? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello fellow pilots!
Now that I've finished applying to graduate school, I want to spend my evenings/weekends trying to understand the design of how Autopilot uses threads to write data to HDF5 files. I was taking a multithreading course on Udemy before this application craziness got in the way, but I can't seem to get a handle on how autopilot is capable of piping information into a file while also running all these other tasks.
In short, concurrency is hard for me and I'm having trouble understanding how threading is used to gather "long form" data streams and write it to file.
Beta Was this translation helpful? Give feedback.
All reactions