Esempio n. 1
0
 def commit(self, sn):
     """
     The request referenced by the serial number has been completely
     processed and can be deleted from the journal.
     :param sn: A request serial number.
     :param sn: str
     """
     try:
         path = self.journal[sn]
         unlink(path)
         log.debug('%s committed', sn)
     except KeyError:
         log.warn('%s not found for commit', sn)
Esempio n. 2
0
 def commit(self, sn):
     """
     The request referenced by the serial number has been completely
     processed and can be deleted from the journal.
     :param sn: A request serial number.
     :param sn: str
     """
     try:
         path = self.journal.pop(sn)
         unlink(path)
         log.debug('%s committed', sn)
     except KeyError:
         log.warning('%s not found for commit', sn)
Esempio n. 3
0
 def _read(path):
     """
     Read a request.
     :param path: The path to the journal file.
     :type path: str
     :return: The read request.
     :rtype: Document
     """
     with open(path) as fp:
         try:
             request = Document()
             body = fp.read()
             request.load(body)
             log.debug('read [%s]: %s', path, body)
             return request
         except ValueError:
             log.error('%s corrupt (discarded)', path)
             unlink(path)
Esempio n. 4
0
 def test_not_exist(self, _unlink):
     path = '/tmp/file'
     exception = OSError()
     exception.errno = errno.ENOENT
     _unlink.side_effect = exception
     unlink(path)
Esempio n. 5
0
 def test_unlink(self, _unlink):
     path = '/tmp/file'
     unlink(path)
     _unlink.assert_called_once_with(path)
Esempio n. 6
0
 def test_not_exist(self, _unlink):
     path = '/tmp/file'
     exception = OSError()
     exception.errno = errno.ENOENT
     _unlink.side_effect = exception
     unlink(path)
Esempio n. 7
0
 def test_unlink(self, _unlink):
     path = '/tmp/file'
     unlink(path)
     _unlink.assert_called_once_with(path)