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/2010-January/097075.html below:

[Python-Dev] GIL required for _all_ Python calls?

[Python-Dev] GIL required for _all_ Python calls?Benjamin Peterson benjamin at python.org
Thu Jan 7 04:32:17 CET 2010
2010/1/6 John Arbash Meinel <john.arbash.meinel at gmail.com>:
> Anything that Py_INCREF or Py_DECREF's should have the GIL, or you may
> get concurrent updating of the value, and then the final value is wrong.
> (two threads do 5+1 getting 6, rather than 7, and when the decref, you
> end up at 4 rather than back at 5).

Correct.

>
> AFAIK, the only things that don't require the GIL are macro functions,
> like PyString_AS_STRING or PyTuple_SET_ITEM. PyErr_SetString, for
> example, will be increfing and setting the exception state, so certainly
> needs the GIL to be held.

As a general rule, I would say, no Py* macros are safe without the gil
either (the exception being Py_END_ALLOW_THREADS), since they mutate
Python objects which must be protected.



-- 
Regards,
Benjamin

More information about the Python-Dev mailing list

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