zeromq/pyzmq — pull request #266 by dowski (2012-10-03 22:48:52+00:00)
Title: Better fix for cleanup on process termination.

(This is a follow-up to https://github.com/zeromq/pyzmq/pull/265).

If `getpid` is None due to the module itself already being garbage
collected, it is reimported in order to be used in the cleanup logic.

This ensures that `zmq_term` is called when needed and still works
around missing global `getpid`.

Using the underlying C `getpid` functionality would require too much x-platform work that `os.getpid` already does for us. This lazy-import seems a little hackish but it should be an OK workaround for this corner case.