Viewing multiple USB or IP cameras simultaneously with OpenCV

I am looking for some guidance and/or sample Python code on running multiple USB or IP cameras simultaneously with OpenCV.
My application will use either 4 cameras connected to a PC via a USB hub and/or 4 IP cameras o the same local network as the PC.
Examples that I found on the Internet show grabbing frames sequentially on the same thread or using multiple threads.
Does officially support the multiple camera captures? Where can I find some working/validated code? If no code is available, I’d appreciate some guidance on how to make it work.

sure, opencv supports opening multiple cameras. use one VideoCapture object per source.

frame rates never perfectly match in practice. it’s the same problem as in socket programming.

if you simply ran it all in lockstep, reading one frame from every camera, the slowest would hold all the others up, which would eventually run out of buffer and give up.

to handle that properly, you have to read each camera as soon as possible.

OpenCV recently gained waitAny:

wtf it’s not exposed to python. that’s a bummer! you could open an issue about it. it might be an easy fix.

before that, people had to use multiple threads and synchronization primitives to do the job.

Thanks for your feedback.
I typically program in Python, but I am willing to give C++ a try and use this new function.

I welcome any other feedback from others if any.
Thanks again.