BelgianBiodiversityPlatform / python-dwca-reader

🐍 A Python package to read Darwin Core Archive (DwC-A) files.
BSD 3-Clause "New" or "Revised" License
43 stars 21 forks source link

DWCA reader is not closing properly [Python v3.5 windows7] #64

Closed pedrosiracusa closed 6 years ago

pedrosiracusa commented 7 years ago

When I try to close the DWCA reader object python throws me the following error traceback: Traceback (most recent call last): File "<ipython-input-5-8e4d11a91f1d>", line 1, in <module> dwca.close()

File "F:\Anaconda3\lib\site-packages\dwca\read.py", line 316, in close self._cleanup_temporary_dir()

File "F:\Anaconda3\lib\site-packages\dwca\read.py", line 319, in _cleanup_temporary_dir rmtree(self._directory_to_clean, False)

File "F:\Anaconda3\lib\shutil.py", line 488, in rmtree return _rmtree_unsafe(path, onerror)

File "F:\Anaconda3\lib\shutil.py", line 383, in _rmtree_unsafe onerror(os.unlink, fullname, sys.exc_info())

File "F:\Anaconda3\lib\shutil.py", line 381, in _rmtree_unsafe os.unlink(fullname)

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\Pedro\\AppData\\Local\\Temp\\tmpf20rfyg1\\multimedia.txt'

I'm using the Spyder IDE, and apparently it locks the temp folder from being removed during its execution, and therefore I'm not sure if this is an issue with dwca-reader or with Spyder itself...

niconoe commented 7 years ago

That may very well be a consequence of #63, since the temporary directory creation was (silently) buggy since a long time.

I'll try first to fix it, then to run the full test suite on Windows. Hope to release a new version soon!

niconoe commented 7 years ago

@pedrosiracusa, could you try again with the freshly released v0.10.1?

Thanks!

pedrosiracusa commented 7 years ago

Thanks for the fix @niconoe ! mkdtemp() is now working properly, although there's still an issue with the closing method dwca.close() for (Windows7+Spyder) setup. Thanks!

niconoe commented 7 years ago

I can confirm the issue with the test suite from the command-line (so it's not Spyder related). More probably because it seems Windows can't remove a directory if there are opened files inside.

Initial plan of action:

niconoe commented 7 years ago

Hi @pedrosiracusa ,

I just released a new version (0.10.2) that supposedly fixes all known bugs under Windows. Could you have a look and tell me if this is solved?

Thanks a lot!

niconoe commented 6 years ago

No news, supposedly solved!