Re: Threading and GIL
Hi, thats the reason why its not working. Imagine the end() method of the thread object is called so the C++ Function is opened where the code for this method is in. At a line the Code ...-End() is called which waits that the C++ Thread class is finished. BUT here is the problem: In the Method of the C++ class which is in threaded mode can't run because its still waiting that the GIL is released by the thread which executed the -End() command. So the app has a deadlock when it arrives at -End() and PyGILState_Ensure function. -- http://mail.python.org/mailman/listinfo/python-list
Re: Threading and GIL
hey, thanks, that works fine. I wrapped it around, done a lot of tests and it works fine. Just had done a few other things to make it stable. cheers. -- http://mail.python.org/mailman/listinfo/python-list
Threading and GIL
Hi! I have a big problem I can't solve and I hope anyone of you can help me. I use the Python C API and in C++ I have a class which represets a thread object, similiar to the thread class of the known Python Thread class but with some needed additions so thats the reason why I have to built my own. Well, this is the problem. There is a method called Thread::End() which I can call in Python. But now the End() Function waits until the Main Function of my C++ class is done, but in this method I want to ensure the Global Interpreter Lock but this is already locked by the Thread which executes the End() command. So both is waiting and stops. The thread which calls the End () method is waiting for the finish of the Main() method of the Thread Class and the Main-Method in the other thread waits for the thread of the End() command that this is done - welcome Deadlock. Any suggestions what I have to do? Thank you veeery much for you help, otherwise I become really crazy here because this is the first time I have such a problem. Bye :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Interrupt Python C API
On 16 Apr., 11:08, Piet van Oostrum p...@cs.uu.nl wrote: googler.1.webmas...@spamgourmet.com (g1w) wrote: g1w hi, yes, thats true, Alan Touring told us, so it would be nice to let g1w the user abort it. g1w Is there a chance for windows, too? I don't know. I have no access to Python on Windows. Maybe there is setitimer support on Windows. Or maybe you can use the threading.Timer object, like this: import signal, os import threading signalcode = signal.SIGALRM # on Windows, choose one that exists there. class AlarmError(Exception): pass def interrupt(): os.kill(os.getpid(), signalcode) def execute(command, timeout): threading.Timer(timeout, interrupt).start() try: exec(command) except AlarmError, e: print e print 'Aborted %s' % (command,) print continue work print The everlasting command execute(while 1: pass, 10) print The End -- Piet van Oostrum p...@cs.uu.nl URL:http://pietvanoostrum.com[PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org thx, i will check... :) merci -- http://mail.python.org/mailman/listinfo/python-list
Re: Interrupt Python C API
hi, yes, thats true, Alan Touring told us, so it would be nice to let the user abort it. Is there a chance for windows, too? -- http://mail.python.org/mailman/listinfo/python-list
Interrupt Python C API
Hi, I just have a design problem and don't know how to solve it. I call a function which executes a simple PyRun_String(...) command. imagine the script while 1: pass is executed so the app would hang. Is there any chance to break out this PyRun_String-function? I just searched the forums for that stuff but these information are very rare. Thanks for any suggestions. Bye. -- http://mail.python.org/mailman/listinfo/python-list
PyEval_EvalCode(...) problem
Hi! I have a problem with PyEval_EvalCode(...) I compile the following code and execute them with PyEval_EvalCode (...) class MyClass(mod.Upper): pass register(MyClass) #just the type, not the instance Thats all. So register(...) is a Python C API method so i take the type and store it in a global variable. PyEval_EvalCode(...) returns not NULL and I do not decref the dictionary, just the returnvalue. After PyEval_EvalCode(..) is executed I would like to create an instance of MyClass which crashes because information of the inherited types are corrupt. If I call PyObject_CallObject(obj, NULL) in register(..) where PyEval_EvalCode (..) is still active everything works fine but when I call it after PyEval_EvalCode, even I did not decref anything) its not working. Can anyone of you help me? The refcounts of the MyClass type are 0. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: PyEval_EvalCode(...) problem
http://rafb.net/p/Uyb5Ps45.html Pelase note, when I call PyObject_CallObject(...) in the wrapped C register(..) method it works fine. -- http://mail.python.org/mailman/listinfo/python-list
Re: ImportError in embedded Python Interpreter
Hi! Thanks. Well, os.py is found and all the others which don't need a library. I tested this: I execute Py_Main(...) in my app which executes the console interpreter and i tried to execute import socket which works. So Py_Main has something what my created PyRun_SimpleString doesn't have. Maybe the environment variables? Something has to be called in Py_Main which I should call, too. bye.. -- http://mail.python.org/mailman/listinfo/python-list
Re: ImportError in embedded Python Interpreter
Hi! Okay, thats just the question. I did that what you wrote but it doesn't really works. What is, if Py_SetProgramName() gets a NULL Pointer, if argv[0] is empty? Well, the problem is, in my opinion that os.environ returns some paths in python.exe and in my embedded interpreter if I call os.environ in Py_Main(...) When I call it in my PyRun_SimpleString(...) it returns nothing. Hm.. thats really strange. -- http://mail.python.org/mailman/listinfo/python-list
ImportError in embedded Python Interpreter
Hi, i have a problem. I compiled Python and the socket module so I got this structure. (all on windows) C:\test\dll_files\python25.dll C:\test\my_app C:\test\dll_files\DLLs\ C:\test\dll_files\python.exe If I run python I get the console and I can call import socket which succeeds. I wrote a small console app which is stored in C:\test\ and embeddeds the python interpreter. I set the environment variable PATH so the python DLL files can be load. But when I want to import in a script the socket module, it fails. (The interpreter works fine, just importing files in the DLLs folder fail). Why? When I print out the sys.path I get the same like in the real python.exe. What do you think, whats missing? Thanks a lot. bye :) -- http://mail.python.org/mailman/listinfo/python-list
ImportError in embedded Python Interpreter
Hi, i have a problem. I compiled Python and the socket module so I got this structure. (all on windows) C:\test\dll_files\python25.dll C:\test\my_app C:\test\dll_files\DLLs\ C:\test\dll_files\python.exe If I run python.exe I get the console and I can call import socket which succeeds. I wrote a small console app which is stored in C:\test\ and embeddeds the python interpreter. I set the environment variable PATH so the python25.dll can be load. But when I want to import the socket module in a script, it fails. (The interpreter works fine, just importing files in the DLLs folder fail). Why? When I print out the sys.path in my app I get the same like in the real python.exe. What do you think, whats missing? Thanks a lot. bye :) -- http://mail.python.org/mailman/listinfo/python-list
Re: ImportError in embedded Python Interpreter
Hi! Okay, I checkede Py_Main(...) and called some python code there. There it works too. So I know whats missing. sys.environ.. returns nothing. How can I set the paths with the Python C API? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python C API (PyObject_CallMethod clear object)
On 26 Jan., 03:25, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Sun, 25 Jan 2009 23:46:01 -0200, googler.1.webmas...@spamgourmet.com escribió: I have a problm with deallocating stuff. I call a function with this command: PyObject *rvalue = PyObject_CallMethod(obj, execute,,NULL); if(rvalue==NULL) PyErr_Print(); else Py_DECREF(rvalue); Can it be, that something is missing here? Imagine I allocate an object of a type: t = MyImage() ,;- syntax_error 129=)/% #is a syntax error How you see I would get a syntaxerror, but an object of the type MyImage() is created. But its deallocated when Py_Finalize() is called. What can I do to deallocate this object after PyObject_CallMethod returns NULL, too? I debug it, so if rvalue!=NULL the object is deallocated, but what can I do if rvalue==NULL= A syntax error is detected *before* the code runs -- so the object isn't created at all. -- Gabriel Genellina Hi! Yes, you are right. I got this issue not in syntax error, I get it on a runtime error like this: t = MyImage() self.test(hallo) #test takes an integer so this would throw an exception. Here you see, an object of the type MyImage() was created but its not deleted. 't' is a local reference so how can I do that? Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python C API (PyObject_CallMethod clear object)
the hook is, how to delete the locals of this function, maybe thats a workaround? thanks and bye. -- http://mail.python.org/mailman/listinfo/python-list
Python C API (PyObject_CallMethod clear object)
Hi! I have a problm with deallocating stuff. I call a function with this command: PyObject *rvalue = PyObject_CallMethod(obj, execute,,NULL); if(rvalue==NULL) PyErr_Print(); else Py_DECREF(rvalue); Can it be, that something is missing here? Imagine I allocate an object of a type: t = MyImage() ,;- syntax_error 129=)/% #is a syntax error How you see I would get a syntaxerror, but an object of the type MyImage() is created. But its deallocated when Py_Finalize() is called. What can I do to deallocate this object after PyObject_CallMethod returns NULL, too? I debug it, so if rvalue!=NULL the object is deallocated, but what can I do if rvalue==NULL= Thanks a lot -- http://mail.python.org/mailman/listinfo/python-list
MaxInt on Vista-64bit?
Hi! I downloaded Python64 for Windows Vista64 but the value returned from sys.maxint is just a 32bit integer. I found out, thats by design, Microsoft decided to make the long value 32bit. What can I do to compile python 2.6 with maxint of 64bit integers? Can I replace the int values to a int64 value? Thanks a lot! -- http://mail.python.org/mailman/listinfo/python-list
Re: MaxInt on Vista-64bit?
Hi! Thanks for the fast answer. Yes, its enough but I never thought that Vista64 is not a real 64-bit operating system :-o. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6.1 @executable_path
Hi! Woow, thanks. The unix command install_name_tool solved my problem. Thanks a lot. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6.1 @executable_path
Hi! :) Thank you. I found PySys_SetPythonHome() to set the path where the lib folder of Python is, but I guess they are not really implemented because they are fixed compiled for an absolute path, aren't they? Thats the whole problem. Do you have a suggestoin for the command line how I can build it? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6.1 @executable_path
Thank you, I found PySys_SetPythonHome() to set the path where the lib folder of Python is, but I guess they are not really implemented because they are fixed compiled with an absolute path, aren't they? Thats the problem. I hadn't compiled Python and I don't know if I should compile it as a dylib file or a framework? hmm. I know how to create a framework but compiling as a dylib hadn't worked yet. :-( Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6.1 @executable_path
yeap, okay, its just the beginning so I didn't know that the framework is still the dylib file. Well, I only want to compile python and put the framework in the subdirectory. Thats all. And the current state is, that the framework is not found because the path of the compiled Python library is hardcoded so when I move it from /Library/Frameworks/ to my app folder it isn't found when I start my app. I found a ressource that I have to compile it with a dynamic path flag like LDFLAGS=-install_name,@executable_path/../Frameworks to put it in the Framework of my app. maybe you know where my problem is. hm. bye -- http://mail.python.org/mailman/listinfo/python-list
Python 2.6.1 @executable_path
Hi! I asked something similar a few days ago. Is it possible to compile Python 2.6.1 with a dynamic path? I don't know how the configure command would look like. This is my current configure command for the default /Library/ Frameworks/ path: ./configure --with-framework-name=Python --with-universal-archs=all -- enable-framework --enable-universalsdk=/ Can anyone help me? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Python 2.6.1 @executable_path
Hi! I asked something similar a few days ago. Is it possible to compile Python 2.6.1 with a dynamic path on MacOSX? I don't know how the configure command would look like. This is my current configure command for the default /Library/ Frameworks/ path: ./configure --with-framework-name=Python --with-universal-archs=all -- enable-framework --enable-universalsdk=/ Can anyone help me? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Python 2.6.1 @executable_path
Hi! I asked something similar a few days ago. Is it possible to compile Python 2.6.1 with a dynamic path on Mac OSX Leopard 10.5.x. I found out that I could use @executable_path but I don't know how the configure command would look like. This is my current configure command for the default /Library/ Frameworks/ path: ./configure --with-framework-name=Python --with-universal-archs=all -- enable-framework --enable-universalsdk=/ Can anyone help me? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6.1 @executable_path
I want to embedd it into another app so on the 'customers'-mac I want to put python into a subdirectory of my app. bye -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6.1 @executable_path
I want to embedd it into my app so on the 'customers'-mac I want to put python into a subdirectory of my app. and with the configure command above, that will not work because the library has to be on every system in /Library/Framework/ so I found out that @executable_path is replaced by the path of the app. bye -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6.1 @executable_path
Thanks for the link but I don't want to do a make a python script as an applicatin, I want to embedd python into a C++ app so thats the reason why I have to compile Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6.1 @executable_path
hmm.. very strange. Is it so complicated to compile python that I can move the framework to the app folder? hmm. thats really strange :-( /myapp.app /subfolder/Python.framework any suggestions? Thank you very muc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6 fails on compiling Bug report
hm... any ideas? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6 fails on compiling Bug report
Hi! I didn't wanted to post 11.000 Lines here, so I uploaded it here: http://rapidshare.com/files/181425216/config.log.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6 fails on compiling Bug report
hi, thanks for your help. May the diff file is wrong? on my system it doesn't work. Well, set the -enable-universalsdk= path occurs that error. Hmm. that is really a disaster, isn't it :( hm. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6 fails on compiling Bug report
Hi! :) Sorry, there were a few line wrap-arounds in the diff file due to long lines but the changes for the four significant lines should be easy to do manually. Hadn't done that before but I found a ressource how to read that syntax. x86_64 would be enough. i test that again. Thank you. :) -- http://mail.python.org/mailman/listinfo/python-list
Python 2.6 fails on compiling Bug report
Hi! I compiled Python 2.6.1 on a Mac OSX 10.5.5 Intel machine with this configure command and got this message FAILS: ./configure --with-framework-name=Python --with- universal-archs=all --enable-framework --enable- universals...@executable_path/my/path/to/app WORKS: ./configure --with-framework-name=Python --with- universal-archs=all --enable-framework --enable-universalsdk=/ [...] configure: WARNING: dlfcn.h: present but cannot be compiled configure: WARNING: dlfcn.h: check for missing prerequisite headers? configure: WARNING: dlfcn.h: see the Autoconf documentation configure: WARNING: dlfcn.h: section Present But Cannot Be Compiled configure: WARNING: dlfcn.h: proceeding with the preprocessor's result configure: WARNING: dlfcn.h: in the future, the compiler will take precedence configure: WARNING: ## ## configure: WARNING: ## Report this to http://www.python.org/python-bugs ## configure: WARNING: ## ## checking for dlfcn.h... yes [...] many of this error warnings occure. /* its already noted in the bug reporter but there is no solution. Does anyone know how to use my custom path? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6 fails on compiling Bug report
Hi searched for Library/Frameworks/ in the config file and edited it to @executable_path. Well my configure and make command worked very fine. Just 'make install' aborted after this error message. test -d /Applications/Python 2.6 || mkdir -p /Applications/Python 2.6 test -d /Applications/Python 2.6/IDLE.app rm -r /Applications/ Python 2.6/IDLE.app cp -PR IDLE.app /Applications/Python 2.6 touch /Applications/Python 2.6/IDLE.app cp ./config-main.def @executable_path/Python.framework/Versions/2.6/ lib/python2.6/idlelib/config-main.def cp: @executable_path/Python.framework/Versions/2.6/lib/python2.6/ idlelib/config-main.def: No such file or directory make[2]: *** [install] Error 1 make[1]: *** [install_IDLE] Error 2 make: *** [frameworkinstallapps4way] Error 2 That is not cool.. really.. thats not cool. Thanks for your tipps. -- http://mail.python.org/mailman/listinfo/python-list
Compile as static library
Hi! I have a big problem with compiling Python on MacOSX. I compile it - everything works ./configure make so I get a libpython2.5.a file which I include into a Xcode Project. I want to static link it with my project (works in Debug mode but not in Release) 1. Is there a static library flag which I have to set, or something like that? 2. Why does it work in Debug mode, not in Release? The import settings for a library doesn't differe between debug and release, does it? Thanks a lot. -- http://mail.python.org/mailman/listinfo/python-list
Python with PyGIL_Ensure?
Hi! I have a small problem with my python embedded interpreter. I do some stuff where two threads exists which do some pythons stuff in the same stuff. So bpoth call PyGILState_Ensure() which occurs a crash. What can I do, that one thread waits until the other thread released the gil state? Thanks a lot. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python with PyGIL_Ensure?
and merry christmas :) -- http://mail.python.org/mailman/listinfo/python-list
Python C API
Hi :) I have a main() function of my app which intializes the Python Interpreter and some other stuff. When I am finished I call: PyGILState state = PyGILState_Ensure() //call PyRun_String() PyGILStateRelease(state); The first question is, I found out the API contains other commands lik PyEval_AcquireLock(). I don't really understand if I have to use them too, could anyone explain? Thanks. Okay, back to topic. In PyRun_String() I call a wrapped function. This wrapped function does some internal calculations and takes a pointer to another function which is called in another thread while it calculates the stuff. void MyProgressbar(Real p, void* hook) // this function wil be called in another thread { PyGILState_STATE gilstate = PyGILState_Ensure(); PyObject* func = (PyObject*)hook; //do some python stuff PyGILState_Release(gilstate) } PyObject *pyMyFunction(PyObject *pSelf, PyObject *args, PyObject *keywords) { static char *kwlist[] = {hook, NULL}; PyObject *hook=NULL; if (!PyArg_ParseTupleAndKeywords(args, keywords, O!, kwlist, PyFunction_Type, hook)) return NULL; LONG ok = MyFunction(myprogress, hook); //hook is a pointer which is passed to the threaded function. Py_RETURN_INT(ok); } I want to do the same in Python. I want to pass a reference of a function to the function which is called from the other thread. But it stops (not crash) here: PyGILState_STATE gilstate = PyGILState_Ensure (); What can I do? Thank you very much. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python C API
Hi! thats a very interesting point and good to know. I have to release the GIL but how do I do? In this case i need PyEval_AcquireLock and PyEval_ReleaseLock? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python C API
Hi! Any ideas? Thanks, :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Embedding Thread
Hi! Thank you very much for your answers. I have a menue with a script in it. So my app starts a new thread for each script. So I would like to run two scripts all the same time. Could someone give me a tip, what I have to set in my code? Thank you :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Embedding Thread
Hi! I fixed the code. This code snippet runs in a seperate thread: PyObject *dict=NULL; PyGILState_STATE state = PyGILState_Ensure(); dict = CreateMyGlobalDictionary(); PyRun_String(my code, Py_file_input, dict, dict); ReleaseGlobalDictionary(dict); But it still does not work... :-/ -- http://mail.python.org/mailman/listinfo/python-list