I have a script which could be run 1,2... x number of times in parallel.
foo.py &
foo.py &
...
Each script has to check the existence of a piece of hardware (open all found FTDI device, read some data, close it). foo.py checks for FTDI devices once a second & then sleeps (what happens next is user chooses one to connect to).
Now obviously each instance cannot open the same FTDI device at the same time so I am in need of some form of "communication" for locking purposes.
What I have considered so far
- locking file (slow... but if I have to)
- sockets (I can use the condition that if a socket is open then a foo.py instance is querying the USB bus for ftdi devices)
- python's multiprocessing library & Lock (I however cannot see how this could work since no way to share the existence of x number of foo.py's running)
Anyone have any ideas?