classification
Title: Enable pydoc to run as background job
Type: enhancement Stage: test needed
Components: Library (Lib) Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: digitaldragon
Priority: normal Keywords:

Created on 2021-03-03 13:34 by digitaldragon, last changed 2021-03-06 01:04 by terry.reedy.

Messages (1)
msg388017 - (view) Author: (digitaldragon) Date: 2021-03-03 13:34
The pydoc tool can serve a website for browsing the docs interactively with the -p or -b option. While serving, it enters a simple command line interface:
Server commands: [b]rowser, [q]uit
server> 

Because it is reading from stdin, it is not possible to straightforwardly run the progress in the background of a linux shell. Normally, this is achieved by appending a & to the command, starting it in the background, or using the shell's job control features to put it in the background after starting normally: Usually Ctrl-Z and issuing the command 'bg'.

In both cases, any attempt to read from stdin causes a SIGTTIN signal, suspending the process if not caught. The webserver then cannot process any requests.

I reproduced the behavior in python versions 3.5, 3.7, 3.8 and 3.9. In 2.7, no interactive interface is present.

Possible fixes:
- remove the interactive command line altogether (it does not offer more functionality than the -b flag, and the shell's handling of Ctrl-C, which sends a SIGINT anyway)
- catch SIGTTIN (handles a subsequent sending-to-background)
- detecting if started in background (https://stackoverflow.com/a/24862213, can't handle subsequent sending-to-background)
History
Date User Action Args
2021-03-06 01:04:07terry.reedysetstage: test needed
type: behavior -> enhancement
versions: - Python 3.6, Python 3.7, Python 3.8, Python 3.9
2021-03-03 13:42:44digitaldragonsetversions: + Python 3.6, Python 3.7, Python 3.8, Python 3.10
2021-03-03 13:34:22digitaldragoncreate