Hi folks, I am implementing a forking SocketServer daemon that maintains significant internal state (a graph that takes ~30s to build by fetching from a SQL database, and eventually further state that may take up to an hour to build).
I would like to be able to notify the daemon that it needs to update its state. Because it forks for each new request, a request handler can't update the state because then only the child would have the new state. One idea I had was to use signals. Is it safe to write a signal handler that does extensive work (several seconds)? Seems like even so, it might be tricky to do this without race conditions. Another possibility is that the signal handler simply sets a needs_update flag, which I could check for in a handle_request() loop. The disadvantage here is that the update wouldn't happen until after the next request is handled, and I would like the state to be available for that next request. A solution might be to send a signal followed by a dummy request, which seems a bit awkward. Any other ideas or suggestions? Thanks in advance, Reid p.s. This group's help on A* search was very much appreciated -- just the ticket! -- http://mail.python.org/mailman/listinfo/python-list