Multi-Threading or Multiprocessing with Arduino?

Jetson Nano 4GB
Deepstream 5.1
Jetpack 4.5.1

I am running object detection using deepstream sdk python-scripts I pass on the meta data. Specifically the rect.params data with class ID to an Arduino connected via UART USB. Since UART is slow the program can’t run sequentially because this will create a bottle neck as my program waits on the slow communication of UART. This now causes a drop in frames while the object is detected, using SPI (faster than UART communication protocol) reduces the drop in frames but the drop is still considerable, So I plan on using multi-threading/multiprocessing to run the code concurrently/parallelly.

The problem is the two functions

    while l_obj is not None:
                # Casting to pyds.NvDsObjectMeta
            except StopIteration:
            obj_meta.rect_params.border_color.set(0.0, 0.0, 1.0, 0.0)
            rect_params = obj_meta.rect_params
            list_set = {int(,int(rect_params.left),int(rect_params.height) 
            list_ = list(list_set)

and my custom function

    link = txfer.SerialTransfer('/dev/ttyACM0')
    time.sleep(2) # allow some time for the Arduino to completely reset

    send_size = 0
    list_size = link.tx_obj(list_)
    send_size += list_size

So the Solution I am hoping to find is to run this smoothly either via multi-(threading/Processing)

For clarification:
The def osd_sink_pad_buffer_probe(pad,info,u_data): runs faster than object_cords() function so I need an exception case to handle errors when the osd_buffer functions gives inputs which the serial transfer can’t pass because of the UART speed limitations.

Is the question : you should choose Multi-Threading or Multiprocessing to run the application smoothly?

If it’s, why Multi-Threading or Multiprocessing could improve the application perf?

Yes , that is it the question .

if the data transfer throughput is slower than the data genarted by the pipeline and you want to send out all the data , I don’t think multi-(threading/Processing) can help that, i.e. the data transferring must block the pipeline.

So can I run the osd_buffer pipeline on the main thread and start the transferring function on another thread initialized in the python script?

yes, you could initiate another thread for data transfer.