Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: too many values to unpack (expected 2) #86

Open
RuABraun opened this issue Apr 8, 2020 · 1 comment
Open

Error: too many values to unpack (expected 2) #86

RuABraun opened this issue Apr 8, 2020 · 1 comment

Comments

@RuABraun
Copy link

RuABraun commented Apr 8, 2020

Python 3.7.6, running example:

sending function jobs to cluster

Traceback (most recent call last):
  File "testb.py", line 113, in <module>
    main()
  File "testb.py", line 105, in main
    job_outputs = process_jobs(functionJobs, max_processes=4)
  File "/idiap/temp/rbraun/programs/anaconda3/lib/python3.7/site-packages/gridmap/job.py", line 887, in process_jobs
    with JobMonitor(temp_dir=temp_dir) as monitor:
  File "/idiap/temp/rbraun/programs/anaconda3/lib/python3.7/site-packages/gridmap/job.py", line 299, in __init__
    for _, _, _, _, (ip, _) in getaddrinfo(getfqdn(), 0):
ValueError: too many values to unpack (expected 2)

I fixed it by changing the code to

for _, _, _, _, tpl in getaddrinfo(getfqdn(), 0):
    if len(tpl) > 2:
        continue
    ip = tpl[0]
@mulhod
Copy link
Contributor

mulhod commented Apr 15, 2020

@RuABraun Thanks for filing this issue. I see you are indeed correct as the get_addrinfo function will return 5-tuples with the last element being either a 2-tuple or a 4-tuple, the latter of which we are not handling correctly. However, I think we should be filtering on AF_INET (which corresponds to the 2-tuple), e.g.

# from socket import AF_INET
for _, _, _, _, (ip, _) in getaddrinfo(getfqdn(), 0, AF_INET):
    ...

This way, the unpacking that assigns to the ip variable will be left intact. It is more readable, in my opinion.

@RuABraun Do you think this makes sense? And, if you are able to try with this instead, it would be much appreciated. I'd like to know that it works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants