# p5-python-new_service_port_generator
Random port generator for new tcp/udp service.

# Source code
Upstream on [GitHub](https://github.com/p5-vbnekit/p5-python-new_service_port_generator).

# Install
- call `pip install p5.new_service_port_generator`
```
Collecting p5.new_service_port_generator
  Downloading p5.new_service_port_generator-0.0.3.tar.gz
```
```
Successfully built p5.new-service-port-generator
Installing collected packages: p5.new-service-port-generator
Successfully installed p5.new-service-port-generator-0.0.3
```
- or call `pip install .` in source directory
```
Processing /home/user/src/p5-python-new_service_port_generator
```
```
Successfully built p5.new-service-port-generator
Installing collected packages: p5.new-service-port-generator
Successfully installed p5.new-service-port-generator-0.0.3
```

# Uninstall
call `pip uninstall p5.new_service_port_generator`
```
Uninstalling p5.new-service-port-generator-0.0.3:
  Would remove:
    /home/user/venv/lib/python3.8/site-packages/p5.new_service_port_generator-0.0.3-py3.8.egg-info
    /home/user/venv/lib/python3.8/site-packages/p5/new_service_port_generator/*
Proceed (y/n)? y
  Successfully uninstalled p5.new-service-port-generator-0.0.3
```

# Example
Try:
- [`example.py`](https://github.com/p5-vbnekit/p5-python-new_service_port_generator/blob/v0.0.3/example.py)
- or this:
```python
import sys

from p5.new_service_port_generator import make as _make_generator

_generator = _make_generator()
print("generator pool size: {}".format(len(_generator.pool)), file = sys.stderr)

print("your first port [{}] for your new service was returned by __call__ and removed from pool".format(_generator()), file = sys.stderr)
print("generator pool size: {}".format(len(_generator.pool)), file = sys.stderr)

print("your second port [{}] for your new service was generated by __iter__ and removed from pool".format(next(iter(_generator))), file = sys.stderr)
print("generator pool size: {}".format(len(_generator.pool)), file = sys.stderr)
```
