Weird HTTP data accumulation in App Engine with Python and CouchDB

I am trying to make a relatively simple App Engine application to download some pages daily and send data to a CouchDB server. I have the following code in an App Engine application (with couchdb-python library):

    # post the result to CouchDB
    price_data = {
      'source': 'blah',
      'date': str(result.headers['date'])
    }
    db.save(price_data)
    db.put_attachment(price_data, file_one, 'prices_one.txt')
    db.put_attachment(price_data, file_two, 'prices_two.txt')

file_oneand file_twoare the results of previous URL requests.

Now everything works fine, except that the first attachment is sent from price_data JSON ({ 'source': 'blah', 'date': 'date here'})the beginning of the text file prices_one, and the second attachment gets the prefix with both price_dataJSON and all prices_onetext files, followed by the actual prices_two.txtfile.
I am sure that if I tried to add a third attachment, he would send all the accumulated data to this. If I go to CouchDB to look at a file in the database, this is a complete file, only from { 'source': 'blah', 'date': 'date here'}the very beginning.

Any ideas that might make App Engine continue to forward previous data with each new HTTP POST? Also, I have to point out that he did the same thing before I started using the couchdb-python library, so there seems to be something related to the App Engine that I don't understand.

+3
1

HTTP CouchDB. App Engine (urlfetch , , urllib2). API CouchDB , .

?

+1

Source: https://habr.com/ru/post/1791039/


All Articles