Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75837

Re: AttributeError: 'module' object has no attribute 'fork'

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 <python-python-list@m.gmane.org>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12720.1407394838.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


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 <module>
>     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 <https://docs.python.org/dev/library/os.html#os.fork>:

"""
os.fork()
Fork a child process.
...
Availability: Unix.
"""

You are using the wrong operating system ;)

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

AttributeError: 'module' object has no attribute 'fork' Satish ML <satishmlwizpro@gmail.com> - 2014-08-06 23:44 -0700
  Re: AttributeError: 'module' object has no attribute 'fork' Peter Otten <__peter__@web.de> - 2014-08-07 09:00 +0200
    Re: AttributeError: 'module' object has no attribute 'fork' Roy Smith <roy@panix.com> - 2014-08-07 07:49 -0400
      Re: AttributeError: 'module' object has no attribute 'fork' Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-08 02:56 +1000
        Re: AttributeError: 'module' object has no attribute 'fork' Rustom Mody <rustompmody@gmail.com> - 2014-08-07 22:19 -0700
          Re: AttributeError: 'module' object has no attribute 'fork' Rustom Mody <rustompmody@gmail.com> - 2014-08-07 22:35 -0700
          Re: AttributeError: 'module' object has no attribute 'fork' Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-08 15:48 +1000
            Re: AttributeError: 'module' object has no attribute 'fork' Rustom Mody <rustompmody@gmail.com> - 2014-08-08 00:17 -0700
              Re: AttributeError: 'module' object has no attribute 'fork' Chris Angelico <rosuav@gmail.com> - 2014-08-08 17:32 +1000

csiph-web