Issue #41 resolved
A Jagoe
created an issue

I used your code sample solution to issue #25 and it works fine to get the data. However, after returning the data, my script never completes...and finally the below error is returned from the api. The blocker for me is I cannot process the data once I get it because the script hangs.

Any ideas?

Traceback (most recent call last):
  File "", line 61, in <module>
    result = aws_product_search(line.strip())
  File "", line 27, in aws_product_search
    for page in api.item_search("All", Keywords=keywords):
  File "/Library/Python/2.7/site-packages/amazonproduct/", line 47, in __iter__
    yield + 1) 
  File "/Library/Python/2.7/site-packages/amazonproduct/", line 54, in page
    root =*self.args, **self.kwargs)
  File "/Library/Python/2.7/site-packages/amazonproduct/", line 75, in <lambda>
    method = lambda *a, **b: fnc(api, *a, **b)
  File "/Library/Python/2.7/site-packages/amazonproduct/", line 360, in item_search
    SearchIndex=search_index, **params)
  File "/Library/Python/2.7/site-packages/amazonproduct/", line 281, in call
    fp = self._fetch(url)
  File "/Library/Python/2.7/site-packages/amazonproduct/", line 208, in _fetch
    response =
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 394, in open
    response = self._open(req, data)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 412, in _open
    '_open', req)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 372, in _call_chain
    result = func(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 1199, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 1174, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error timed out>

Comments (4)

  1. Sebastian Rahlf repo owner

    This may be a temporary network problem. Try this

    from amazonproduct import API
    import logging
    logger = logging.getLogger('amazonproduct.api')
    class LoggingAPI (API):
        def call(self, **qargs):
  'Calling API with %r' % qargs)
            return super(LoggingAPI, self).call(**qargs)
        def _fetch(self, url):
            logger.debug('Fetching %s...' % url)
            return super(LoggingAPI, self)._fetch(url)

    and simply use LoggingAPI instead of API in your code. This should give you a bit more insight.

  2. A Jagoe reporter

    Thanks for the quick response Sebastian. There seems to be an issue with the iterator over the LxmlItemSearchPaginator object returned from my code.

    for page in api.item_search("All", Keywords=keywords):
        for product in page.Items.Item:
            print product.ItemAttributes.Title

    I'm looping through a file where each line has the keywords for a specific search. All the data is returned fine, but the loop over the file hangs when it should complete. If I remove the code I pasted above for the LxmlItemSearchPaginator iterator, the file loop returns just fine.

    Below is the console output of the last item in the file. Exactly as desired...except for the problem with the iterator. I'm using Python 2.7.2 on OS X 10.8.2.

    Sorry for the messy display...I can't seem to get the bitbucket markdown to work correctly for it...

    Timbuk2 Classic Messenger Bag INFO:amazonproduct.api:Calling API with {'Keywords': 'Timbuk2+Classic+Messenger+Bag', 'ItemPage': 1, 'Operation': 'ItemSearch', 'SearchIndex': 'All', 'limit': 5} DEBUG:amazonproduct.api:Fetching Timbuk2 Command Laptop Messenger Bag (Black, Medium) INFO:amazonproduct.api:Calling API with {'ItemId': 'B005HEV52G', 'Operation': 'ItemLookup', 'ResponseGroup': 'Images,Small'} DEBUG:amazonproduct.api:Fetching INFO:amazonproduct.api:Calling API with {'Keywords': 'Timbuk2+Classic+Messenger+Bag', 'ItemPage': 2, 'Operation': 'ItemSearch', 'SearchIndex': 'All', 'limit': 5} DEBUG:amazonproduct.api:Fetching INFO:amazonproduct.api:Calling API with {'Keywords': 'Timbuk2+Classic+Messenger+Bag', 'ItemPage': 3, 'Operation': 'ItemSearch', 'SearchIndex': 'All', 'limit': 5} DEBUG:amazonproduct.api:Fetching INFO:amazonproduct.api:Calling API with {'Keywords': 'Timbuk2+Classic+Messenger+Bag', 'ItemPage': 4, 'Operation': 'ItemSearch', 'SearchIndex': 'All', 'limit': 5} DEBUG:amazonproduct.api:Fetching INFO:amazonproduct.api:Calling API with {'Keywords': 'Timbuk2+Classic+Messenger+Bag', 'ItemPage': 5, 'Operation': 'ItemSearch', 'SearchIndex': 'All', 'limit': 5} DEBUG:amazonproduct.api:Fetching Finished

  3. Log in to comment