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


Groups > comp.lang.python > #85273

Re: multiprocessing.Queue() and missing sem_open

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2a.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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'output': 0.05; 'say,': 0.05; 'attribute': 0.07; 'subject:missing': 0.07; 'dependency': 0.09; 'exception.': 0.09; 'latter': 0.09; 'lookup': 0.09; 'stating': 0.09; 'thrown': 0.09; 'try:': 0.09; 'yeah,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '2.7': 0.14; 'class;': 0.16; 'consciously': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'guessing': 0.16; 'hint': 0.16; 'importerror': 0.16; 'optional': 0.16; 'throw': 0.16; 'wrote:': 0.18; 'module': 0.19; 'trying': 0.19; 'normally': 0.19; 'feb': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'install': 0.23; 'exists': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; '[1]': 0.29; 'am,': 0.29; "doesn't": 0.30; 'errors': 0.30; 'have,': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'included': 0.31; 'code': 0.31; 'fri,': 0.33; "can't": 0.35; 'except': 0.35; 'something': 0.35; 'prepare': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'module.': 0.36; 'opposed': 0.36; 'skip:\xd0 10': 0.36; 'should': 0.36; 'so,': 0.37; 'being': 0.38; 'handle': 0.38; 'anything': 0.39; "couldn't": 0.39; 'sure': 0.39; 'even': 0.60; 'catch': 0.60; 'signal': 0.60; 'entire': 0.61; 'simply': 0.61; 'skip:n 10': 0.64; 'more': 0.64; 'bottom': 0.67; 'anything.': 0.68; 'statement,': 0.68; 'caused': 0.69; '2015': 0.84; '3.4': 0.84; 'built,': 0.84; 'source?': 0.84; 'mean.': 0.91; '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:content-transfer-encoding; bh=zOsR3wBvBx9cCzwAjHXtxPLrf0xFD4i/dsyWcKY3a4Y=; b=k7BOfyKdvvew/IblPHR5uP27YF6ePlQIR7aJOO1jcMZifmpE4yUooZBpLlnTUcMoYt GDtjbZwr8n2ZS6X/guiFpN96bBYYGuXzrQmVyISVPeDhRjH4ZMoWfLcZkKxGl3mXOiSk cnxzZtPKfFI2SBJBHzIp2nkJn3D1U55vrRldV+Z2AchP+qezPyjh6iABMuLpZXwQiRsL jLPn8b8ZVjNsxA+8p2LCOH3/rzgega8AMZtJCZutdS9/Z5SsvWi+cm8vEOCbXthMbcMC dmmfaQGU+TebZt0Fj2zwhRWCUiPlUwG+wXi79LiKYaunrbwr+VKw6utbQT1TV8Bbc2sb FctA==
MIME-Version 1.0
X-Received by 10.42.200.136 with SMTP id ew8mr9598712icb.59.1423175345067; Thu, 05 Feb 2015 14:29:05 -0800 (PST)
In-Reply-To <877fvwaz1y.fsf@news.ole.ath.cx>
References <877fvwaz1y.fsf@news.ole.ath.cx>
Date Fri, 6 Feb 2015 09:29:05 +1100
Subject Re: multiprocessing.Queue() and missing sem_open
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
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.18497.1423175353.18130.python-list@python.org> (permalink)
Lines 57
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1423175353 news.xs4all.nl 2862 [2001:888:2000:d::a6]:55538
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:85273

Show key headers only | View raw


On Fri, Feb 6, 2015 at 7:22 AM, Оlе Ѕtrеісhеr <ole-usenet-spam@gmx.net> wrote:
> I am just trying to prepare a package (astropy) for (Debian) Hurd. This
> os lacks a sem_open() implementation. When I now try:
>
> import multiprocessing
> q = multiprocessing.Queue()
>
> I get an ImportError with Python 2.7, but an AttributeError with Python
> 3.4. In the documentation of multiprocessing.Queue() I couldn't find any
> hint that it would throw this exception.

Neither of those errors is being consciously thrown by the Queue
class; the latter means that multiprocessing exists but it has no
Queue in it, and the former means that the entire multiprocessing
module is absent.

I'm guessing you built Python from source? If so, you should have had
a report at the bottom of the build output stating which of the
optional packages weren't built, which on 2.7 will have included
multiprocessing. You might be able to install some dependency and get
that to build, though I don't know what it would be, given that the
3.4 build managed to find it.

But this is the exact way that Python will normally signal that
something isn't available. If your platform doesn't have, say,
os.O_BINARY, because that flag has no meaning for you, then you don't
get NotImplementedError - you simply get AttributeError.

> Can I be sure that the following works also in future?
>
> try
>     q = multiprocessing.Queue()
> except (ImportError, AttributeError)
>     # handle the case of missing sem_open
>
> Or what is the correct way to catch a not working Queue caused by a
> missing sem_open() implementation?

The ImportError will come from the import statement, the
AttributeError will come from the attribute lookup - the above code
can't[1] bomb out with ImportError. So a more correct way would be
something like:

try:
    import multiprocessing
    multiprocessing.Queue
except (ImportError, AttributeError):
    # handle the absence

Or alternatively, don't even bother to try/except the import. If your
code requires multiprocessing.Queue (as opposed to just queue.Queue),
chances are you can't cope with the absence of the module.

ChrisA

[1] Yeah yeah, anything can do anything. You know what I mean.

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


Thread

multiprocessing.Queue() and missing sem_open ole-usenet-spam@gmx.net (Оlе Ѕtrеісhеr) - 2015-02-05 21:22 +0100
  Re: multiprocessing.Queue() and missing sem_open Chris Angelico <rosuav@gmail.com> - 2015-02-06 09:29 +1100
    Re: multiprocessing.Queue() and missing sem_open ole-usenet-spam@gmx.net (Оlе Ѕtrеісhеr) - 2015-02-06 09:27 +0100
      Re: multiprocessing.Queue() and missing sem_open Chris Angelico <rosuav@gmail.com> - 2015-02-06 19:34 +1100

csiph-web