Files
uiautomator2/examples/multi-thread-example.py
codeskyblue 021c391182 Poetry (#945)
limit python version >= 3.8
use poetry instead of pbr, setup.py
remove some useless deps
add github.actions.test matrix, include mac, linux, windows (3.8-3.11)
remove extra option [image] for pip install uiautomator[image]
2024-03-20 15:32:03 +08:00

30 lines
749 B
Python

# coding: utf-8
#
# GIL limit python multi-thread effectiveness.
# But is seems fine, because these operation have so many socket IO
# So it seems no need to use multiprocess
#
import threading
import adbutils
from logzero import logger
import uiautomator2 as u2
def worker(d: u2.Device):
d.app_start("io.appium.android.apis", stop=True)
d(text="App").wait()
for el in d.xpath("@android:id/list").child("/android.widget.TextView").all():
logger.info("%s click %s", d.serial, el.text)
el.click()
d.press("back")
logger.info("%s DONE", d.serial)
for dev in adbutils.adb.device_list():
print("Dev:", dev)
d = u2.connect(dev.serial)
t = threading.Thread(target=worker, args=(d,))
t.start()