Skip to main content

pythonic processes

Project description

https://raw.githubusercontent.com/datalib/proclib/master/media/logo-small.png

Proclib is a high level wrapper/abstraction around the standard library subprocess module, written in Python, with proper piping support which aims to simplify the usage of Unix utilities right from Python and help the developer focus on the commands and not the code which calls the commands.

https://travis-ci.org/datalib/proclib.svg?branch=master

Overview

proclib.api.spawn(cmd)

Given a string or list making up commands cmd, return a Response object which is the result of piping the commands, i.e. they are run in parallel. The data parameter can be used to configure the data passed in to the initial process. Usage example:

>>> from proclib.api import spawn
>>> r = spawn('yes | head')
>>> r.stdout.read()
'y\ny\ny\ny\ny\ny\ny\ny\ny\ny\n'
>>> r.close()
>>> r.history[0].explain_signal()
{'action': 'kill',
 'description': 'write on a pipe with no readers',
 'id': 13,
 'signal': 'SIGPIPE'}

Streaming support is built-in- that is that the stdout of any process can be streamed lazily instead of read and stored in memory all in one go. Also, any kind of iterable can be piped to the process:

def gen():
    yield 'hi\n'
    yield 'ho\n'

r = spawn('cat', data=gen())
assert r.out.split() == ['hi', 'ho']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

proclib-0.1.3.tar.gz (6.1 kB view details)

Uploaded Source

File details

Details for the file proclib-0.1.3.tar.gz.

File metadata

  • Download URL: proclib-0.1.3.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for proclib-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1d88a7b6be7d8929ec6300b696b676772a689416eb9db4197d8e027512f80dc8
MD5 b101d9d4c6c9c38c5f59fb5d6af8e4a2
BLAKE2b-256 a0d65cf26c10c074b6d452ca8362781f9853407cccc8b2c769cea386a8dd79fe

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page