Linux as shipped with the Pi is not a real time operating system but version do exist called RTOS or RT Linux and some kernel mods for the Pi have been seen in the wild to give some added ability.
Add onto this, Python is an interpreted language and can suffer from the Global Interpreter locking threads let alone from the OS wanting the CPU for its own tasks.
Python brings its own multi-threading and multi-process libraries to help getting more than one thing done.
You are always limited by the OS, devices attached to the CPU and native programming so ‘real-time’ is not something a multitasking computer is very good at.
In your case, it is always possible to lose data (see Tom Scott on YouTube for why no message can be 100% guaranteed) and this is why check routines and hardware signalling has been part of computing since day one.
Remember some communications subsystems on the Pi are handled by the OS (disk / serial / USB) and they operate at speeds in excess of normal GPIO based data transfers by building in checks and correct hardware design.
If you are looking for robust communication, you need to look at:
- Interrupt driven capture so the link disrupts the normal program flow not the other way around.
- Limiting what the machine is doing outside of data communications
- Have a fast enough processor and memory and disk etc etc to handle all the demands
- Building control signalling (either hardware or software) into the link
- Building checks into the data so you know it’s correct or not
- Look at using buffers (Python Queues being one way) where processing is separate from capture
- Look at using extra hardware to provide a buffer between the high speed data and the slow speed data.
I think you will be surprised as to the amount of data and speed the Pi can handle BUT it depends on the application and connections.