Refs #31169 -- Added DatabaseCreation.setup_worker_connection() hook.
This commit is contained in:
parent
eabc22f919
commit
ae91ecf6a1
|
@ -369,3 +369,13 @@ class BaseDatabaseCreation:
|
||||||
settings_dict["ENGINE"],
|
settings_dict["ENGINE"],
|
||||||
self._get_test_db_name(),
|
self._get_test_db_name(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def setup_worker_connection(self, _worker_id):
|
||||||
|
settings_dict = self.get_test_db_clone_settings(str(_worker_id))
|
||||||
|
# connection.settings_dict must be updated in place for changes to be
|
||||||
|
# reflected in django.db.connections. If the following line assigned
|
||||||
|
# connection.settings_dict = settings_dict, new threads would connect
|
||||||
|
# to the default database instead of the appropriate clone.
|
||||||
|
self.connection.settings_dict.update(settings_dict)
|
||||||
|
self.mark_expected_failures_and_skips()
|
||||||
|
self.connection.close()
|
||||||
|
|
|
@ -407,13 +407,7 @@ def _init_worker(counter):
|
||||||
|
|
||||||
for alias in connections:
|
for alias in connections:
|
||||||
connection = connections[alias]
|
connection = connections[alias]
|
||||||
settings_dict = connection.creation.get_test_db_clone_settings(str(_worker_id))
|
connection.creation.setup_worker_connection(_worker_id)
|
||||||
# connection.settings_dict must be updated in place for changes to be
|
|
||||||
# reflected in django.db.connections. If the following line assigned
|
|
||||||
# connection.settings_dict = settings_dict, new threads would connect
|
|
||||||
# to the default database instead of the appropriate clone.
|
|
||||||
connection.settings_dict.update(settings_dict)
|
|
||||||
connection.close()
|
|
||||||
|
|
||||||
|
|
||||||
def _run_subsuite(args):
|
def _run_subsuite(args):
|
||||||
|
|
Loading…
Reference in New Issue