Giter Site home page Giter Site logo

techtonik / absub Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 14 KB

Anti-blocking subprocess implementations https://bugs.python.org/issue14872

Home Page: https://stackoverflow.com/questions/34504970/non-blocking-read-on-os-pipe-on-windows

License: Other

Python 100.00%
subprocess

absub's Introduction

async_subprocess is a simple wrapper around Python's subprocess.Popen
class.  You use it just like you would use subprocess.Popen; there are only
two major differences:

    * You can only pass None or PIPE as values for stdout, stdin, stderr.
    * asyncomm() returns immediately with whatever data is available, rather
      than waiting for EOF and process termination.  As such, you can now call
      asyncomm() many times on the same object.

async_subprocess is beta software, so it might still be a bit buggy.  It has
been tested on the following configurations:

    * Linux (Fedora 15), Python 2.7.1
    * Linux (Fedora 15), Python 3.2
    * Windows Vista 32, Python 2.7.3

Example usage:

    from async_subprocess import AsyncPopen, PIPE
    args = ("echo", "Hello World!")
    proc = AsyncPopen(args, stdout=PIPE)
    stdoutdata, stderrdata = proc.asyncomm()
    print stdoutdata    # should print "Hello World!"

------------
 What's New 
------------
Version 0.5
* (techtonik) Implement standard communicate() using non-blocking layer.

Version 0.4
* (techtonik) Non-blocking communicate() is renamed to asyncomm() to allow
  making AsyncPopen() class a drop-in Popen() replacement that doesn't break
  existing codebase.

Version 0.3
* (techtonik) Change communicate() to return empty strings if pipes are
  alive and empty, and None if they are dead or closed.
* (techtonik) Wrap Popen.stdin to make sure that programs closing stdin
  directly do this in a threadsafe manner.

Version 0.2.3
* (techtonik) Fixed wrong lock being set in communicate() for stdout pipe.
* (techtonik) Added tests.

Version 0.2
* Got rid of the stray debug print statement that was accidentally left in
  version 0.1.  Sorry about that, it's gone now, and 0.2 has been checked for
  other stray debug statements.
* Support for Python 3 added.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.