Author petr@motejlek.net
Recipients docs@python, petr@motejlek.net
Date 2017-01-25.17:25:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1485365131.36.0.15146613889.issue29374@psf.upfronthosting.co.za>
In-reply-to
Content
Hi,

The documentation for signal.signal() clearly states that it is only supposed to be called on MainThread

However, it does not say so for the signal.sigwait() and neither signal.sigtimedwait()

I think this is an error on the documentation side of things (unless I misread it). When either signal.sigwait or signal.sigtimedwait are called outside MainThread, they simply never catch any signals (signal.sigwait blocks indefinitely)

I did not test this on Windows, but on both Linux and OS X the behavior is the same

Consider the below simple code

  import signal
  import os
  def sigwait():
    print("Send me a signal, my PID is {p}".format(p=os.getpid()))  
    print("Got the signal: {i}".format(i=signal.sigwait((signal.SIGUSR1,))))

If sigwait() is called on MainThread and the process receives SIGUSR1, "Got the signal: ..." gets printed. However, calling sigwait in a different thread blocks the thread indefinitely. The behavior is the same with signal.sigtimedwait() as well
History
Date User Action Args
2017-01-25 17:25:31petr@motejlek.netsetrecipients: + petr@motejlek.net, docs@python
2017-01-25 17:25:31petr@motejlek.netsetmessageid: <1485365131.36.0.15146613889.issue29374@psf.upfronthosting.co.za>
2017-01-25 17:25:31petr@motejlek.netlinkissue29374 messages
2017-01-25 17:25:30petr@motejlek.netcreate