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

Usage of get_html_string() ends up with TypeError: cannot pickle '_thread.lock' object #173

Open
ebenahar opened this issue Mar 5, 2022 · 1 comment

Comments

@ebenahar
Copy link

ebenahar commented Mar 5, 2022

What did you do?

table = PrettyTable()

        table = table.get_html_string(
            attributes={
                'border': 1, 'style': 'border-width: 1px; border-collapse: collapse; text-align: center; padding: 2px;'
            }
        )

What did you expect to happen?

No exception and functionality to work

What actually happened?

Traceback (most recent call last):
  File "/home/elad/python_projects/vsphere_usage.py", line 246, in <module>
    print_rps(dc_name=dc, cluster_name=cluster)
  File "/home/elad/python_projects/vsphere_usage.py", line 214, in print_rps
    table = table.get_html_string(
  File "/home/elad/git/ocs-ci/venv/lib64/python3.9/site-packages/prettytable/prettytable.py", line 2021, in get_html_string
    string = self._get_simple_html_string(options)
  File "/home/elad/git/ocs-ci/venv/lib64/python3.9/site-packages/prettytable/prettytable.py", line 2060, in _get_simple_html_string
    rows = self._get_rows(options)
  File "/home/elad/git/ocs-ci/venv/lib64/python3.9/site-packages/prettytable/prettytable.py", line 1575, in _get_rows
    rows = copy.deepcopy(self._rows)
  File "/usr/lib64/python3.9/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/usr/lib64/python3.9/copy.py", line 205, in _deepcopy_list
    append(deepcopy(a, memo))
  File "/usr/lib64/python3.9/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/usr/lib64/python3.9/copy.py", line 205, in _deepcopy_list
    append(deepcopy(a, memo))
  File "/usr/lib64/python3.9/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/usr/lib64/python3.9/copy.py", line 205, in _deepcopy_list
    append(deepcopy(a, memo))
  File "/usr/lib64/python3.9/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/usr/lib64/python3.9/copy.py", line 270, in _reconstruct
    state = deepcopy(state, memo)
  File "/usr/lib64/python3.9/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/usr/lib64/python3.9/copy.py", line 230, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib64/python3.9/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/usr/lib64/python3.9/copy.py", line 270, in _reconstruct
    state = deepcopy(state, memo)
  File "/usr/lib64/python3.9/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/usr/lib64/python3.9/copy.py", line 230, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib64/python3.9/copy.py", line 161, in deepcopy
    rv = reductor(4)
TypeError: cannot pickle '_thread.lock' object

What versions are you using?

  • OS: Fedora 34
  • Python: 3.9.10
  • PrettyTable: 3.1.1

Please include code that reproduces the issue.

The best reproductions
are
self-contained scripts
with minimal dependencies.

# code goes here
@OlafvdSpek
Copy link
Contributor

Does it still fail if you run the snippet outside of vsphere_usage.py?

This works fine for me (on another OS and on another version though):

#!/usr/bin/python3
from prettytable import PrettyTable
table = PrettyTable()
table = table.get_html_string(
    attributes={
        'border': 1, 'style': 'border-width: 1px; border-collapse: collapse; text-align: center; padding: 2px;'
    }
)
print(table)

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