Skip to content

Commit

Permalink
[3.2.x] Refs #32074 -- Removed usage of deprecated Thread.setDaemon().
Browse files Browse the repository at this point in the history
Thread.setDaemon() was deprecated in Python 3.10 and will be removed in
Python 3.12.

Backport of f9f6bd6 from main
  • Loading branch information
tirkarthi authored and felixxm committed Oct 5, 2021
1 parent 8bebb1c commit d0dc446
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion django/utils/autoreload.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def start_django(reloader, main_func, *args, **kwargs):

main_func = check_errors(main_func)
django_main_thread = threading.Thread(target=main_func, args=args, kwargs=kwargs, name='django-main-thread')
django_main_thread.setDaemon(True)
django_main_thread.daemon = True
django_main_thread.start()

while not reloader.should_stop:
Expand Down
2 changes: 1 addition & 1 deletion tests/utils_tests/test_autoreload.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def test_starts_thread_with_args(self, mocked_check_errors, mocked_thread):
mocked_thread.call_args[1],
{'target': fake_main_func, 'args': (123,), 'kwargs': {'abc': 123}, 'name': 'django-main-thread'}
)
self.assertSequenceEqual(fake_thread.setDaemon.call_args[0], [True])
self.assertIs(fake_thread.daemon, True)
self.assertTrue(fake_thread.start.called)


Expand Down

0 comments on commit d0dc446

Please sign in to comment.