Created
June 26, 2018 09:25
-
-
Save mattbennett/9dd456f31e1161348e936b9c3a6918b9 to your computer and use it in GitHub Desktop.
Attach PDB to Nameko worker exceptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@pytest.yield_fixture | |
def pdb_worker_exceptions(): | |
import pdb | |
from mock import patch | |
from nameko.containers import ServiceContainer | |
unpatched = ServiceContainer._worker_result | |
def attach_pdb(self, worker_ctx, result, exc_info): | |
if exc_info: | |
pdb.post_mortem(exc_info[2]) | |
return unpatched(self, worker_ctx, result, exc_info) | |
with patch.object(ServiceContainer, '_worker_result', new=attach_pdb): | |
yield |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You must run pytest with output capturing enabled (
-s
) in order to use this