You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.
running this results in:
cannot use w (type http.ResponseWriter) as type *python3.PyObject in argument to python3.PyTuple_SetItem
Describe what you expected:
I did not expect this to work, but would be interested in getting this to work so that http.ResponseWriter.Write could be called within the Python code. Is this possible?
Steps to reproduce the issue:
The text was updated successfully, but these errors were encountered:
It's possible but this will require some/a lot of wrapping. You need to extend python using CPython and there call any Go function exposed to C. You can't just pass a Go pointer and use it in Python.
In the datadog-agent we don't use this repo (because we want to embed both Python2 and Python3 at the same time, so we need to open shared library dynamically). But you can look into it to get some idea on how to do this.
As you can see embedding python is easy in Go, extending it requires some works.
In you example, I think, the simplest solution would be to create a Python Callable class, that internally store a C pointer and call a C method with that pointer when being called. Then in C you will actually call the Go function.
Describe what happened:
python3.PyTuple_SetItem(tuple, 0, w)
testfunc := pyMod.GetAttrString("serve")
pyret := testfunc.Call(tuple, ret)
running this results in:
cannot use w (type http.ResponseWriter) as type *python3.PyObject in argument to python3.PyTuple_SetItem
Describe what you expected:
I did not expect this to work, but would be interested in getting this to work so that http.ResponseWriter.Write could be called within the Python code. Is this possible?
Steps to reproduce the issue:
The text was updated successfully, but these errors were encountered: