I have a multithreaded Python shell server (base on the sample code
'pysvr.py') that uses a C-based extension class. The trouble I'm having
is that I cannot figure out a way to create a Python object from the C
code. I'll detail the  methods I've looked at and the troubles I'm
having:


Method 1)

Ideally, I could get PyRun_String to work, however I cannot figure out
how to properly get the locals and globals structures. In the examples
I've seen, people  are either creating brand new globals dictionaries
and/or reusing globals as locals. The problem I have is that I
potentially have multiple threads with different globals and locals
(see pysvr.py code in Python 2.4.1 distribution). I need to reference
the locals and globals for the interpreter shell for the current
thread. PyRun_SimpleString works great, but I need to get a PyObject *
back, so I need to use PyRun_String -- so another way to phrase my
problem is:

How do I get the locals and globals used in PyRun_SimpleString for use
with PyRun_String (given that I'm in a multi-threaded,
multi-interpreter environment similar to the one found using pysvr.py).


Method 2)

PyObject_New() seems like a good possibility -- except that I have no
idea where to get a PyTypeObject* from! This is for a
Python-implemented class, e.g.: Queue.

Method 3)

Dig inside the interpreter structs (PyFrameObject, PyThreadState, etc)
and dig the locals out that way. Problem is, that's not supported, so
I'd rather not do it.


There has to be a simple way to do this simple task!! 

-Doug

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to