Skip to content

Commit

Permalink
add sleep to unittests to ensure dbs can be deleted (#391)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #391

Added a 100ms sleep between turning off the test server and deleting the test db.

Server-related unittests sometimes fail (seen when running tests in Windows) when trying to delete the test db, likely due to the db's not fully released by the server yet.

This bug is inconsistent when it appears, but so far only on Windows OS and only consistently in Github Workflows with specific combinations of dependencies and OS versions.

Theoretically could happen outside of tests but it is rare to stop a server and delete the related db one after another. A more careful fix could add checks in place for this.

Reviewed By: crasanders

Differential Revision: D63486690

fbshipit-source-id: 665fc6b1be8da8d5c76fd6195b64c2037bc6dde7
  • Loading branch information
JasonKChow authored and facebook-github-bot committed Sep 26, 2024
1 parent 4ad541d commit 910459d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/server/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import unittest
import uuid
from unittest.mock import MagicMock
import time

import aepsych.server as server
import aepsych.utils_logging as utils_logging
Expand Down Expand Up @@ -62,6 +63,9 @@ def setUp(self):
def tearDown(self):
self.s.cleanup()

# sleep to ensure db is closed
time.sleep(0.1)

# cleanup the db
if self.s.db is not None:
self.s.db.delete_db()
Expand Down

0 comments on commit 910459d

Please sign in to comment.