I used ThreadPoolExecutor in my API. in the test case, I generated a Movie instance and saved it in the database (PostgreSQL). I printed movie count in the test case, API, and thread pool function. why in the thread pool return an empty queryset?
view.py:
def movie_count():
   print(Movie.objects.count(), "movie count in the thread")
class MovieListView(APIView):
    renderer_classes = (
       render.CamelCaseJSONRenderer,
       renderers.BrowsableAPIRenderer,
    ) 
   def get(self, request, key, format=None):
      print(Movie.objects.count(), "movie count before the thread")
      with ThreadPoolExecutor(1) as executor:
          bookmarked_future = executor.submit(movie_count)
          bookmarked_future.result()
    return Response({})
test.py
def test_mock_function(self):
    Movie.objects.create(
        title="Title"
    )
    print(Movie.objects.count(), "movie count in the test")
    url = reverse('video_api:list', args=('tops',))
    self.client.get(url, format='json', data={'limit': 30})
result:
1 movie counts in the test
1 movie count before the thread
0 movie count in the thread
