How to quit an asyncore dispatcher from a handler?

后端 未结 4 1823
谎友^
谎友^ 2020-12-18 03:48

I couldn\'t find this in the docs, but how am I meant to break out of the asyncore.loop() without using signals?

4条回答
  •  再見小時候
    2020-12-18 04:40

    Another approach is to use the count parameter of asyncore.loop call. You can then wrap asyncore.loop in other logic:

    while(i_should_continue()):
        asyncore.loop(count=1)
    

    This won't immediately stop an open connection, or prematurely timeout. But this is probably a good thing? I'm using this when I start a listening server.

提交回复
热议问题