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


Groups > comp.lang.python > #75869

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!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'win32': 0.03; '(at': 0.04; 'sufficient': 0.05; 'attribute': 0.07; "subject:' ": 0.07; 'correspond': 0.09; 'subject:module': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; "api's": 0.16; 'callable': 0.16; 'detected': 0.16; 'exist.': 0.16; 'fork': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:object': 0.16; 'windows:': 0.16; 'wrote:': 0.18; 'bit': 0.19; "python's": 0.19; 'platforms': 0.22; 'import': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'compilation': 0.24; 'exists': 0.24; 'cc:2**0': 0.24; 'least': 0.26; '2010,': 0.27; 'header:In-Reply- To:1': 0.27; 'testing': 0.29; 'raise': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; '"",': 0.31; '>>>>': 0.31; 'existence': 0.31; 'file': 0.32; '(most': 0.33; 'fri,': 0.33; 'etc': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'possible': 0.36; 'should': 0.36; 'error.': 0.37; 'nov': 0.38; 'pm,': 0.38; 'recent': 0.39; 'expect': 0.39; 'even': 0.60; 'availability': 0.60; 'tell': 0.60; 'course': 0.61; "you're": 0.61; 'more': 0.64; 'different': 0.65; 'miss': 0.74; 'jul': 0.74; 'subject:skip:A 10': 0.78; '2.7.1': 0.84; '2014,': 0.84; 'etc),': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=fLspxnl15BnkXHuIuSz5Z8/4UNDDtoLxisDtRMB66R0=; b=QHVOuQfs8fcnm4ehcfvSZrVUEfLPquWe9qAiQ8lJWvwzL7OBcroZmkBqv1zfMbfFRc 9fHsD3sfvnU2dSykmBlVgGqhjnzBTl+NSKr0ov/ZJkZfedv9je0nQKSp8HZwGE1emxKE s7I96u3BBwi2MyWMsVVgucMWDwtnuY6wMavxpyKquHGMx1G3h+lRhljxvhj4b4nxdV2F BEnblqXzY9a0fd4oXzdzFOo+o12K6RYH+oexowpWRkfWmrVa7uHYJBx4zjvz73WixKpM IXievzuWXZZC4d3US89e8HThykPT3eRxprt8L50kAu+DE1vJP5UevTtW4/uqvUdnHe7f dxfA==
MIME-Version 1.0
X-Received by 10.42.216.148 with SMTP id hi20mr9971640icb.12.1407483174178; Fri, 08 Aug 2014 00:32:54 -0700 (PDT)
In-Reply-To <ca10fd68-16c7-45dc-b281-8a84e83d0b23@googlegroups.com>
References <7bd83ac7-17e6-49c2-b5c7-3236c900d005@googlegroups.com> <mailman.12720.1407394838.18130.python-list@python.org> <roy-496ACC.07490507082014@news.panix.com> <53e3afd9$0$29970$c3e8da3$5496439d@news.astraweb.com> <f865db66-8cb8-4796-a8f0-bedfb2ef5079@googlegroups.com> <53e464a3$0$30003$c3e8da3$5496439d@news.astraweb.com> <ca10fd68-16c7-45dc-b281-8a84e83d0b23@googlegroups.com>
Date Fri, 8 Aug 2014 17:32:54 +1000
Subject Re: AttributeError: 'module' object has no attribute 'fork'
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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.12741.1407483183.18130.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1407483183 news.xs4all.nl 2903 [2001:888:2000:d::a6]:53027
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75869

Show key headers only | View raw


On Fri, Aug 8, 2014 at 5:17 PM, Rustom Mody <rustompmody@gmail.com> wrote:
>> But with Roy's suggestion, testing for the existence of os.fork is not
>> sufficient, because it will exist even on platforms where fork doesn't
>> exist. So testing that os.fork exists is not sufficient to tell whether or
>> not you can actually fork.
>
> Windows:
>
> Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license()" for more information.
>>>> import os
>>>> os.fork
>
> Traceback (most recent call last):
>   File "<pyshell#1>", line 1, in <module>
>     os.fork
> AttributeError: 'module' object has no attribute 'fork'
>
>
> Linux:
>
> $ python
> Python 2.7.8 (default, Jul  4 2014, 13:08:34)
> [GCC 4.9.0] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import os
>>>> os.fork
> <built-in function fork>
>>>>
>
>
> So yes, I continue to miss something...

I think the bit you're missing is the "with Roy's suggestion" bit, at
which os.fork() would be callable and would raise a different error.

It's of course possible for fork() to fail (no memory, ulimit hit, etc
etc etc), but I would expect that the presence of os.fork should
correspond perfectly to the API's availability (at least as detected
by Python's compilation testing).

ChrisA

Back to comp.lang.python | Previous | NextPrevious 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