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 8094047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:40:08+00:00 2026-06-05T20:40:08+00:00

I have a python framework which has to execute bash scripts as plugins. We

  • 0

I have a python framework which has to execute bash scripts as plugins.
We are using multiprocessing module to create worker processes which pick the plugin details from a multiprocessing.JoinableQueue and execute the plugins using subprocess.Popen().

It has been observed that the final output generated by the shell scripts get truncated and as end result the entire execution goes waste.

So we tried moving to python threads for the workers maintaining the subprocess mechanism to spawn the shell script processes. And the truncation was no longer happening. But threads are awfully slow (due to GIL) and the responses to signals and events are also indeterminate(probably owing to the GIL release timings).

I have read in many places including other questions in stackoverflow that multiprocessing module does a buffering of stdout. We know this is the problem. But are unable to find a proper solution, as we can’t give sys.stdout.flush from python for the data that the shell script has to echo to a file.

Also we tried os.fsync with some samples, and truncation is not happening. Again it can’t be used directly for our purpose as the names of files created by the shell scripts are not known to the framework. Only a final archive is taken back by the framework.

My question is, is there any way to prevent this buffering in the processes spawned from multiprocessing modules? Will the -u option of python interpreter help here? Or will any modifications to the python library in /usr/lib64/python2.6/multiprocessing clear this problem?

  • 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-06-05T20:40:10+00:00Added an answer on June 5, 2026 at 8:40 pm

    We found out that the commands sent over ssh inside the scripts were the ones which were getting truncated in their outputs.

    For this we used the -n flag of ssh , which solved the problem. There is no more truncation.
    But this is a strange issue which happens only in python multiprocessing environment and must be considered seriously by anyone attempting to use such a model for their own purposes.

    The man page of -n option says

    Redirects stdin from /dev/null (actually, prevents reading from
    stdin). This must be used when ssh is run in the background. A
    common trick is to use this to run X11 programs on a remote
    machine. For example, ssh -n shadows.cs.hut.fi emacs & will
    start an emacs on shadows.cs.hut.fi, and the X11 connection will
    be automatically forwarded over an encrypted channel. The ssh
    program will be put in the background. (This does not work if
    ssh needs to ask for a password or passphrase; see also the -f
    option.)

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

Sidebar

Related Questions

I have a C/C++ application in which I define a Python module. I set
I have python script which downloads N number of images from website. I run
I like the sinatra framework, but might have to work in python. A quick
On OSX, I have a Python universal binary which just contains 32-bit code: $
Using the Python templates for Xcode, I have a simple project running on one
I need to use a library which depends on the Tornado Python Web Framework,
I have a Rails server which will need to run a python script at
I am looking for a simple python web framework which runs both as standalone
I have the academic distribution of EPD 7.1 for MacOS 10.6.x , which has
I have been trying to make a case for using Python at my work.

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.