0

I originally thought I was incorrectly passing data to my subprocesses so I asked a question How do I pass object data to other Python multiprocessing processes?. It got closed for a duplicate but after more research on the issue and implementing a Queue per the other links provided I don't think that is the problem.

Part of the data is making it to my process, a few of the other parts are not which are what I assume part of SQLAlchemy objects.

What was put into the Queue:

Data going into the Queue

What I see in my process getting out of Queue:

Processing receiving end of Queue

So I believe the issue comes down to SQLAlchemy and its states. How can I pass a SQLAlchemy resultset to a process without it losing all of this data?

The sample code.

def test_mp(queue):
    while True:
        file = queue.get(True)

results = dbsession.query(Raw_records).limit(10).all()

inqueue = mp.Queue()
for item in results:
    inqueue.put(item)
pool = mp.Pool(4, test_mp, (inqueue,))
pool.close()
pool.join()

edit: figured out the "drill_parameters_record" highlight why it isn't returning.

Had to do .options(joinedload(Raw_records.drill_parameters_record))

But the raw_xml column is still blank. It is a custom type so it is an object. I used this to create it. SQLAlchemy declaring custom UserDefinedType for XML in MSSQL

Kevin Vasko
  • 1,561
  • 3
  • 22
  • 45
  • `multiprocessing.Queue` requires objects to be picklable, and `lxml.etree._ElementTree` [does not appear to be picklable](https://stackoverflow.com/questions/8274438). – univerio Oct 06 '17 at 17:56
  • @univerio ahhh. That makes sense. I guess I'll just convert it to a string, and then convert it back to an lxml object afterwords. – Kevin Vasko Oct 06 '17 at 18:13

0 Answers0