Giter Site home page Giter Site logo

problem in test about django-grpc-framework HOT 6 CLOSED

fengsp avatar fengsp commented on May 23, 2024
problem in test

from django-grpc-framework.

Comments (6)

b3nav avatar b3nav commented on May 23, 2024

I'm currently also seeing this problem - making a simple gRPC call results in:

Error
Traceback (most recent call last):
  File "[..].venv/lib/python3.9/site-packages/django/db/backends/base/base.py", line 237, in _cursor
    return self._prepare_cursor(self.create_cursor(name))
  File "[..].venv/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "[..].venv/lib/python3.9/site-packages/django/db/backends/postgresql/base.py", line 236, in create_cursor
    cursor = self.connection.cursor()
psycopg2.InterfaceError: connection already closed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "[..].", line 17, in test_create_or_update_partial
    response = stub.CreateOrUpdate(current_request)
  File "[..].venv/lib/python3.9/site-packages/django_grpc_framework/test.py", line 47, in __call__
    return self._handler.unary_unary(request, context)
  File "[..].venv/lib/python3.9/site-packages/django_grpc_framework/services.py", line 51, in handler
    return getattr(self, action)(request, context)
  File "[..]", line 23, in CreateOrUpdate
    thingy = MagicDatabaseObject.objects.get(pk=request.puzzle.database_id)
  File "[..].venv/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "[..].venv/lib/python3.9/site-packages/django/db/models/query.py", line 431, in get
    num = len(clone)
  File "[..].venv/lib/python3.9/site-packages/django/db/models/query.py", line 262, in __len__
    self._fetch_all()
  File "[..]..venv/lib/python3.9/site-packages/django/db/models/query.py", line 1324, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "[..].venv/lib/python3.9/site-packages/django/db/models/query.py", line 51, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "[..].venv/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1173, in execute_sql
    cursor = self.connection.cursor()
  File "[..].venv/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "[..].venv/lib/python3.9/site-packages/django/db/backends/base/base.py", line 259, in cursor
    return self._cursor()
  File "[..].venv/lib/python3.9/site-packages/django/db/backends/base/base.py", line 237, in _cursor
    return self._prepare_cursor(self.create_cursor(name))
  File "[..].venv/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "[..].venv/lib/python3.9/site-packages/django/db/backends/base/base.py", line 237, in _cursor
    return self._prepare_cursor(self.create_cursor(name))
  File "[..].venv/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "[..].venv/lib/python3.9/site-packages/django/db/backends/postgresql/base.py", line 236, in create_cursor
    cursor = self.connection.cursor()
django.db.utils.InterfaceError: connection already closed

from django-grpc-framework.

b3nav avatar b3nav commented on May 23, 2024

@sobolevn @fengsp - is this repository actively maintained?

from django-grpc-framework.

fengsp avatar fengsp commented on May 23, 2024

@boyan-quine I need more info, how to reproduce it?

from django-grpc-framework.

b3nav avatar b3nav commented on May 23, 2024

@fengsp The way I get this error is when I have multiple test cases in the same file and run them at the same time - it works if I run them one-by-one, but not when I run them all - I saw a few forks removing the db.close_old_connections call and it works if it's removed, but not sure what are the consequences:

https://github.com/fengsp/django-grpc-framework/blob/master/django_grpc_framework/services.py#L45

E.g.
Fork 1: https://github.com/findspace-inc/django-grpc-framework/commit/7edb61ab81b4694b321b70032fbcb10a24dd29c4
Fork 2: algori-io@fe43670#diff-e96daad5bed2c5ae0c073219f7f11722d5c064d7e91b433bdffee8c2264f50d1L45

from django-grpc-framework.

fengsp avatar fengsp commented on May 23, 2024

@boyan-quine close_old_connections is necessary in the normal request. However, we need to remove this behavior under testing, this needs fixes.

from django-grpc-framework.

fengsp avatar fengsp commented on May 23, 2024

Fixed in 0.2.1

from django-grpc-framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.