2

For some reason,

result = pool.map(_delete_load_log,list(logs_to_delete))

is now giving me an 'int' object is not iterable error.

as per the screenshot, logs_to_delete is clearly an array (added list() to see if it changed anything, and nope). This worked earlier, but I can't track back what changed to make it not work. Any ideas?

enter image description here

mapping function:

def _delete_load_log(load_log_id):
    logging.debug('** STARTING API CALL FOR: ' + get_function_name())
    input_args = "/15/" + str(load_log_id)
    logging.debug('url: ' + podium_url + '\nusername: ' + podium_username)

    podium = podiumapi.Podium('https://xx/podium','podium','podium')
    #podium = podiumapi.Podium(podium_url,podium_username,podium_password)
    data = None
    response_code = 0
    try:
        api_url = PodiumApiUrl(podium_url,input_args)

        (response_code,data) = podium._podium_curl_setopt_put(api_url)
        if not data[0]['hasErrors']:
            return data[0]['id']
        elif data[0]['hasErrors']:
            raise Exception("Errors detected on delete")
        else:
            raise Exception('Unmanaged exception while retrieving entity load status.')
    except Exception as err:
        raise Exception(str(err))

File "c:\Repos\Tools\podium-dataload\scripts\podiumlogdelete.py", line 69, in _delete_source_load_logs_gte_epoch
    deleted_load_ids = _delete_logs_in_parallel(load_logs_to_delete)
  File "c:\Repos\Tools\podium-dataload\scripts\podiumlogdelete.py", line 85, in _delete_logs_in_parallel
    result = pool.map(_delete_load_log,logs_to_delete)
  File "C:\Python27\lib\multiprocessing\pool.py", line 253, in map
    return self.map_async(func, iterable, chunksize).get()
  File "C:\Python27\lib\multiprocessing\pool.py", line 572, in get
    raise self._value
Exception: 'int' object is not iterable

output of list:

[154840, 154841, 154842, 154843, 154844, 154845, 154846, 154847, 154848, 154849, 154850, 154851, 154852, 154853, 154854, 154855, 154856, 154857, 154858, 154859, 154860, 154861, 154862, 154863, 154864, 154865, 154866, 154867, 154868, 154869, 154870, 154871, 154872, 154873, 154874, 154875, 154876, 154877, 154878, 154879, 154880, 154881, 154882, 154883, 154884, 154885, 154886, 154887, 154888, 154889, 154890, 154891, 154892, 154893, 154894, 154895, 154896, 154897, 154898, 154899, 154900, 154901, 154902, 154903, 154904, 154905, 154906, 154907, 154908, 154909, 154910, 154911, 154912, 154913, 154914, 154915, 154916, 154917, 154918, 154919, 154920, 154921, 154922, 154923, 154924, 154925, 154926, 154927, 154928, 154929, 154930, 154931, 154932, 154933, 154934, 154935, 154936, 154937, 154938, 154939]

9
  • 1
    Looks impossible. Provide the trace back please. Commented Feb 6, 2018 at 17:57
  • @liliscent added traceback Commented Feb 6, 2018 at 18:02
  • 1
    Use print(logs_to_delete) print(type(logs_to_delete)). That will at least give you some indication of what's happening; you'll need to do some debugging first Commented Feb 6, 2018 at 18:06
  • a gist also may be useful and more readable. Commented Feb 6, 2018 at 18:07
  • @roganjosh added. looks like a normal list :| Commented Feb 6, 2018 at 18:08

2 Answers 2

2

Your problem is clear from the traceback. It's not caused by the iterable in Pool.map(), otherwise the exception would be raised from Python source code line

iterable = list(iterable)

Here the exception is raised from

File "C:\Python27\lib\multiprocessing\pool.py", line 253, in map
return self.map_async(func, iterable, chunksize).get()
File "C:\Python27\lib\multiprocessing\pool.py", line 572, in get
raise self._value

This is because your _delete_load_log() raised some exception, and Pool.map re-raise it. See https://github.com/python/cpython/blob/2.7/Lib/multiprocessing/pool.py

In other words, Exception: 'int' object is not iterable is not from the python library part, it's from your own function _delete_load_log().

Sign up to request clarification or add additional context in comments.

1 Comment

that was it. never had a bug within a mapper before. thanks and have a nice day
0

In all honesty, just take a close look at

#podium = podiumapi.Podium(podium_url,podium_username,podium_password)
data = None
response_code = 0
try:

The response code is equivalent to 0, although the traceback function isn't inputted as "invalid", it makes you have to re-patch a lot afterwards.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.