python - Django doesn't insert rows into table with multiprocessing -


I have some scripts that use the multiprocessing module, and Django ORM. The scenario is quite simple:

  1. Get the data,
  2. To make n processes in each process and form a part of the data,
  3. Do something,
  4. Save in Djibu OR with DB. OK, in step 4, I have a problem that not all the data left in Django don DB, the data generating function is correct and correct, but I do not know that Django Where the problem is with, before the processes become established, the old connection stops, so that each process has its own connection.

    Is there a problem with Django and multiprocessing, or the maximum number of connections (I use maximum 4 processes)? Example code:
    Connection.close () # where I say the function "fun", and sending data p = the process (target = funny, Argus = (i, data,)

      diff fun (i, data): result_1 = some_other_fun (data) # this list is results_2 = some_exam (statistics) # this model models.py save_data ( Result_1, result_2) is defined in def save_data (res1, res2): If I call save_data from the process in res1: res1 for the line, then the Save () method does not save the row in the table. Idi is called without the process (general call only the script), everything is fine. 


Comments