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 occurs when running in a non-Linux environment #5

Open
otms61 opened this issue May 17, 2020 · 1 comment
Open

AttributeError occurs when running in a non-Linux environment #5

otms61 opened this issue May 17, 2020 · 1 comment

Comments

@otms61
Copy link
Contributor

otms61 commented May 17, 2020

Hi, thanks for making a great python module.

I understand that README.md says Works on Linux on, but I had a problem that it was difficult to identify the cause from the error message when running on macOS.

Our team is using a memory-tempfile with code that runs on a only Linux machine.
However, some of our team engineers are developing on macOS and when he just run the test code he got the following error:

test_x.py:8: in <module>
    if not tempfile.found_mem_tempdir():
/Users/otms61/.pyenv/versions/3.7.5/lib/python3.7/site-packages/memory_tempfile/memory_tempfile.py:71: in found_mem_tempdir
    return len(self.usable_paths) > 0
E   AttributeError: 'MemoryTempfile' object has no attribute 'usable_paths'

The code is like this

from memory_tempfile import MemoryTempfile

tempfile = MemoryTempfile()
if tempfile.found_mem_tempdir():
    pass

Although it is Works only on Linux, I think there are two problems with the current implementation.

  • temp-memory must be called carefully, and extra code to check the execution environment is required
  • It is difficult to identify the cause from the error message

I think about some solutions.

Solution 1:
No matter what environment you run, initialize enable_pahts to prevent AttributeError.

Solution 2:
Raise RuntimeError when running on non-Linux.

Please let me know the opinion of the author.
Thanks.

@otms61
Copy link
Contributor Author

otms61 commented May 17, 2020

I just implemented it with the solution 1 (#6) .
Thank you for confirmation.

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

1 participant