saltstack/salt — pull request #2799 by s0undt3ch (2012-12-04 20:40:18+00:00)
Title: Finally fix the python 2.6 issues.

First of all, this has been a problematic bug which was really hard to chase down. It only got caught when I finally used the 2 perfect(almost) tools, [PuDB](https://github.com/inducer/pudb) and [GDB](http://www.gnu.org/software/gdb/), kudos to these tools!!!

Now, some explanation on what was going on.

Each [zmq.Context](http://zeromq.github.com/pyzmq/api/generated/zmq.core.context.html) spawns two(s) threads, and the most problematic code was in [`salt.utils.event`](https://github.com/saltstack/salt/blob/develop/salt/utils/event.py) which was not [*un*-registering](https://github.com/s0undt3ch/salt/blob/hotfix/gdb-resources/salt/utils/event.py#L159) it's poller socket's. This little thing, unfortunately, was not enough. I had to [explicitly](https://github.com/s0undt3ch/salt/blob/hotfix/gdb-resources/salt/client.py#L1000) force it's garbage collection.

Anyway, I still do not know why it did not fail under python 2.7, I didn't end-up running salt using pudb under 2.7 since the problem was under 2.6 and the issue was detected. It might be that 2.7 is more benevolent, though, I think it would just take a few more test runs to trigger it under 2.7 ;)

There are a bunch more commits in this pull request than this little explanation might tell you, some are some PEP-8 fixes which I took care along the way, others were [needed fixes](https://github.com/saltstack/salt-cloud/issues/186) which were also taken care of along the way, etc.

We have stopped using `py27_subprocess`, and wherever ZMQ is involved, a little *house-cleaning* was enforced so we don't end up in this same place in the future.

We need to check if this has any impact or even fixes #2431, #1863 or even #1094.