Pyftdi issue with multiprocessing

221 views Asked by At

I'm currently using a FT232H Breakout board (USB GPIO) from Adafruit that I am controlling with Pyftdi in Windows, using the libusbK 3.0.7 driver installed through ZADIG. It's working just fine in every aspect, but for this particular project I need to use the multiprocessing module. However, I can't get Pyftdi to work with it. To replicate my issue, you can just run this bit of code.

import multiprocessing as mp

import board

def func():
    print('This will crash')

p1 =  mp.Process(target=func)

p1.start()
p1.join()
p1.terminate

From what I can gather, the problem is that when instanciating a new process, Python will once again import the board module, required to run the FT232H, and will attempt to claim it's USB interface which is already claimed, throwing this error:

pyftdi.ftdi.FtdiError: UsbError: [Errno None] b'libusb0-dll:err [claim_interface] could not claim interface 0, win error: Cannot create a file when that file already exists.

However, if I write around this so that the board module is not imported a second time for the new process, any FT232H commands ran in the new process will not work.

Anyone has any ideas on how I can tackle this somehow?

0

There are 0 answers