[New-bugs-announce] [issue43387] Enable pydoc to run as background job

digitaldragon report at bugs.python.org
Wed Mar 3 08:34:22 EST 2021


New submission from digitaldragon <raphael at pdev.de>:

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)

----------
components: Library (Lib)
messages: 388017
nosy: digitaldragon
priority: normal
severity: normal
status: open
title: Enable pydoc to run as background job
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43387>
_______________________________________


More information about the New-bugs-announce mailing list