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

GC deadlock on subprocess #1461

Closed
marecik16 opened this issue Nov 15, 2018 · 2 comments
Closed

GC deadlock on subprocess #1461

marecik16 opened this issue Nov 15, 2018 · 2 comments

Comments

@marecik16
Copy link

marecik16 commented Nov 15, 2018

Hello community! Can you help me?
I have a strange problem with Python for Android and I have short demo

from jnius import autoclass

import os
import signal
import multiprocessing
import time

def process():
    Runtime = autoclass("java.lang.Runtime")
    print("Starting GC...")
    Runtime.getRuntime().gc()
    print("GC done.")

print("STARTED")
while True:
    newProcess = multiprocessing.Process(target=process)
    newProcess.start()
    time.sleep(1)
    
    if newProcess.is_alive():
        print("      GC DEADLOCK!!!!????????")
        pid = newProcess.pid
        os.kill(pid, signal.SIGKILL)
    newProcess.join()

basically if I started a new python subprocess, then SOMETIMES the garbage collector freezes inside.
You can change the sleeping time in the above code and a result would be the same - some of the subprocesses never return from GC.
Tested with the new version of p4a & jnius, bootstrap=sdl2, python3crystax, arch=armeabi-v7a and a three complete different smartphones with Android 6/7/8

@marecik16
Copy link
Author

Well, can you at least confirm my problem at your device?

@tito
Copy link
Member

tito commented Nov 20, 2018

Android doesn't like any kind of fork. At least that was the case before, dunno if it has evolved since.
If you do Android, then go services and communicate between your app / services, don't use multiprocessing.

I never though to write or think that a such example would work :)

@Julian-O Julian-O closed this as not planned Won't fix, can't repro, duplicate, stale Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants