1. In general, the channel will remain open indefinitely regardless of the state of the underlying TCP connection. 2. In most cases, __del__ will probably fine, but __del__ is not reliably called when an object goes out of scope. It may happen an arbitrary amount of time after that. If you're *really* worried about deterministically closing the connection, you'll want to add an explicit close method that closes the channel.
On Thu, Feb 2, 2023 at 6:35 AM Jens Troeger <jens.troe...@gmail.com> wrote: > Thanks, that seems to work! > > But it leads me to the next questions: > > 1. If for whatever reason the channel is closed, do I need to reopen > it or does that channel instance manage disconnects itself? Or: how do I > keep the stub alive? > 2. I presume that I should close the channel in the __del__() > <https://docs.python.org/3/reference/datamodel.html#object.__del__> > method of my Servicer? > > Cheers, > Jens > > > On Thursday, February 2, 2023 at 11:26:09 AM UTC+10 rbel...@google.com > wrote: > Jens, > > In general, the best way to do this is to simply create the channel in > your Servicer constructor and then use self._channel or self._stub from > your server handlers. > > -- > You received this message because you are subscribed to the Google Groups " > grpc.io" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to grpc-io+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/grpc-io/f813855d-15c2-488c-9a18-fa135e093fc1n%40googlegroups.com > <https://groups.google.com/d/msgid/grpc-io/f813855d-15c2-488c-9a18-fa135e093fc1n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CAOew_sEQoNL2a%3Dn2U5q6jz9otso%2B8i5Qn8-8tALg88EvAkdS%3DQ%40mail.gmail.com.