fabric/fabric — pull request #1218 by yacn (2014-11-04 17:37:18+00:00)
Title: Add local_tunnel context manager to forward local port to the remote server 

This is pull request #939 with a fix added for the exception being raised when the context manager exits

```
Traceback (most recent call last):
File "/Users/yacn/.virtualenvs/fabric/lib/python2.7/site-packages/fabric/main.py", line 743, in main
*args, **kwargs
File "/Users/yacn/.virtualenvs/fabric/lib/python2.7/site-packages/fabric/tasks.py", line 384, in execute
multiprocessing
File "/Users/yacn/.virtualenvs/fabric/lib/python2.7/site-packages/fabric/tasks.py", line 274, in _execute
return task.run(*args, **kwargs)
File "/Users/yacn/.virtualenvs/fabric/lib/python2.7/site-packages/fabric/tasks.py", line 174, in run
return self.wrapped(*args, **kwargs)
File "/Users/yacn/git/tst/fabric/fabfile.py", line 59, in tst
puts(cur.fetchall())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 24, in __exit__
self.gen.next()
File "/Users/yacn/git/fabric/tst/util/ssh.py", line 143, in local_tunnel
listening_thread.raise_if_needed()
File "/Users/yacn/.virtualenvs/fabric/lib/python2.7/site-packages/fabric/thread_handling.py", line 12, in wrapper
callable(*args, **kwargs)
File "/Users/yacn/git/fabric/tst/util/ssh.py", line 90, in listener_thread_main
selsockets = select.select([sock], [], [], 1)
select.error: (9, 'Bad file descriptor')
```

The fix was to add another `except` statement for `select.error`