Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4028726
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:15:22+00:00 2026-05-20T11:15:22+00:00

The subprocess module has the convenience function call , which is implemented like this

  • 0

The subprocess module has the convenience function call, which is implemented like this in both 2.6 and 3.1:

def call(*popenargs, **kwargs):
    return Popen(*popenargs, **kwargs).wait()

The documentation for this function carries a red warning, reading:

Warning: Like Popen.wait(), this will deadlock when using stdout=PIPE and/or stderr=PIPE and the child process generates enough output to a pipe such that it blocks waiting for the OS pipe buffer to accept more data.

The Popen.wait() documentation says to use Popen.communicate() instead in such circumstances. Well, then why isn’t call just implemented like below instead, so the stupid warning can be removed, and silly limitations like this removed from the standard library?

def call(*args, **kwargs):
    input = kwargs.pop("input", None)
    p = Popen(*args, **kwargs)
    p.communicate(input)
    return p.returncode

I’m sure there’s a reason. What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:15:23+00:00Added an answer on May 20, 2026 at 11:15 am

    I spent some time looking through PEP-324, which introduced the subprocess module, trying to figure out the design decisions involved, but I think the answer is actually very simple:

    There’s no reason to pass stdout=PIPE or stderr=PIPE to subprocess.call, so the fact that it can deadlock is irrelevant.

    The only reason to pass stdout=PIPE or stderr=PIPE to subprocess.Popen is so that you can use the Popen instance’s stdout and stderr attributes as file objects. Since subprocess.call never lets you see the Popen instance, the PIPE options become irrelevant.

    There is potential overhead to Popen.communicate (creating additional threads to avoid deadlock by monitoring the pipes), and there’s no benefit in this case, so there’s no reason to use it.

    Edit: If you want to discard your output, I guess it’s better to do so explicitly:

    # option 1
    with open(os.devnull, 'w') as dev_null:
        subprocess.call(['command'], stdout=dev_null, stderr=dev_null)
    
    # option 2
    subprocess.call(['command >& /dev/null'], shell=True)
    

    instead of instructing subprocess to capture all of the output to PIPE files that you never intend to use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realize this might be a duplicate of Using module 'subprocess' with timeout .
Python's subprocess module by default passes all open file descriptors to any child processes
The primary class in the subprocess module is name Popen , and represents a
How do I execute the following shell command using the Python subprocess module? echo
I'm having problems redirecting stdio of another program using subprocess module. Just reading from
If this is my subprocess: import time, sys for i in range(200): sys.stdout.write( 'reading
I'm looking to call a subprocess with a file descriptor opened to a given
I'm kind of confused about how subprocess.Popen works. If anyone has example code that
I'm testing python subprocess and I keep getting this error: $ python subprocess-test.py Traceback
How can I get the output of a process run using subprocess.call() ? Passing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.