This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [subinterpreters] Multiple interpreters and readline module hook functions.
Type: behavior Stage:
Components: Subinterpreters Versions: Python 3.6, Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Winston451, eric.snow, grahamd, terry.reedy, vstinner
Priority: normal Keywords: patch

Created on 2008-10-25 02:52 by grahamd, last changed 2022-04-11 14:56 by admin.

Files
File name Uploaded Description Edit
readline.patch Winston451, 2012-10-26 12:24 review
Messages (5)
msg75201 - (view) Author: Graham Dumpleton (grahamd) Date: 2008-10-25 02:52
Because the readline module uses PyGILState_Ensure() to facilitate triggering 
callbacks into Python code, this would make the ability to use the hook 
functions incompatible with use in sub interpreters.

If this is the case, then that readline module cannot be used in sub 
interpreters should be documented if not already.

Better still, attempts to register hooks from sub interpreters should result in 
an exception. Further, when in use, in sub interpreter, callback hooks should 
also not be called if defined, because if defined they would be the hooks from 
the main interpreter since variables holding the hooks are static C variables 
and shared across all interpreters.

This issue derived from reading of code only and not tested in real program.
msg107981 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-06-17 01:34
The be an issue, tests with currents interpreters are needed. You may be right, but it may be that no one ever uses readline with subinterpreters.
msg173809 - (view) Author: (Winston451) Date: 2012-10-25 23:23
Hi,

I'm currently developping an application which runs sub interpreters in threads (one sub interpreter per thread). When I try to use readline completion in these sub interpreters it fails because it's not possible to import the "keyword" module (PyEval_GetRestricted() returns true). I think it is due to the fact that readline's on_completion() use PyGILState_Ensure(). It should be possible to use PyEval_RestoreThread with _PyOS_ReadlineTState instead.
msg173839 - (view) Author: (Winston451) Date: 2012-10-26 12:17
I attached a patch that solve the problem
msg368905 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-05-15 01:28
See also bpo-15751: [subinterpreters] Make the PyGILState API compatible with subinterpreters.
History
Date User Action Args
2022-04-11 14:56:40adminsetgithub: 48452
2020-05-15 01:28:36vstinnersetnosy: + vstinner
messages: + msg368905
2020-05-15 01:10:05vstinnersetcomponents: + Subinterpreters, - Interpreter Core
title: Multiple interpreters and readline module hook functions. -> [subinterpreters] Multiple interpreters and readline module hook functions.
2015-07-03 00:32:42eric.snowsetnosy: + eric.snow

versions: + Python 3.5, Python 3.6, - Python 3.4
2012-10-26 13:02:22berker.peksagsetversions: - Python 2.6, Python 3.0, Python 3.1, Python 2.7, Python 3.2, Python 3.3, Python 3.5
2012-10-26 12:24:47Winston451setfiles: - readline.patch
2012-10-26 12:24:31Winston451setfiles: + readline.patch
2012-10-26 12:19:40Winston451settype: behavior
versions: + Python 2.6, Python 3.1, Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5
2012-10-26 12:17:40Winston451setfiles: + readline.patch
keywords: + patch
messages: + msg173839
2012-10-25 23:23:50Winston451setstatus: pending -> open
nosy: + Winston451
messages: + msg173809

2010-06-17 01:34:59terry.reedysetstatus: open -> pending
versions: - Python 2.5
nosy: + terry.reedy

messages: + msg107981
2008-10-25 02:52:43grahamdcreate