I'm working with a piece of hardware that must be stopped and started at different intervals. Unfortunately, it doesn't teardown gracefully, so restarting within the same process results in libusb errors. One workaround would be to move the configuration of the hardware to a different process, and stop/start the process when required.

What would be the best way to do this in Python?

有帮助吗?

解决方案

The pickle module allows you to serialize objects to a string, so you can transfer it via the disk or a socket.

You could also use multiprocessing, which is intended for parallelism, but could be used here too. (Actually, multiprocessing relies on pickle.)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top