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


Groups > comp.lang.python > #108571

Re: Calling python from C with OpenMP

From Sturla Molden <sturla.molden@gmail.com>
Newsgroups comp.lang.python
Subject Re: Calling python from C with OpenMP
Date 2016-05-13 00:04 +0000
Message-ID <mailman.618.1463097878.32212.python-list@python.org> (permalink)
References <8224bdd2-9afe-487b-804b-f3b88dee2028@googlegroups.com> <1288606789484790413.405054sturla.molden-gmail.com@news.gmane.org>

Show all headers | View raw


<oysteijo@gmail.com> wrote:

> Second and most important question: When I run this code it sometimes
> segementation faults, and sometimes some threads run normal and some
> other threads says "Cannot call 'do_multiply'". Sometimes I get the
> message: Fatal Python error: GC object already tracked. And some times it
> even runs normally...
> I understand there is some kind of race condition here, where python
> tries to refer to some memory that has been already released. But how can
> I avoid this? What am I doing wrong? (or, less likely, is this a bug?)


You must own the GIL before you can safely use the Python C API, object
creation and refcounting in particular. Use the "Simplified GIL API" to
grab the GIL and release it when you are done.

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


Thread

Calling python from C with OpenMP oysteijo@gmail.com - 2016-05-12 12:28 -0700
  Re: Calling python from C with OpenMP Sturla Molden <sturla.molden@gmail.com> - 2016-05-13 00:04 +0000
    Re: Calling python from C with OpenMP Øystein Schønning-Johansen <oysteijo@gmail.com> - 2016-05-13 09:22 -0700
      Re: Calling python from C with OpenMP MRAB <python@mrabarnett.plus.com> - 2016-05-13 18:12 +0100
        Re: Calling python from C with OpenMP Øystein Schønning-Johansen <oysteijo@gmail.com> - 2016-05-13 13:16 -0700
          Re: Calling python from C with OpenMP Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-05-13 20:04 -0400
            Re: Calling python from C with OpenMP Paul Rubin <no.email@nospam.invalid> - 2016-05-13 19:09 -0700

csiph-web