gRPC Python sets the SO_REUSEADDR option on server sockets, which allows
multiple servers to bind to the same port.

On Mon, Sep 4, 2017 at 5:58 AM, Amit Saha <[email protected]> wrote:

> Hey all,
>
> This is the relevant part of my server:
>
> def serve():
>   server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
>   users_service.add_UsersServicer_to_server(UsersService(), server)
>   res = server.add_insecure_port('127.0.0.1:50051')
>   server.start()
>   try:
>     while True:
>       time.sleep(_ONE_DAY_IN_SECONDS)
>   except KeyboardInterrupt:
>     server.stop(0)
>
>
> On OS X, by mistake i started the server twice in different terminal
> sessions and I expected it to fail the second time (address already bound,
> etc). However, it didn't error out and this is what I see via lsof:
>
> $ sudo lsof -iTCP:50051
>
> COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
> Python  12120 amit    4u  IPv6 0xffbffb1742aa0f0f      0t0  TCP
> localhost:50051 (LISTEN)
> Python  12157 amit    4u  IPv6 0xffbffb1742aa144f      0t0  TCP
> localhost:50051 (LISTEN)
>
> Curiously enough, they both have the same FD.
>
> (I verified it with a Flask application to see if it was something Python
> specific, and i do see the expected error message when I try to start a
> second instance of the same)
>
> Thanks for any hints in advance.
>
> Best Wishes,
> Amit.
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/grpc-io.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/grpc-io/7bef9f00-c9fa-4cdc-91c7-c3555c177c9a%40googlegroups.com
> <https://groups.google.com/d/msgid/grpc-io/7bef9f00-c9fa-4cdc-91c7-c3555c177c9a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CAGm2-Y5xLvNKSqyPo6zzHBi6JHVZADSrJ5BNfJ12AjS%3D%3D2UijQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to