Every time the program terminates when it runs the third time through this loop:
for component_ID in self.component_IDs:
print component_ID
fundamentals(component_ID)
This is my fundamentals class:
class fundamentals(download):
def __init__(self, ID):
self.browser = spynner.Browser()
self.url = self.getURL(ID)
self.browser.load(self.url)
html = self.browser.html
print "1"
soup = BeautifulSoup(html)
print "2"
self.count = self.get_count(soup)
self.currency = self.get_currency(soup)
self.fundamentals = self.get_fundamentals_pages(soup)
self.write_fundamentals_to_db(id, self.currency, self.count,
self.fundamentals)
The program always stops when soup = Beautiful(Soup) is executed the 3rd time. This doesn’t depend on which component_ID is provided.
component_ID has a length of 30 and when I start the loop at index 2 it also runs two times and stops at the 3rd run.
How does such strange behavior happen and how can I prevent it the next time?
More info:
Additionally the program just terminates without an error-message after printing 1 for the 3rd time. I am not sure what to do now.
When I only implement the .close(), but call the loop as above, it stops after going through the loop once. When I save the instance in the attribute self.component_ID the loop breaks after looping twice.
EDIT: I solved the previous version of this question by closing the spynner.browser and changing how the loop works. Instead of just calling the class I build a list and appended the instances to it.
Close the spynner.browser and change the way the loop works. Instead of just calling the class, build a list and appended the instances to it.