且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用pyodbc“不安全"的Python多处理和数据库访问?

更新时间:2022-01-24 06:10:58

多处理依赖于酸洗来在进程之间通信对象.pyodbc 连接和游标对象不能被pickle.

Multiprocessing relies on pickling to communicate objects between processes. The pyodbc connection and cursor objects can not be pickled.

>>> cPickle.dumps(aCursor)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.5/copy_reg.py", line 69, in _reduce_ex
    raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle Cursor objects
>>> cPickle.dumps(dbHandle)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.5/copy_reg.py", line 69, in _reduce_ex
    raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle Connection objects

它将项目放入工作队列",什么项目?光标对象是否也有可能被传递?

"It puts items in the work_queue", what items? Is it possible the cursor object is getting passed as well?