I get the error: TypeError: 'NoneType' object is not iterable when i try to geocode over 200K IPs using the following code excerpt. Please note that when I geocode just 100K IPs no errors are occurring:
#writing a function that takes index, geocodes the ip individually for multithreading
def new_geocode_ip_ver2(ipandresponse):
if ipandresponse[1]!='0':
match=geolite2.lookup(ipandresponse[0])
if match is not None:
lat, lng = match.location
else:
lat="GC failed"
lng="GC failed"
else:
lat="Non-pingable, no GC"
lng="Non-pingable, no GC"
return lat, lng
#spawn threads for geocoding IPs
pool=ThreadPool(200)
latlng_result=pool.map(new_geocode_ip_ver2,ip_response)
pool.close()
pool.join()
The error is message is provided below. Can anyone tell me why this error is occuring on over 100k IP only. I am trying to build my program in such a way that I will be able to geocode a million + IPs. Do I have some kind of memory leak by any chance?
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-26e36f25645e> in <module>()
32 #spawn threads for geocoding IPs
33 pool=ThreadPool(200)
---> 34 latlng_result=pool.map(new_geocode_ip_ver2,ip_response)
35 pool.close()
36 pool.join()
C:\Users\sibag\Anaconda2\lib\multiprocessing\pool.pyc in map(self, func, iterable, chunksize)
249 '''
250 assert self._state == RUN
--> 251 return self.map_async(func, iterable, chunksize).get()
252
253 def imap(self, func, iterable, chunksize=1):
C:\Users\sibag\Anaconda2\lib\multiprocessing\pool.pyc in get(self, timeout)
565 return self._value
566 else:
--> 567 raise self._value
568
569 def _set(self, i, obj):
TypeError: 'NoneType' object is not iterable