Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python multithreading ios-deploy with subprocess hangs #589

Open
SachaTe opened this issue Jul 26, 2023 · 1 comment
Open

Python multithreading ios-deploy with subprocess hangs #589

SachaTe opened this issue Jul 26, 2023 · 1 comment

Comments

@SachaTe
Copy link

SachaTe commented Jul 26, 2023

Command Executed

Running the following via python threads;

ios-deploy --id --bundle --noinstall --bundle_id <BUNDLE_ID> --noninteractive --args --version

Expected behavior

Print the device version and return for all devices.

Actual behavior.

Prints the device version and freezes, although the app has terminated and I see the PROCESS_EXITED bring printed, as follows;

     (lldb)     connect
     (lldb)     run
     success
     (lldb)     autoexit
    1.0.12
    
     PROCESS_EXITED

This issue does not occur when running multiple ios-deploy instances in parallel via bash. However it occurs when running via multi-threads on python.

Out of all the devices running on in parallel, it only passes for the last device to be executed. For example if I execute 5 threads for 5 different iphones, only the 5th thread will return.

This code used to run properly as we have been using it for over a year. Only recently (a few weeks ago) it broke. Seems to be broken on multiple macbooks.

Steps to reproduce the problem

import concurrent.futures
import subprocess

APP_LOCATION = "APP_LOCATION"
BUNDLE_ID = "BUNDLE_PATH"

def run_quiet(args, id):
    print(f"========= Starting {id} =========")
    print(" ".join(args))

    result = subprocess.run(
        args,
        universal_newlines=True,
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT,
    )

    print(result.stdout)

    print(f"========= COMPLETED {id} =========")


def thread(id):
    version_cmd = [
        "ios-deploy",
        "--id",
        f"{id}",
        "--bundle",
        APP_LOCATION,
        "--noinstall",
        "--bundle_id",
        BUNDLE_ID,
        "--noninteractive",
        "--args",
        "--version",
    ]
    run_quiet(version_cmd, id)


list = [
    "REDACTED-ID-1",
    "REDACTED-ID-2",
]

with concurrent.futures.ThreadPoolExecutor() as executor:
    futures = [executor.submit(thread, id) for id in list]

concurrent.futures.wait(futures)

System Specs

This occurs on multiple devices

  1. system_profiler SPSoftwareDataType

    Software:
    
    System Software Overview:
    
      System Version: macOS 13.5 (22G74)
      Kernel Version: Darwin 22.6.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: <REMOVED>
      User Name: <REMOVED>
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled
      Time since boot: 16 hours, 45 minutes
    
  2. ios-deploy -V

    1.12.2
    
  3. xcodebuild -version (please note, attempted this with XCode 14.3 as well)

    Xcode 15.0
    Build version 15A5209g
    
  4. xcode-select --print-path

    /Applications/Xcode.app/Contents/Developer
    
  5. gcc --version

    Apple clang version 15.0.0 (clang-1500.0.38.1)
    Target: arm64-apple-darwin22.6.0
    Thread model: posix
    InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
    
  6. lldb --version

    lldb-1500.0.20.2
    Apple Swift version 5.9 (swiftlang-5.9.0.124.4 clang-1500.0.38.1)
    
@SachaTe SachaTe changed the title Python multithreading ios-deploy hangs when running bundle app Python multithreading ios-deploy with subprocess hangs Jul 26, 2023
@gabebear
Copy link

gabebear commented Aug 7, 2023

Is there a reason you need multiple threads?

The python interpreter is just the one shipped as part of LLDB along with Xcode. I'm not sure it supports multithreading(it's not easy to search since SOOO much of the documentation is about how to debug specific threads). The main documentation is at https://lldb.llvm.org/use/python-reference.html and running Python through LLDB on an iPhone should be the same as running Python via LLDB on your local computer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants