in Debug logs i can see
`time=“Jun 28 08:58:13” level=debug msg=“Registering coprocess middleware, hook name: ResponseHookhook type: Post, driver: python” api_id=1 api_name=MTAPI org_id=LW prefix=coprocess
Please have a look at Tutorial Add a python plugin bundle to your Gateway and try using a plugin bundle. I’m having success using that but not when placing the python code directly in the middleware directory.
I’ll continue to investigate but this will provide a work-around until I have a better answer.
Before trying bundle, let me share other findings, as they make me doubt that bundle is the way to go.
First, the error says that Python is not loaded.
And I found in the documentation - that to enable python middleware, i have to start another service, which is tyk-gateway-python instead of tyk-gateway
But when I tried this from the container, obviously, it failed because port 8080 is already busy.
So my question is:
what service or what prerequisites shall I run/install to prepare the runtime to execute python?
Because the bundle is just a way of getting the code to execute, while the problem above - runtime setup which is not documented well
Could you please specify, what container image do you use? what entrypoint? what linux service?
Did you install any additional libs before running bundle?
Thanks
I’m afraid that is out of date. Python support has been in the default binary since the release of 2.9. There is no extra service that needs to be started.
That script was included for compatibility. For systems which were configured before python was built in, an identical script is included for backwards compatibility
@Pete thank you for the help.
I tried to switch to bundle but to no avail
Based on the manual - create and uploaded sample and updated API config. Tyk downloads it to somewhere but then fails to find it on the file system
I’m not able to recreate the problem, even when using the bundle you attached
A couple of things though.
You don’t need "driver": "python", specified in the API defn when you are using a bundle. That info comes from the manifest.
Perhaps most importantly, when you change or rebuild the bundle you have to either change its name and update the API defn or remove the directory containing it from under /opt/tyk-gateway/middleware/bundles and restart the gateway.
Here are the logs from loading and running your bundle.You can see the error returned from python about 100 being an int.
I was able to reproduce your positive flow only when I updated custom_middleware_bundle by adding file extension "custom_middleware_bundle": "bundle.zip",
This change lead me to the same 100 has type int error