Improve depthai-core's responsiveness upon a device crash or a node error, attempt 2 #1424
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are several shortcomings in the changes introduces PR1404. Specifically the use of detached threads is a potentially problematic element that could lead to data races or invalid memory accesses (i.e. accesses to already deleted chucks of memory)
This PR tries to mitigate that by introducing a new attribute to the
DeviceBase
andPipelineImpl
classes calledshouldCloseQuickly
indicating that threads and other long-running methods should return as quickly as possible without sacrificing memory access safety and program correctness.I've done extensive testing and the responsiveness of
depthai
-based python scripts has increased dramatically, with programs now typically reacting to keyboard interrupts within a single second as opposed to tens of seconds without the changes in this PR.Finally, just like PR1404, this PR introduces a tiny fix where the crashdump collection timeout was set to 9000 seconds (2.5 hours). The intended unit of time in this case was presumably meant to be milliseconds.