Message195641
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() |
|
Date |
User |
Action |
Args |
2013-08-19 15:33:25 | tokeefe | set | recipients:
+ tokeefe |
2013-08-19 15:33:25 | tokeefe | set | messageid: <1376926405.17.0.0447575429203.issue18782@psf.upfronthosting.co.za> |
2013-08-19 15:33:25 | tokeefe | link | issue18782 messages |
2013-08-19 15:33:24 | tokeefe | create | |
|