Skip to content
Snippets Groups Projects
Commit 6ad48a1e authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Disconnect from SQLite DB when tearing down tests

This allows the temp directory to be cleaned up on Windows.
parent 279388e3
No related branches found
No related tags found
No related merge requests found
...@@ -46,6 +46,8 @@ class TaskUpdateQueue: ...@@ -46,6 +46,8 @@ class TaskUpdateQueue:
self._db.isolation_level = '' self._db.isolation_level = ''
def _disconnect_db(self): def _disconnect_db(self):
if self._db is None:
return
self._log.info('Disconnecting from database %s', self.db_fname) self._log.info('Disconnecting from database %s', self.db_fname)
self._db.close() self._db.close()
self._db = None self._db = None
...@@ -91,6 +93,8 @@ class TaskUpdateQueue: ...@@ -91,6 +93,8 @@ class TaskUpdateQueue:
self._log.debug('Inspecting queued task updates.') self._log.debug('Inspecting queued task updates.')
await self.flush_and_catch(loop=loop) await self.flush_and_catch(loop=loop)
self._disconnect_db()
self._log.warning('Stopping work loop') self._log.warning('Stopping work loop')
def _queue(self) -> typing.Iterable[typing.Tuple[int, str, object]]: def _queue(self) -> typing.Iterable[typing.Tuple[int, str, object]]:
......
import asyncio import asyncio
import copy import copy
import datetime import datetime
import logging
import tempfile import tempfile
from unittest.mock import Mock from unittest.mock import Mock
...@@ -16,6 +17,8 @@ class TaskUpdateQueueTest(AbstractWorkerTest): ...@@ -16,6 +17,8 @@ class TaskUpdateQueueTest(AbstractWorkerTest):
from flamenco_worker.cli import construct_asyncio_loop from flamenco_worker.cli import construct_asyncio_loop
from tests.mock_responses import CoroMock from tests.mock_responses import CoroMock
logging.getLogger('flamenco_worker.upstream_update_queue').setLevel(logging.DEBUG)
self.asyncio_loop = construct_asyncio_loop() self.asyncio_loop = construct_asyncio_loop()
self.shutdown_future = self.asyncio_loop.create_future() self.shutdown_future = self.asyncio_loop.create_future()
...@@ -31,6 +34,8 @@ class TaskUpdateQueueTest(AbstractWorkerTest): ...@@ -31,6 +34,8 @@ class TaskUpdateQueueTest(AbstractWorkerTest):
) )
def tearDown(self): def tearDown(self):
self.tuqueue._disconnect_db()
super().tearDown()
self.tmpdir.cleanup() self.tmpdir.cleanup()
def test_queue_push(self): def test_queue_push(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment