semvec/pypi-packages huggingface dataset:
doctest-cli 0.0.3
Doctests for your shell

[![Build Status](https://travis-ci.org/ivan-krukov/doctest-cli.svg?branch=master)](https://travis-ci.org/ivan-krukov/doctest-cli)

# doctest-cli

Doctests for your shell.
Run an executable, check the output.

## Installation

With `pip`:

```bash
pip install doctest-cli
```

By hand:
```bash
curl -O https://github.com/ivan-krukov/doctest-cli/blob/master/bin/doctest-cli ~/bin
chmod +x ~/bin/doctest-cli
```

## Usage

Create a test script, say `test.sh`:

```sh
# Command
>>> echo hello
# Expected output
hello

# Another command
>>> echo 'Good bye!'
Good bye!

# Failing
>>> echo banana
apple
```

Test it:

```bash
doctest-cli test.sh
```

Check output:
```
doctest-cli: test/simple.sh
------------------------------------------------------------
Error while running:
  echo banana
With STDERR:

Expected STDOUT:
  apple
Got:
  banana
------------------------------------------------------------
Tests ran: 3
Tests passed: 2
Tests failed: 1
```

## Dependencies

The program depends on `python` - both `2.7` and `3.4` and above should work

## Extra 

See `test/` for more examples.

### Return code

Check return code by adding `$?=<RET>` to the beginning of the line. Default return code is `0`:

```sh
>>> false
$?=1
>>> true
$?=0
```

### Standard error

Check `stderr` output by adding `!` to the beginning of the line:

```sh
>>> echo error > /dev/stderr
! error
```

By default, the `stderr` stream is assumed to be empty.

### Custom shell

You can use a custom shell with a shebang line:

```fish
#!/usr/local/bin/fish
>>> echo hello; and echo this is fish
hello
this is fish
```

## Details

`doctest-cli` uses `python`'s `subprocess` module to spawn a new shell for each command and checks the output against the lines provided. All the environment variables are inherited from the parent session. 

Whitespace (including intervening newlines) is ignored. For example, the following test should pass, since all the newlines in the middle are removed:

```sh
>>>printf 'hello\n\n\n\n\n\nworld'
hello
world
```

This is done so that you can have an arbitrary amount of whitespace delineating the test blocks.
mp-throttle 0.0.5
Package to monitor and throttle multiple processes or threads.

# mp_throttle
#### A Python package to monitor and throttle multiprocessing processes.

## Use case:
This package can be used to control and monitor Pythons [multiprocessing](https://docs.python.org/3.4/library/multiprocessing.html?highlight=process) processes or [threading](https://docs.python.org/3.4/library/threading.html) threads. The central Throttle class can be used to monitor the current and the mean frequency of processes/threads and/or to throttle them to execute a limited times per second. This can be used to limit the server requests of a multi-process web crawler.

## Example:
```python
    import multiprocessing
    import mp_throttle
    import time

    def work(tank):
        while not tank.kill_flag.is_set():
            # Block until 'fuel' is available.
            tank.await_fuel()
            # do something
        return

    # Limit the processes to 4 per 1 second, by providing 4 'fuel' per second.
    throttle = mp_throttle.Throttle(4,1)
    workerpool = multiprocessing.Pool(processes=4, initializer=work, initargs=(throttle,))
    throttle.start()
    time.sleep(5)
    # Stops the processes and return stats:
    runtime, total_processes, mean_frequency, mean_processes_per_second = throttle.stop()
    print("Runtime: {}".format(runtime))
    print("Total: {}".format(total_processes))
    print("Mean frequency: {}".format(mean_frequency))
    print("Processes per second: {}".format(mean_processes_per_second))
```
Output:

    >>> Runtime: 5.027516841888428
    >>> Total: 20
    >>> Mean frequency: 0.25046865940093993
    >>> Processes per second: 3.9925154803469485


## Installation:

To install mp_throttle, simply use pip:

    pip install mp_throttle


## Documentation:
For the full documentation see [docs.elpunkt.eu](http://docs.elpunkt.eu/mp_throttle)

## How to Contribute:
1. Test mp_throttle and open an issue to report a bug or discuss a feature idea.
2. Give general feedback on the code and the package structure. Since this is my first python package, I'm sure there is a lot to feedback on:)
3. Fork the repository and make your changes.