Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; '"""': 0.07; 'attribute': 0.07; 'problem?': 0.07; "subject:' ": 0.07; 'msg': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:module': 0.09; 'def': 0.12; "%s'": 0.16; '32)': 0.16; 'appear?': 0.16; 'fork': 0.16; 'msg)': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:object': 0.16; 'true:': 0.16; 'wrote:': 0.18; 'module': 0.19; 'help.': 0.21; 'import': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; 'url:dev': 0.24; 'code:': 0.26; 'skip:" 20': 0.27; 'header:X-Complaints-To:1': 0.27; 'os,': 0.31; 'file': 0.32; 'url:python': 0.33; '(most': 0.33; 'hi,': 0.36; 'url:org': 0.36; 'wrong': 0.37; 'operating': 0.37; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'solve': 0.60; 'kindly': 0.61; 'line,': 0.68; 'subject:skip:A 10': 0.78 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: AttributeError: 'module' object has no attribute 'fork' Date: Thu, 07 Aug 2014 09:00:23 +0200 Organization: None References: <7bd83ac7-17e6-49c2-b5c7-3236c900d005@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p57bd96ab.dip0.t-ipconnect.de User-Agent: KNode/4.13.2 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407394838 news.xs4all.nl 2962 [2001:888:2000:d::a6]:46701 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75837 Satish ML wrote: > Hi, > > Code: > import os, time > def child(pipeout): > zzz = 0 > while True: > time.sleep(zzz) > msg = ('Spam %03d' % zzz).encode() > os.write(pipeout, msg) > zzz = (zzz+1) % 5 > def parent(): > pipein, pipeout = os.pipe() > if os.fork() == 0: > child(pipeout) > else: > while True: > line = os.read(pipein, 32) > print('Parent %d got [%s] at %s' % (os.getpid(), line, > time.time())) > parent() > > Output: > Traceback (most recent call last): > File "C:/Python34/pipe1.py", line 17, in > parent() > File "C:/Python34/pipe1.py", line 11, in parent > if os.fork() == 0: > AttributeError: 'module' object has no attribute 'fork' > > Why does this error appear? Module os provides fork(). How to solve this > problem? Kindly help. Quoting : """ os.fork() Fork a child process. ... Availability: Unix. """ You are using the wrong operating system ;)