Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac #30671: Random failure in src/sage/interfaces/psage.py
Browse files Browse the repository at this point in the history
Clearly the dtor is racing with the sage-cleaner process that is
deleting the temporary directory:
{{{
File "src/sage/interfaces/psage.py", line 114, in
sage.interfaces.psage.PSage.__del__
Failed example:
    PSage().__del__()
Expected nothing
Got:
    Exception ignored in: <function ExpectElement.__del__ at 0xd14d6388>
    Traceback (most recent call last):
      File "/home/buildbot/slave/sage_git/build/local/lib/python3.8
/site-packages/sage/interfaces/expect.py", line 1513, in __del__
        P.clear(self._name)
      File "/home/buildbot/slave/sage_git/build/local/lib/python3.8
/site-packages/sage/interfaces/sage0.py", line 369, in clear
        self.eval('del %s' % var)
      File "/home/buildbot/slave/sage_git/build/local/lib/python3.8
/site-packages/sage/interfaces/psage.py", line 129, in eval
        if self.is_locked():
      File "/home/buildbot/slave/sage_git/build/local/lib/python3.8
/site-packages/sage/interfaces/psage.py", line 97, in is_locked
        with open(self.__tmp) as fobj:
    FileNotFoundError: [Errno 2] No such file or directory: '/home/build
bot/slave/sage_git/dot_sage/temp/sagebu16_32s02/3311/sage_smpux8mxorv//l
ock'
**********************************************************************
1 item had failures:
   1 of   2 in sage.interfaces.psage.PSage.__del__
    [7 tests, 1 failure, 4.76 s]
}}}

URL: https://trac.sagemath.org/30671
Reported by: vbraun
Ticket author(s): Markus Wageringel
Reviewer(s): Volker Braun
  • Loading branch information
Release Manager committed Sep 27, 2020
2 parents ed7c4a3 + bd3c899 commit be1a62b
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/sage/interfaces/psage.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,21 @@ def __del__(self):
sage: PSage().__del__()
"""
if os.path.exists(self.__tmp_dir):
for x in os.listdir(self.__tmp_dir):
os.remove(os.path.join(self.__tmp_dir, x))
try:
files = os.listdir(self.__tmp_dir)
except OSError:
pass
else:
for x in files:
try:
os.remove(os.path.join(self.__tmp_dir, x))
except OSError:
pass
try:
os.removedirs(self.__tmp_dir)
except OSError:
pass

if not (self._expect is None):
cmd = 'kill -9 %s'%self._expect.pid
os.system(cmd)
Expand Down

0 comments on commit be1a62b

Please sign in to comment.