Can writing to a UDP socket ever block?

后端 未结 2 1184
天命终不由人
天命终不由人 2021-02-19 07:04

And if so, under what conditions? Or, phrased alternately, is it safe to run this code inside of twisted:

class StatsdClient(AbstractStatsdClient):
  def __init_         


        
2条回答
  •  天命终不由人
    2021-02-19 07:35

    Yes, oddly, a UDP socket can block.

    The conditions under which this can happen are basically, some buffers somewhere fill up, your operating system decides it's time for something to block. These are arguably kernel bugs, but I've seen them here and there. You can definitely get EWOULDBLOCK sometimes under obscure, impossible-to-reproduce conditions.

    Why would you want to do this in Twisted instead of using Twisted's built-in UDP support though?

提交回复
热议问题