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

AttributeError: Can't pickle local object 'merge_configuration_file.<locals>.<lambda>' #163

Closed
barakalon opened this issue Oct 11, 2022 · 4 comments · Fixed by #164
Closed
Labels

Comments

@barakalon
Copy link

barakalon commented Oct 11, 2022

Getting an error when attempting to use autoflake:

AttributeError: Can't pickle local object 'merge_configuration_file.<locals>.<lambda>'

The original error: https://github.com/tobymao/sqlglot/actions/runs/3223288986/jobs/5273206564

To reproduce:

❯ python3 -m venv venv

❯ source venv/bin/activate

❯ system_profiler SPSoftwareDataType SPHardwareDataType

Software:

    System Software Overview:
      ...
      System Version: macOS 12.6 (21G115)
      Processor Name: 8-Core Intel Core i9

❯ python3 --version
Python 3.10.1

❯ pip install autoflake
Collecting autoflake
  Using cached autoflake-1.7.2-py2.py3-none-any.whl (17 kB)
Collecting tomli>=2.0.1
  Using cached tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting pyflakes>=1.1.0
  Using cached pyflakes-2.5.0-py2.py3-none-any.whl (66 kB)
Installing collected packages: tomli, pyflakes, autoflake
Successfully installed autoflake-1.7.2 pyflakes-2.5.0 tomli-2.0.1
WARNING: You are using pip version 21.2.4; however, version 22.2.2 is available.
You should consider upgrading via the '/Users/barak_alon/Development/sandbox/venv/bin/python3 -m pip install --upgrade pip' command.

❯ python -m autoflake --version
autoflake 1.7.2

❯ touch foo.py

❯ touch bar.py

❯ python -m autoflake foo.py bar.py
Traceback (most recent call last):
  File "/Users/barak_alon/.pyenv/versions/3.10.1/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/barak_alon/.pyenv/versions/3.10.1/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/barak_alon/Development/sandbox/venv/lib/python3.10/site-packages/autoflake.py", line 1530, in <module>
    sys.exit(main())
  File "/Users/barak_alon/Development/sandbox/venv/lib/python3.10/site-packages/autoflake.py", line 1519, in main
    return _main(
  File "/Users/barak_alon/Development/sandbox/venv/lib/python3.10/site-packages/autoflake.py", line 1501, in _main
    exit_status |= fut.get()
  File "/Users/barak_alon/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/pool.py", line 771, in get
    raise self._value
  File "/Users/barak_alon/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/pool.py", line 537, in _handle_tasks
    put(task)
  File "/Users/barak_alon/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/connection.py", line 211, in send
    self._send_bytes(_ForkingPickler.dumps(obj))
  File "/Users/barak_alon/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/reduction.py", line 51, in dumps
    cls(buf, protocol).dump(obj)
AttributeError: Can't pickle local object 'merge_configuration_file.<locals>.<lambda>'
@fsouza
Copy link
Collaborator

fsouza commented Oct 11, 2022

Hmm, let me send a fix and a test for the parallel execution. Sorry about the breakage.

@fsouza fsouza added the bug label Oct 11, 2022
fsouza added a commit that referenced this issue Oct 11, 2022
Also make sure we finally have a test for the multiprocessing logic.
@fsouza
Copy link
Collaborator

fsouza commented Oct 11, 2022

I have a reproducer in #164. I'll push a fix in that same PR in ~1 hour.

fsouza added a commit that referenced this issue Oct 11, 2022
This makes sure that we don't break multiprocessing. Also introduce a
test to prevent future regressions. I should have added that test ages
ago :)

Closes #163.
fsouza added a commit that referenced this issue Oct 11, 2022
This makes sure that we don't break multiprocessing. Also introduce a
test to prevent future regressions. I should have added that test ages
ago :)

Use --check and a set in the test to avoid flakiness.

Closes #163.
fsouza added a commit that referenced this issue Oct 11, 2022
This makes sure that we don't break multiprocessing. Also introduce a
test to prevent future regressions. I should have added that test ages
ago :)

Use --check and a set in the test to avoid flakiness.

Closes #163.
fsouza added a commit that referenced this issue Oct 11, 2022
This makes sure that we don't break multiprocessing. Also introduce a
test to prevent future regressions. I should have added that test ages
ago :)

Use --check and a set in the test to avoid flakiness.

Closes #163.
@fsouza fsouza closed this as completed in eecb1cc Oct 11, 2022
@DanielNoord
Copy link
Member

Thanks for the quick fix @fsouza! Much appreciated!

@barakalon
Copy link
Author

Confirmed it works now.

Thanks!

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

Successfully merging a pull request may close this issue.

3 participants