This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eleven.xiang
Recipients eleven.xiang, vstinner
Date 2021-09-29.02:56:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1632884178.9.0.985009138374.issue45308@roundup.psfhosted.org>
In-reply-to
Content
I still have some questions about is, so re-open it.

You mean it is the fork principle, but if change the script to use os.fork(), the child process will inherit from parent, and also free it.

You could refer below change:


from ctypes import cdll
import multiprocessing as mp
import os

def foo():
    handle = cdll.LoadLibrary("./test.so")
    handle.IncA()

if __name__ == '__main__':
    foo()
    #p = mp.Process(target = foo, args = ())
    #p.start()
    #print(p.pid)
    #p.join()

    pid = os.fork()
    if pid == 0:
        foo()
    else:
        os.waitpid(pid, 0)
History
Date User Action Args
2021-09-29 02:56:18eleven.xiangsetrecipients: + eleven.xiang, vstinner
2021-09-29 02:56:18eleven.xiangsetmessageid: <1632884178.9.0.985009138374.issue45308@roundup.psfhosted.org>
2021-09-29 02:56:18eleven.xianglinkissue45308 messages
2021-09-29 02:56:18eleven.xiangcreate