Monday, April 16, 2012

Paramiko hangs while loading a module (continuation). Usage with Aspects Oriented Programming?

So my problem is exactly the same as the question I referenced in the title:
Why does Paramiko hang if you use it while loading a module?



I also created a similar unit test and couldn't find any solution.



I'm currently trying to create some non-regression tests for a big python script.
This script executes unix commands through SSH (paramiko) on many hosts. To achieve that, I want to use aspect oriented programming in two steps:




  1. To create scenarios:
    Capture calls and return values of external functions called by the script and serialize them in some scenario files (to create scenarios easily from real usage).


  2. When running non-regression tests:
    Replace external functions to compare calls with the scenario file, and return the value stored in the scenario (deserialized).




Just for info, I'm doing that with "aspects" module which works very well (http://www.cs.tut.fi/~ask/aspects/index.shtml)



My only problem is I wanted to control that from a kind of caller script, which would define wrapper functions, replace function calls... and call the main script. This way looks very clean to me cause I don't do any modification in the code of the script to test.



However the only way I know to call code in a python module is with import... But if I call the main scrit this way, it gets stuck as soon as Paramiko connects to the first host... All the rest seems to work fine.



So do you have any idea to call the main script without being frozen by paramiko, and without adding a lot of code inside of it?



Many thanks,
Romain





No comments:

Post a Comment