semvec/pypi-packages huggingface dataset:
k3wsjobd 0.1.4
Gevent-based WebSocket server for async job processing
License: MIT
Requires Python: >=3.9
Keywords: websocket, gevent, job, async, server

# k3wsjobd

[![Action-CI](https://github.com/pykit3/k3wsjobd/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3wsjobd/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3wsjobd/badge/?version=stable)](https://k3wsjobd.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3wsjobd)](https://pypi.org/project/k3wsjobd)

This module is a gevent based websocket server. When the server receives a job description from a client, it runs that job asynchronously in a thread, and reports the progress back to the client periodically.

k3wsjobd is a component of [pykit3] project: a python3 toolkit set.


This module is a gevent based websocket server. When the server receives a job description from a client,
it runs that job asynchronously in a thread, and reports the progress back to the client periodically.




# Install

```
pip install k3wsjobd
```

# Synopsis

```python

from geventwebsocket import Resource, WebSocketServer
import k3wsjobd
from k3wsjobd import logging


def run():
    k3wsjobd.run(ip='127.0.0.1', port=33445)


if __name__ == "__main__":
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)

    file_handler = logging.FileHandler('wsjobd.log')
    formatter = logging.Formatter('[%(asctime)s, %(levelname)s] %(message)s')
    file_handler.setFormatter(formatter)
    logger.addHandler(file_handler)
    run()

```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
k3zkutil 0.1.6
Helper functions for ZooKeeper with kazoo
License: MIT
Requires Python: >=3.9
Keywords: zookeeper, kazoo, distributed, lock, coordination

# k3zkutil

[![Action-CI](https://github.com/pykit3/k3zkutil/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3zkutil/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3zkutil/badge/?version=stable)](https://k3zkutil.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3zkutil)](https://pypi.org/project/k3zkutil)

Some helper function to make life easier with zookeeper.

k3zkutil is a component of [pykit3] project: a python3 toolkit set.


Some helper function to make life easier with zookeeper.




# Install

```
pip install k3zkutil
```

# Synopsis

```python

from k3zkutil import config
"""
config.zk_acl      # (('xp', '123', 'cdrwa'), ('foo', 'bar', 'rw'))
config.zk_auth     # ('digest', 'xp', '123')
config.zk_hosts    # '127.0.0.1:2181'
config.zk_node_id  # 'web-01'
config.zk_lock_dir # 'lock/'
"""
with k3zkutil.ZKLock('foo_lock',
                   zkconf=dict(
                       hosts='127.0.0.1:2181',
                       acl=(('xp', '123', 'cdrwa'),),
                       auth=('digest', 'xp', '123'),
                       node_id='web-3',
                       lock_dir='my_locks/'
                   )):
    print("do something")
lock = k3zkutil.ZKLock('foo')
try:
    for holder, ver in lock.acquire_loop(timeout=3):
        print('lock is currently held by:', holder, ver)

    print('lock is acquired')
except k3zkutil.LockTimeout as e:
    print('timeout to acquire "foo"')
```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
k3utfjson 0.1.5
JSON dump and load with enforced UTF-8 encoding
License: MIT
Requires Python: >=3.9
Keywords: json, utf-8, encoding, serialization

# k3utfjson

[![Action-CI](https://github.com/pykit3/k3utfjson/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3utfjson/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3utfjson/badge/?version=stable)](https://k3utfjson.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3utfjson)](https://pypi.org/project/k3utfjson)

force `json.dump` and `json.load` in `utf-8` encoding.

k3utfjson is a component of [pykit3] project: a python3 toolkit set.


# Name

utfjson: force `json.dump` and `json.load` in `utf-8` encoding.

# Status

This library is considered production ready.


# Install

```
pip install k3utfjson
```

# Synopsis

```python

import k3utfjson

k3utfjson.load('"hello"')
k3utfjson.dump({})

```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
k3ut 0.1.19
Unittest utilities with debug logging and test helpers
License: MIT
Requires Python: >=3.9
Keywords: unittest, testing, debug, logging, utility

# k3ut

[![Build Status](https://github.com/pykit3/k3ut/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3ut/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3ut/badge/?version=stable)](https://k3ut.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3ut)](https://pypi.org/project/k3ut)

unittest util

k3ut is a component of [pykit3] project: a python3 toolkit set.


# Install

```
pip install k3ut
```

# Synopsis

```python

```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
k3utdocker 0.1.4
Docker client utilities for unit testing
License: MIT
Requires Python: >=3.9
Keywords: docker, testing, unittest, container, utility

# k3utdocker

[![Action-CI](https://github.com/pykit3/k3utdocker/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3utdocker/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3utdocker/badge/?version=stable)](https://k3utdocker.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3utdocker)](https://pypi.org/project/k3utdocker)

unit test for python-docker

k3utdocker is a component of [pykit3] project: a python3 toolkit set.






# Install

```
pip install k3utdocker
```

# Synopsis

```python

```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
k3time 0.1.10
Time conversion utilities for parsing and formatting timestamps
License: MIT
Requires Python: >=3.9
Keywords: time, datetime, timestamp, timezone, conversion

# k3time

[![Action-CI](https://github.com/pykit3/k3time/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3time/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3time/badge/?version=stable)](https://k3time.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3time)](https://pypi.org/project/k3time)

Time convertion utils

k3time is a component of [pykit3] project: a python3 toolkit set.


Time convertion utils.

    >>> parse('2017-01-24T07:51:59.000Z', 'iso')
    datetime.datetime(2017, 1, 24, 7, 51, 59)
    >>> format_ts(1485216000, 'iso')
    '2017-01-24T00:00:00.000Z'
    >>> format_ts(1485216000, '%Y-%m-%d')
    '2017-01-24'




# Install

```
pip install k3time
```

# Synopsis

```python
>>> parse('2017-01-24T07:51:59.000Z', 'iso')
datetime.datetime(2017, 1, 24, 7, 51, 59)
>>> format_ts(1485216000, 'iso')
'2017-01-24T00:00:00.000Z'
>>> format_ts(1485216000, '%Y-%m-%d')
'2017-01-24'
```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
k3txutil 0.1.4
Compare-and-swap (CAS) loop utilities for transactional operations
License: MIT
Requires Python: >=3.9
Keywords: cas, compare-and-swap, transaction, concurrency, optimistic-locking

# k3txutil

[![Action-CI](https://github.com/pykit3/k3txutil/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3txutil/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3txutil/badge/?version=stable)](https://k3txutil.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3txutil)](https://pypi.org/project/k3txutil)

A collection of helper functions to implement transactional operations.

k3txutil is a component of [pykit3] project: a python3 toolkit set.


#   Name

txutil

#   Status

This library is considered production ready.

#   Description

A collection of helper functions to implement transactional operations.

#   Exceptions

##  CASConflict

**syntax**:
`CASConflict()`

User should raise this exception when a CAS conflict detect in a user defined
`set` function.




# Install

```
pip install k3txutil
```

# Synopsis

```python

import k3txutil
import threading


class Foo(object):

    def __init__(self):
        self.lock = threading.RLock()
        self.val = 0
        self.ver = 0

    def _get(self, db, key, **kwargs):
        # db, key == 'dbname', 'mykey'
        with self.lock:
            return self.val, self.ver

    def _set(self, db, key, val, prev_stat, **kwargs):

        # db, key == 'dbname', 'mykey'
        with self.lock:
            if prev_stat != self.ver:
                raise k3txutil.CASConflict(prev_stat, self.ver)

            self.val = val
            self.ver += 1

    def test_cas(self):
        for curr in k3txutil.cas_loop(self._get, self._set, args=('dbname', 'mykey', )):
            curr.v += 2

        print((self.val, self.ver)) # (2, 1)

while True:
    curr_val, stat = getter(key="mykey")
    new_val = curr_val + ':foo'
    try:
        setter(new_val, stat, key="mykey")
    except CASConflict:
        continue
    else:
        break

#`cas_loop` simplifies the above workflow to:
for curr in k3txutil.cas_loop(getter, setter, args=("mykey", )):
    curr.v += ':foo'


```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
k3thread 0.1.7
Thread utilities for daemon threads and exception sending
License: MIT
Requires Python: >=3.9
Keywords: thread, daemon, concurrent, exception

# k3thread

[![Build Status](https://github.com/pykit3/k3thread/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3thread/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3thread/badge/?version=stable)](https://k3thread.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3thread)](https://pypi.org/project/k3thread)

utility to create thread.

k3thread is a component of [pykit3] project: a python3 toolkit set.


k3thread is utility to create and operate thread.

Start a daemon thread after 0.2 seconds::

    >>> th = daemon(lambda :1, after=0.2)

Stop a thread by sending a exception::

    import time

    def busy():
        while True:
            time.sleep(0.1)

    t = daemon(busy)
    send_exception(t, SystemExit)




# Install

```
pip install k3thread
```

# Synopsis

```python
>>> th = daemon(lambda :1, after=0.2)

```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
k3shell 0.1.5
Shell command dispatcher with nested subcommand support
License: MIT
Requires Python: >=3.9
Keywords: shell, command, cli, subcommand, argparse

# k3shell

[![Action-CI](https://github.com/pykit3/k3shell/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3shell/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3shell/badge/?version=stable)](https://k3shell.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3shell)](https://pypi.org/project/k3shell)

A python module to manage commands.

k3shell is a component of [pykit3] project: a python3 toolkit set.


#   Name

k3shell

#   Status

The library is considered production ready.




# Install

```
pip install k3shell
```

# Synopsis

```python

import k3shell
import sys
arguments = {
    'echo_repr': (
        lambda x: sys.stdout.write(repr(x)),
        ('x', {'nargs': '+', 'help': 'just an input message'}),
    ),

    'foo': {
        'bar': lambda: sys.stdout.write('bar'),

        'bob': {
            'plus': (
                lambda x, y: sys.stdout.write(str(x + y)),
                ('x', {'type': int, help: 'an int is needed'}),
                ('y', {'type': int, help: 'an int is needed'}),
            ),
        },
    },

    '__add_help__': {
        ('echo_repr',)           : 'output what is input.',
        ('foo', 'bar',)          : 'print a "bar".',
        ('foo', 'bob', 'plus',)  : 'do addition operation with 2 numbers.',
    },

    '__description__': 'this is an example command.',
}

k3shell.command(**arguments)
"""

then you can execute your command as:

python demo.py echo_repr hello!
# 'hello!'

python demo.py foo bar
# 'bar'

python demo.py foo bob plus 1 2
# 3


and you can get a usage help message like:

$ python demo.py -h
---------------------------
usage: demo.py [-h] {echo_repr, foo bar, foo bob plus} ...

this is an example command.

positional arguments:
  {echo_repr, foo bar, foo bob plus} commands to select ...
    echo_repr            output what is input.
    foo bar              print a "bar".
    foo bob plus         do addition operation with 2 numbers.

optional arguments:
    -h, --help           show this help message and exit


$ python demo.py foo bob plus -h
--------------------------
usage: demo.py foo bob plus [-h] x y

positional arguments:
    x   an int is need
    y   an int is need

optional arguments:
    -h, --help           show this help message and exit

"""
```

#   Author

Wenbo Li(李文博) <wenbo.li@baishancloud.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2017 Wenbo Li(李文博) <wenbo.li@baishancloud.com>


[pykit3]: https://github.com/pykit3
k3str 0.1.8
String operation utilities for encoding conversion
License: MIT
Requires Python: >=3.9
Keywords: string, encoding, utf8, bytes, conversion

# k3str

[![Build Status](https://github.com/pykit3/k3str/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3str/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3str/badge/?version=stable)](https://k3str.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3str)](https://pypi.org/project/k3str)

k3str is a collection of string utilities.

k3str is a component of [pykit3] project: a python3 toolkit set.


# Install

```
pip install k3str
```

# Synopsis

```python
>>> repr(to_bytes('我'))
"b'\\xe6\\x88\\x91'"
```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
k3stopwatch 0.1.5
Hierarchical timing measurement with aggregated and tracing reports
License: MIT
Requires Python: >=3.9
Keywords: stopwatch, timer, profiling, performance, tracing

# k3stopwatch

[![Action-CI](https://github.com/pykit3/k3stopwatch/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3stopwatch/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3stopwatch/badge/?version=stable)](https://k3stopwatch.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3stopwatch)](https://pypi.org/project/k3stopwatch)

StopWatch - library for adding timers and tags in your code for performance monitoring

k3stopwatch is a component of [pykit3] project: a python3 toolkit set.


StopWatch operates on a notion of "spans" which represent scopes of code for which we
want to measure timing. Spans can be nested and placed inside loops for aggregation.

StopWatch requires a root scope which upon completion signifies the end of the round
of measurements. On a server, you might use a single request as your root scope.

StopWatch produces two kinds of reports.
1) Aggregated (see _reported_values).
2) Non-aggregated or "tracing" (see _reported_traces).



# Install

```
pip install k3stopwatch
```

# Synopsis

```python

import k3stopwatch
sw  = k3stopwatch.StopWatch()

with sw.timer('rwoot'):
    for i in range(50):
         with sw.timer('inner_task'):
             print("do_inner_task(i)")

```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
k3proc 0.2.17
Utility to create subprocess with support for timeout, tty, and text mode
License: MIT
Requires Python: >=3.9
Keywords: subprocess, process, command, shell, tty

# k3proc

[![Build Status](https://github.com/pykit3/k3proc/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3proc/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3proc/badge/?version=stable)](https://k3proc.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3proc)](https://pypi.org/project/k3proc)

easy to use `Popen`

k3proc is a component of [pykit3] project: a python3 toolkit set.


k3proc is utility to create sub process.

Execute a shell script::

    >>> returncode, out, err = k3proc.shell_script('ls / | grep bin')

Run a command::

    # Unlike the above snippet, following statement does not start an sh process.
    returncode, out, err = k3proc.command('ls', 'a*', cwd='/usr/local')




# Install

```
pip install k3proc
```

# Synopsis

```python
>>> returncode, out, err = k3proc.shell_script('ls / | grep bin')

```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
k3redisutil 0.1.5
Redis utilities for easier client management and proxy support
License: MIT
Requires Python: >=3.9
Keywords: redis, client, proxy, cache

# k3redisutil

[![Action-CI](https://github.com/pykit3/k3redisutil/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3redisutil/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3redisutil/badge/?version=stable)](https://k3redisutil.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3redisutil)](https://pypi.org/project/k3redisutil)

For using redis more easily.

k3redisutil is a component of [pykit3] project: a python3 toolkit set.


For using redis more easily.



# Install

```
pip install k3redisutil
```

# Synopsis

```python

import k3redisutil
import time

# Using redis as a duplex cross process communication channel pool.

# client and server with the same channel name "/foo" is a pair
c = k3redisutil.RedisChannel(6379, '/foo', 'client')
s = k3redisutil.RedisChannel(6379, '/foo', 'server')

c.send_msg('c2s')
s.send_msg('s2c')

# list channels
print(c.list_channel('/'))  # ["/foo"]
print(s.recv_msg())  # c2s
print(c.recv_msg())  # s2c

cli = k3redisutil.RedisProxyClient([('127.0.0.1', 2222), ('192.168.0.100', 222)])

cli.set('k1', 'v1', retry=1)
cli.set('k2', 'v2', expire=1000)  # msec

print(cli.get('k1', retry=2))
# out: 'v1'

print(cli.get('k2'))
# out: 'v2'

time.sleep(1)
cli.get('k2')
# raise a 'redisutil.KeyNotFoundError' because it is timeout

cli.hset('hashname1', 'k3', 'v3')
cli.hset('hashname2', 'k4', 'v4', expire=1000)

print(cli.hget('hashname1', 'k3'))
# out: 'v3'

print(cli.hget('hashname2', 'k4'))
# out: 'v4'

time.sleep(1)
cli.hget('hashname2', 'k4')
# raise a 'redisutil.KeyNotFoundError' because it is timeout

```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
k3priorityqueue 0.1.6
Priority queue with weighted producer support
License: MIT
Requires Python: >=3.9
Keywords: queue, priority-queue, producer, weighted

# k3priorityqueue

[![Action-CI](https://github.com/pykit3/k3priorityqueue/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3priorityqueue/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3priorityqueue/badge/?version=stable)](https://k3priorityqueue.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3priorityqueue)](https://pypi.org/project/k3priorityqueue)

priorityQueue is a queue with priority support

k3priorityqueue is a component of [pykit3] project: a python3 toolkit set.


PriorityQueue is a queue with priority support:

The numbers of items it pops from each producer matches exactly the ratio of their priority:
If the priorities of 3 producer A, B and C are 1, 3 and 7, and it runs long
enough, it is expected that the number of items popped from A, B and C are
1:3:7.

import k3priorityqueue

producers = (
    # id, priority, iterable
    (1, 1, [1] * 10),
    (2, 2, [2] * 10),
    (3, 3, [3] * 10),
)
pq = k3priorityqueue.PriorityQueue()
for pid, prio, itr in producers:
    pq.add_producer(pid, prio, itr)

count = {}
for _ in range(12):
    val = pq.get()
    count[val] = count.get(val, 0) + 1
    print(val)

print('respect priority ratio: counts:', repr(count))

while True:
    try:
        val = pq.get()
    except k3priorityqueue.Empty as e:
        break
    count[val] = count.get(val, 0) + 1
    print(val)

print('consumed all: counts:', repr(count))




# Install

```
pip install k3priorityqueue
```

# Synopsis

```python

import k3priorityqueue

producers = (
    # id, priority, iterable
    (1, 1, [1] * 10),
    (2, 2, [2] * 10),
    (3, 3, [3] * 10),
)
pq = k3priorityqueue.PriorityQueue()
for pid, prio, itr in producers:
    pq.add_producer(pid, prio, itr)

count = {}
for _ in range(12):
    val = pq.get()
    count[val] = count.get(val, 0) + 1
    print(val)

print('respect priority ratio: counts:', repr(count))

while True:
    try:
        val = pq.get()
    except k3priorityqueue.Empty as e:
        break
    count[val] = count.get(val, 0) + 1
    print(val)

print('consumed all: counts:', repr(count))
```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3