signals (again)

bill bill.pursell at gmail.com
Wed Aug 10 18:40:22 EDT 2005


I see this (or similar) question occasionally looking back through the
archive, but haven't yet seen a definitive answer, so I'm going to ask
it again.

Consider the following:

while True:
    do_something_to_files_in_directory(fd)
    fcntl(fd, F_NOTFIY, DN_CREATE)
    signal.pause()


How do you deal with the signal that occurs after the fcntl and before
the pause?  The solution to sleep instead of pause is aesthetically
ugly and doesn't really help.  I've thought about examining the stack
trace in the signal handler for SIGIO and responding appropriately, but
that's pretty ugly too.  I saw some mention of implementing a try:
construct that would delay receipt of the signal for one atomic python
instruction, and that seemed like a good idea, but I didn't see much
follow up on that.  What's the pythonic thing to do here?  How can I
guarantee timely response to the creation of a file in the directory
referenced by fd?




More information about the Python-list mailing list