How to shut down a TCPServer serve_forever() loop?

Chris Angelico rosuav at gmail.com
Tue Nov 28 13:39:32 EST 2017


On Wed, Nov 29, 2017 at 5:32 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Chris Angelico <rosuav at gmail.com>:
>
>> On Wed, Nov 29, 2017 at 5:03 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
>>> Chris Angelico <rosuav at gmail.com>:
>>>> Do you respect /etc/nsswitch.conf?
>>>
>>> No, but I don't need to.
>>
>> Ah, right. Until the day you're wrestling with "why doesn't /etc/hosts
>> apply to this program". Yep, you totally don't need nsswitch.
>
> Don't you worry about my programs.

Okay, but you can't claim that problems are solvable if you cheat them.

>>> In this discussion I was referring to the fact that you can interrupt
>>> a coroutine while that is generally not possible to do to a blocking
>>> thread.
>>
>> I'm not sure what you mean by a "blocking thread". Whether it's a
>> coroutine or not, you can't interrupt gethostbyname(); and whether
>> it's a coroutine or not, you CAN interrupt any syscall that responds
>> to signals (that's the whole point of EINTR).
>
> Please reread the original poster's question. It was about a blocking
> TCP listener call that another thread couldn't interrupt.

Yet a SIGINT would successfully interrupt it. I'm not sure what your
point is. Would the OP have been trivially able to switch to asyncio?
Maybe. Would the OP have been trivially able to send a signal to the
process? Yes.

I'm done arguing. You're clearly not listening.

ChrisA



More information about the Python-list mailing list