I cannot save doc in new process

In rquest , I create new process to save document,but I got an error:

File “/home/ubuntu/frappe-bench/apps/frappe/frappe/init.py”, line 480, in set_value
return frappe.client.set_value(doctype, docname, fieldname, value)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/client.py”, line 60, in set_value
doc = frappe.get_doc(doctype, name)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/init.py”, line 499, in get_doc
return frappe.model.document.get_doc(arg1, arg2)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 45, in get_doc
return controller(arg1, arg2)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 76, in init
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py”, line 104, in load_from_db
d = frappe.db.get_value(self.doctype, self.name, “*”, as_dict=1)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/database.py”, line 396, in get_value
ret = self.get_values(doctype, filters, fieldname, ignore, as_dict, debug, cache=cache)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/database.py”, line 437, in get_values
out = self._get_values_from_table(fields, filters, doctype, as_dict, debug, order_by, update)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/database.py”, line 537, in _get_values_from_table
conditions, order_by), values, as_dict=as_dict, debug=debug, update=update)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/database.py”, line 135, in sql
self._cursor.execute(query, values)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (2013, ‘Lost connection to MySQL server during query’)

This is strange. How did you configure your server? How did you install erpnext?

I do that in a pool,

from multiprocessing import Pool

pool = Pool(processes=1)
result = pool.apply_async(worker, (self,), callback=callback)

before db query, I add this code:

that works,but are there other ways to do?


Is your code open source ? If yes please share the link so that I can look at it and see if you are doing it right.