I want to write a simple python C/S exec code model, which will send all codes written in client to execute in server. 
Simply, you can think that I'm using exec(code, globals()) to run remote code.
And I meet a problem about namespace :
If I import something in a connection, another connection can also use this module.
For example, we have two connections: A and B.
I import os in connection A, then connection B can use os module also.
Question : And what I want is that each connection have its own execute environment, say 'globals'.
Currently, I'm using a stupid and violent solution.
I create dict for each connection,  and exec code in dict accordingly.
exec code in connection_dict[connection].
Any smart solution ? Such as python CAPI ? Thanks again!
How to set local namespace for specified connection?