Strange issue with PYTHONPATH in NKEE 6.2.1

Poster Content
nk4um User
Posts: 9
July 3, 2018 17:52

Just reporting back to close this thread. Tony's fix did fix the problem (it was an update to the lang-python module); it just hadn't been pushed to Apposite. Tony pushed it to Apposite this morning and I confirmed that it did resolve my issue.

Thanks again, Tony!

Like · Post Reply
nk4um Administrator
Posts: 606
June 23, 2018 08:53

Hi Gary, that is not good. In order to solve this problem for you I suggest a two prong attack.

1) Can you send me a compact, reproducible test case so I can test against what you are seeing?

2) Please can you attempt to recreate the test case for your problem which I created and fixed at my end? Download and install these two modules:

http://temp.1060research.com/2018/6/urn.python.a.zip

http://temp.1060research.com/2018/6/urn.python.b.zip

These correspond to your modules A and B. Then use the request trace tool to issue requests into each space in turn similar to the scenario you described: and

You should see that both requests execute correctly without exception. Before this fix you would see errors where imported modules where not found. These test modules try to recreate the scenario as you described in your initial report so please take a look at their internal and see if you can see how this deviates from your description.

Thanks, Tony

Like · Post Reply
nk4um User
Posts: 9
June 23, 2018 00:50

Hi Tony,

Thanks for looking at this. I installed all the latest Apposite updates and, unfortunately, I'm still experiencing the same issue.

Thanks, --Gary

Like · Post Reply
nk4um Administrator
Posts: 606
June 19, 2018 22:16

Hi, a fix is now available in apposite. Let me know how you get on.

Like · Post Reply
nk4um Administrator
Posts: 606
June 17, 2018 14:08

Hi Gary, i found in bug in our python wrapper endpoint. It seems that in certain cases modules are loaded at runtime again by Jython. In that case the last request context used by compiler would get used. So in your exact scenario module A was trying load it's python packages using module Bs request context - and hence not finding them.

I'll get the update out to you in Apposite ASAP. Thanks for your patience, it's a long time since I looked at python.

Like · Post Reply
nk4um Administrator
Posts: 606
June 14, 2018 15:28

Hi Gary, thanks for reporting this. I'll take a look.

Like · Post Reply
nk4um User
Posts: 9
June 14, 2018 14:37Strange issue with PYTHONPATH in NKEE 6.2.1

Hi all,

I'm experiencing a real head-scratcher involving the resolution of Python library modules once they've been cached.

I have a couple of modules in my NKEE 6.2.1 deployment that are using Python. Both of them have an etc/PYTHONPATH resource. The first module (let's call it "module-A") includes some additional Python packages in a directory named "python-modules". The PYTHONPATH resource for module-A looks like this:

res:/library/python/2.7.0/
res:/python-modules/

The second module (which we'll call module-B) does not use any additional Python packages, and it's PYTHONPATH file looks like this:

res:/library/python/2.7.0/

When I SOURCE my endpoint on module-A *for the first time*, NK finds all of the necessary Python imports via PYTHONPATH (standard Python packages, plus the ones I have under /python-modules, and completes successfully. I then, subsequently, SOURCE my endpoint on module-B (note: module-A and module-B do not import each other), and module-B completes successfully as well.

Here's where it gets weird. If I now SOURCE module-A's endpoint a second time, packages under res:/python-modules are no longer found, and my Python scripts in the module throw runtime ImportError exceptions, like this:

<ex>
    <id>SubrequestException</id>
    <space>Lang / Python (private)</space>
    <endpoint>PythonRuntime</endpoint>
    <logicalEndpoint>PythonRuntime</logicalEndpoint>
    <ex>
        <id>Python Runtime Exception</id>
        <message>
Traceback (most recent call last): File "res:/scripts/bi-second-pw.py", line 3, in <module> ImportError: No module named rsa
</message>
    </ex>
</ex>

When this occurs, I can go into the cache viewer and find the representations for the Python packages that cause the ImportError. And if I clear the cache, module-A works again (until module-B runs).

For the life of me, I cannot figure out what sort of weird interplay is going on here...any help or pointers as to where to start looking would be most appreciated.

Thanks,

--Gary

Like · Post Reply