Search code examples
pythonmultithreadingsocketskivy

How to make an application from two python programs?


I have two python programs which one of them connects to a bluetooth device(socket package), it receives and saves data from device, and another one read the stored data and draw a real time plot. I should make one application from these two programs.

I tried to mix these two python programs, but since bluetooth should wait to receive data (through a while loop), the other parts of program does not work. I tried to solve this problem using Clock.schedule_interval, but the program will hang after a period of time. So I decided to run these two programs simultaneously. I read, we can run some python programs at a same time using a python script. Is there any trick to join these two programs and build one application? Any help would be greatly appreciated.


Solution

  • Install threaded:

    pip install threaded
    

    Create a new python file:

    from threading import Thread
    
    def runFile1(): import file1
    def runFile2(): import file2
    
    Thread(target=runFile1).start()
    runFile2()
    

    Run the new python file.