scrapinghub / python-scrapinghub

A client interface for Scrapinghub's API
https://python-scrapinghub.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
202 stars 63 forks source link

Omitting `_key` hangs `_BatchWriter` #152

Open alexander-matsievsky opened 4 years ago

alexander-matsievsky commented 4 years ago

Failing

# reprex.py
import os

import scrapinghub

store = (
    scrapinghub.ScrapinghubClient(os.getenv('SH_APIKEY'))
    .get_project(1234567890)
    .collections.get_store("ok_to_mess_around_with")
)

writer = store.create_writer()

writer.write({"foo": "bar"})
print("write")

writer.write({"fizz": "buzz"})
print("write")

writer.flush()
print("flush")
python reprex.py 

write
write
^CTraceback (most recent call last):
...
KeyboardInterrupt

Passing

import os

import scrapinghub

store = (
    scrapinghub.ScrapinghubClient(os.getenv('SH_APIKEY'))
    .get_project(1234567890)
    .collections.get_store("ok_to_mess_around_with")
)

writer = store.create_writer()

writer.write({"_key": "foo", "foo": "bar"})
print("write")

writer.write({"_key": "fizz", "fizz": "buzz"})
print("write")

writer.flush()
print("flush")
python reprex.py

write
write
flush