Re: [C++-sig] how to extract an instance of arbitrary c++ class from python object?

2009-07-04 Thread Renato Araujo
Hi Alexey, you can use this example to see how create converter rules in boost:pyhton: http://www.boost.org/doc/libs/1_39_0/libs/python/doc/v2/faq.html#custom_string or you can expose you class to pyhon using boost:python in normal way. http://www.boost.org/doc/libs/1_39_0/libs/python/doc/tutori

[C++-sig] how to extract an instance of arbitrary c++ class from python object?

2009-07-04 Thread Alexey Akimov
Hi, Here is a question.(see Subject title) I am particularly interested in such implementation using python.boost library. For simple cases I've seen examples, such as: int x = extract(obj.attr("Attribute_name")) However, when a type T in extract() becomes user-specified things become harder. For

Re: [C++-sig] boost::python and threads

2009-07-04 Thread Renato Araujo
Hi Paul In my bindings I had a problem like this, to solve I created a simple class like that: class thread_locker { thread_locker() { if (thread_support::enabled()) m_gstate = PyGILState_Ensure(); } ~thread_locker() { if (thread_support::enabled()) PyGILState_Release(m_g

Re: [C++-sig] boost::python and threads

2009-07-04 Thread William Ladwig
Whoops, I think this problem is a little uglier than I thought, since you overrode the onTick() function in python with a call to print, which needs access to the interpreter in your new thread. See the link Thomas posted for dealing with the GIL (along with worrying about any possible garbage

Re: [C++-sig] boost::python and threads

2009-07-04 Thread William Ladwig
It looks to me like you have a garbage collection problem going on. If you create a wrapped c++ object in python, then python is going to own the object and will destroy it when its reference count goes to 0. In your python example script at the bottom, you call the Ticker's run() function, wh

Re: [C++-sig] boost::python and threads

2009-07-04 Thread Thomas Berg
Hi, On Fri, Jul 3, 2009 at 1:15 PM, Paul Scruby wrote: > I am having some problems using boost::python with boost::thread.  I'm using > threads because I want to run some tasks in the background when I'm using > the Python's interactive shell.  However, when I use get_override() to call > a Python

[C++-sig] boost::python and threads

2009-07-04 Thread Paul Scruby
I am having some problems using boost::python with boost::thread. I'm using threads because I want to run some tasks in the background when I'm using the Python's interactive shell. However, when I use get_override() to call a Python method from another boost::thread it crashes internally. F