简体   繁体   中英

I'm getting AttributeError: 'module' object has no attribute 'fork' when i run my program on windows. How can i fix this?

I tried calling the os.fork() in the parent() funtion but yet it gives me the same error.

this is my code:

import os

def child():
    print('Hello from child', os.getpid())
    os._exit(0) # else goes back to parent loop

def parent():
    while True:
        newpid = os.fork()
        if newpid == 0:
            child()
        else:
            print('Hello from parent', os.getpid(), newpid)
        if input() == 'q': break

parent()

os.fork() is only available in Unix. See this .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM