Answer the question
In order to leave comments, you need to log in
How to work with psycopg2 and multiprocessing?
Application structure:
main.py
import multiprocessing
from postgresql import POSTGRESQL
class Core:
def __init__(self):
self.postgres = POSTGRESQL()
def complete_level_3(self, sub_task_id):
some_information = self.postgres.some_insert_func(sub_task_id)
some_information_two = self.postgres.some_update_func(some_information)
def run_level_two(self, task_id):
sub_task_id_list = self.postgres.get_subtasks_id(task_id)
for sub_task_id in sub_task_id_list:
process = multiprocessing.Process(target=self.complete_level_3, args=(sub_task_id,))
process.start()
def run_level_one(self, task_id_list):
for task_id in task_id_list:
process = multiprocessing.Process(target=self.run_level_two, args=(task_id,))
process.start()
sql1 = "SELECT text, score FROM text_table WHERE id = %s" % (row_id,)
sql2 = "SELECT id FROM language WHERE type = %s" % (type_str,)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question