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: PyOS_Readline uses single lock
Type: Stage: resolved
Components: Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Albert.Zeyer, amaury.forgeotdarc, vstinner
Priority: normal Keywords:

Created on 2011-08-30 17:15 by Albert.Zeyer, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg143229 - (view) Author: Albert Zeyer (Albert.Zeyer) * Date: 2011-08-30 17:15
In Parser/myreadline.c PyOS_Readline uses a single lock (`_PyOS_ReadlineLock`). I guess it is so that we don't have messed up stdin reads. Or are there other technical reasons?

However, it should work to call this function from multiple threads with different/independent `sys_stdin` / `sys_stdout`.
msg143231 - (view) Author: Albert Zeyer (Albert.Zeyer) * Date: 2011-08-30 17:49
Ok, it seems that the Modules/readline.c implementation is also not really threadsafe... (Whereby, I think it should be.)
msg143257 - (view) Author: Albert Zeyer (Albert.Zeyer) * Date: 2011-08-31 14:40
Even more problematic: The readline lib itself is absolutely not designed in a way to be used from multi threads at once.
msg143386 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2011-09-02 07:34
Well, readline is supposed to be used with a console, and there is only one usually.  Why would you want to use readline from multiple threads?
msg143394 - (view) Author: Albert Zeyer (Albert.Zeyer) * Date: 2011-09-02 11:08
You might have opened several via `openpty`.

I am doing that here: https://github.com/albertz/PyTerminal
msg372330 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-25 09:46
No activity for 9 years, I close the issue as out of date.
History
Date User Action Args
2022-04-11 14:57:21adminsetgithub: 57070
2020-06-25 09:46:44vstinnersetstatus: open -> closed

nosy: + vstinner
messages: + msg372330

resolution: out of date
stage: resolved
2011-09-02 11:08:00Albert.Zeyersetmessages: + msg143394
2011-09-02 07:34:56amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg143386
2011-08-31 14:40:20Albert.Zeyersetmessages: + msg143257
2011-08-30 17:49:38Albert.Zeyersetmessages: + msg143231
2011-08-30 17:15:54Albert.Zeyercreate