twisted / twisted/twisted

Replace getProcess* helpers with a single, better, API.

Open
#3,997 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

core enhancement new priority-normal
Dominant language
Python
Stars
6k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
10

Description

spiv's avatar spiv reported
Trac ID trac#3997
Type enhancement
Created 2009-09-03 04:11:54Z

I think the subprocess module has the right idea: give you a single good way to start a function, and declare whether you want to capture/discard/ignore the various stdio streams etc, and then return an object with useful attributes.

So I propose that instead of getProcessValue, getProcessOutput, getProcessOutputAndValue (did I miss any?) we have a single method, that takes args like:

  foo(stdout=fileLikeObject, ...)

and returns a Deferred that yields an object with a .exitValue attribute, and perhaps others (for finding out if a signal terminated it, maybe?). Returning an object certainly seems like a much better API than e.g. the tuples from getProcessOutputAndValue. Obviously this new function would need a better name than foo.

Probably any new API here should try to address the problems with the existing APIs described by exarkun in a comment at http://twistedmatrix.com/trac/ticket/280.

Quite possibly the proposal in this vague sketch could be improved even further. Please feel free to criticise, suggest improvements, suggest more precise details for the signature, etc. I figured it was better to capture a rough idea than forget it entirely.

Searchable metadata
trac-id__3997 3997
type__enhancement enhancement
reporter__spiv spiv
priority__normal normal
milestone__ 
branch__ 
branch_author__ 
status__new new
resolution__None None
component__core core
keywords__ 
time__1251951114000000 1251951114000000
changetime__1359614387000000 1359614387000000
version__None None
owner__ 
cc__khorn cc__tom.prince

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the subprocess module and the existing getProcessValue, getProcessOutput, and getProcessOutputAndValue helpers. Review the problems described in ticket 280, then work out a precise unified API for stdio handling and process results. Done means the proposal is specified well enough to implement and replace the existing helper use cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.