ply and threads

D

dean

I have two threads that exchange information by passing messages. I wanted
to parse those messages with ply. I'd prefer using two independent parsers
so that I can avoid using locks.

Can somebody explain how to do this with ply? Ply seems to be doing a lot
of odd things, such as reading the the python file that imported it,
reading doc strings of it's functions, etc, so I'm not sure how to make
this thread safe. This is from yacc.py:

# The current implementation is only somewhat object-oriented. The
# LR parser itself is defined in terms of an object (which allows multiple
# parsers to co-exist). However, most of the variables used during table
# construction are defined in terms of global variables. Users shouldn't
# notice unless they are trying to define multiple parsers at the same
# time using threads (in which case they should have their head examined).

It would seem that creating two parsers in the main thread, and then
passing one of them to the other thread, is all I need to do to be thread
safe?

But then again I'm not even sure how to create two parsers. Examples I've
seen just call yacc.yacc() at the end, and do not even access yacc
instances.

Any help is appreciated and thanks in advance.

Dean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top