c - Using Python object exported from DLL in an exe -
I have a two-part event generator:
pyglobalexe (to simulate events A stub for) : pyglobalextension Both files crash right on the Pyglobalexe.exe === EDIT === Sorry, the usage case should have been more clear. Command Prompt 1 (running Python .exe) Command Prompt 2 (once I am done in Command Prompt 1). I expected that I would be able to go back to Command Prompt 1 and q.get (10) numbers. Advertising Edit: Still standing. What you are working for is the need of interprosession communication, the simple global variable will not do what you want to do (both have their own copy of the processes) only the code of DLL can be shared, the data not Is รข ???? And in pyglobalexe, this is the tap).
#pragma comment (lib, "pyglobalextension.lib") #include & lt; Python.h & gt; __declspec (dllimport) PyObject * PyInit_pyglobalextension; __declspec (dllimport) PyObject * event_queue; Int main () {int i; {PyObject_CallMethod (event_queue, "put", "O", PyLong_FromLong (i * 2)) for (i = 0; i & lt; 10; i ++); } Return 0; }
#include & lt; Python.h & gt; __declspec (dllexport) PyObject * event_queue = NULL; Fixed PyObject * set_queue (PyObject * self, PyObject * args) {PyObject * temp; If (PyArg_ParseTuple (args, "o", and temporary)) {return tap; } Py_XINCREF (temporary); Py_XDECREF (event_queue); Event_queue = temp; Py_INCREF (Py_None); Back Py_None; } Stable PyMethodDef PyGlobalExtensionMethods [] = {{"set_queue", set_queue, METH_VARARGS, "set a queue global"}, {NULL, NULL, 0, NULL}}; Static Structure POMDDIE Piglobal Extension Module = {PAMDDDFHAADIDITT, "PEGOBLLASTNATION", Faucet, -1, PAGLOBE ExtensionMath}; PyMODINIT_FUNC PyInit_pyglobalextension (zero) {back to PyModule_Create (and PyGlobalExtensionModule); }
PyObject_CallMethod call compilation, so what do I change so that I can use event_queue global from pyglobalextension in pyglobalexe?
& gt; & Gt; & Gt; Import pigoloblastation & gt; & Gt; & Gt; Qatar import queue & gt; & Gt; & Gt; Q = row ()> gt; & Gt; & Gt; Pyglobalextension.set_queue (q)
$ & gt; Pygalobalexe
event_queue is zero, because nothing
Before going to set_queue , click
callMethod .
PyInit_... is a function, not a variable; And you do not call it, so the module and
set_queue are also not present.
Comments
Post a Comment