A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-January/031949.html below:

[Python-Dev] Extension modules, Threading, and the GIL

[Python-Dev] Extension modules, Threading, and the GIL"Martin v. Löwis" martin@v.loewis.de
Wed, 08 Jan 2003 15:49:45 +0100
Mark Hammond wrote:
> It can be done, yes.  I am not looking for a change in semantics, just a
> simple way to do it (and maybe even a fast way to do it, but that is
> secondary).  If such a way already exists, please enlighten us.  If not, but
> it is sufficiently simple to describe, then please describe it.  Otherwise,
> I do not understand your point.

There is a very simple strategy to support multiple threads in an 
extension module.

1. In all callbacks, create a thread state and acquire the current
    thread (this requires a singleton interpreter state).

2. In all API calls that may invoke callbacks, use
    Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS around the API call.

If this strategy is followed, every code always has all Python 
resources, and no deadlocks result.

Regards,
Martin




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4