Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Connection' object has no attribute '_transport' #110

Closed
n00bsys0p opened this issue May 27, 2020 · 4 comments
Closed

'Connection' object has no attribute '_transport' #110

n00bsys0p opened this issue May 27, 2020 · 4 comments

Comments

@n00bsys0p
Copy link

Hi,

I am and have been regularly seeing this in our server logs. It's constant and quite frequent. I've had a look through the library and I can't see anywhere that would allow a Connection to have no Transport, as it's assigned in the constructor.

Here's a traceback (apologies for formatting, it's copied directly from our remote logging provider):

Task exception was never retrieved
future: <Task finished coro=<request_handler() done, defined at /usr/local/lib/python3.7/dist-packages/grpclib/server.py:342> exception=AttributeError("'Connection' object has no attribute '_transport'")>

grpclib/protocol.py in flush at line 219
                      stream_id=stream_id, wrapper=wrapper)

    def flush(self) -> None:
        data = self._connection.data_to_send()
        if data:
            self._transport.write(data)

    def close(self) -> None:
        if hasattr(self, '_transport'):
            self._transport.close()
            # remove cyclic references to improve memory usage

grpclib/protocol.py in ack at line 199
        return self._connection.receive_data(data)  # type: ignore

    def ack(self, stream_id: int, size: int) -> None:
        if size:
            self._connection.acknowledge_received_data(size, stream_id)
            self.flush()

    def pause_writing(self) -> None:
        self.write_ready.clear()

    def resume_writing(self) -> None:

        def release_stream(*, _streams: _Streams = self.streams) -> None:
            assert stream.id is not None
            _stream = _streams.pop(stream.id)
            self.connection.stream_close_waiter.set()
            self.connection.ack(stream.id, _stream.buffer.unacked_size())
        return release_stream

    def close(self, reason: str = 'Connection closed') -> None:
        self.connection.close()

grpclib/server.py in request_handler at line 446
    except ProtocolError:
        log.exception('Application error')
    except Exception:
        log.exception('Server error')
    finally:
        release_stream()

class _GC(abc.ABC):
    _gc_counter = 0
@nickpro
Copy link

nickpro commented May 27, 2020

met the same error

@vmagamedov
Copy link
Owner

This is not critical but should be fixed. We have an optimisation to remove cyclic references, that's why this error is so cryptic.

del self._transport

release_stream is trying to send information over a connection, but connection is already closed. We have to add a check for this case.

@edigaryev
Copy link

@vmagamedov care to cut a new PyPI release?

@vmagamedov
Copy link
Owner

@edigaryev just released https://pypi.org/project/grpclib/0.3.2rc2/, proper version release will follow very soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants