msgpack unpacks the number '10' between each item
<p>I'm trying to use <a href="https://pypi.python.org/pypi/msgpack-python" rel="nofollow">msgpack</a> to write a list of dictionaries to a file. However, when I iterate over an instance of <code>Unpacker</code>, it seems like the number <code>10</code> is unpacked between each 'real' document.</p>

<p>The test script I'm running is</p>

<pre><code>import msgpack
from faker import Faker
import logging
from logging.handlers import RotatingFileHandler

fake = Faker()
fake.seed(0)

data_file = "my_log.log"

logger = logging.getLogger('my_logger')
logger.setLevel(logging.DEBUG)
handler = RotatingFileHandler(data_file, maxBytes=2000, backupCount=10)
logger.addHandler(handler)

fake_dicts = [{'name': fake.name()} for _ in range(100)]

for item in fake_dicts:
    dump_string = msgpack.packb(item)
    logger.debug(dump_string)

unpacker = msgpack.Unpacker(open(data_file))

for unpacked in unpacker:
    print unpacked
</code></pre>

<p>where I've used <a href="https://pypi.python.org/pypi/fake-factory" rel="nofollow">fake-factory</a> to generate fake data. The resulting printed output is as follows:</p>

<pre><code>{'name': 'Joshua Carter'}
10
{'name': 'David Williams'}
10
{'name': 'Joseph Jones'}
10
{'name': 'Gary Perry'}
10
{'name': 'Terry Wells'}
10
{'name': 'Vanessa Cooper'}
10
{'name': 'Michael Simmons'}
10
{'name': 'Nicholas Kline'}
10
{'name': 'Lori Bennett'}
10
</code></pre>

<p>I don't understand why the number <code>10</code> is printed between each dictionary?  Is this somehow introduced by the <code>logger</code>?</p>

<p>This is coming from the contents of unpacker.  You can replicate yourself like this:</p>

<pre><code>In [23]: unpacker = msgpack.Unpacker(open(data_file))

In [24]: unpacker.next()
Out[24]: {'name': 'Edward Ruiz'}

In [25]: unpacker.next()
Out[25]: 10
</code></pre>

python