I have two android devices connected to my Linux machine and I need to be able to take a screenshot on both at the exact same time. How can I achieve this in python? This is what I have so far:
import time, datetime
from threading import Thread
from Queue import Queue
def get_screenshot(deviceid):
print deviceid
print datetime.datetime.now()
# Logic to get screenshot goes here
deviceids = ["blabla1", "blabla2"]
q = Queue()
for d in deviceids:
t = Thread(target=get_screenshot, args=(d,))
t.setDaemon(True)
t.start()
for d in deviceids:
q.put(d)
q.join()
The output looks like this:
blabla1
2016-10-02 12:55:17.146964
blabla2
2016-10-02 12:55:17.147141
The problem is: 1. Is the approach correct? 2. Why the difference of 1ms? Can that be avoided? 3. This program does not exit. I need to Ctrl+Z out of it.