New submission from Timothy O'Keefe:
If you run this code, you will get a segfault. If you a) remove the row factory
from the following code or b) use the standard library map() instead of
multiprocessing.Pool.map, then the code does not crash.
#!/usr/bin/env python
import sqlite3
import multiprocessing as mp
def main():
## --- create a database
conn = sqlite3.connect(':memory:')
conn.row_factory = sqlite3.Row
c = conn.cursor()
## --- create example table similar to python docs
c.execute('''CREATE TABLE stocks (date text, trans text, symbol text, qty
real, price real)''')
c.execute("INSERT INTO stocks VALUES
('2006-01-05','BUY','GOOG',100,869.29)")
c.execute("INSERT INTO stocks VALUES
('1992-01-06','SELL','AAPL',20,512.99)")
c.execute("SELECT * FROM stocks")
## --- map fun over cursor iterable (fun does nothing)
pool = mp.Pool(processes=mp.cpu_count())
features = pool.map(fun, c)
def fun(row):
return row
if __name__ == "__main__":
main()
----------
messages: 195641
nosy: tokeefe
priority: normal
severity: normal
status: open
title: sqlite3 row factory and multiprocessing map
type: crash
versions: Python 2.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue18782>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com