I'm working on a project that's going to be handling thousands of accounts at a time with a limit of x workers at a time. I have a Handler class that's going to be the core of the program.
When the Handler class initiates it creates a new IMAP process that monitors an email inbox for incoming mail. It also checks to see how many accounts are currently created that are stored locally, if accounts created are < x, it starts x workers running an account creator and stores the created accounts locally.
When the IMAP process receives a new email it checks the contents of email for specific processing. It should alert the Handler process what to do with the received email.
I'm still new to threading, and especially multiprocessing, and used a queue from the parent thread to send commands to the child thread. However, in this use-case I need the child IMAP process to be able to communicate to the Handler class to tell it when a new email arrives and what to do when it's received.
How can I initiate x workers with multiprocessing while being able to communicate child->parent and child->child?
example of my IMAP class, using the same format for my other classes
class IMAP(object):
def __init__(self):
self._config = configparser.ConfigParser().read('config.ini')['imap']
self._mail = imaplib.IMAP4_SSL(self._config['host'])
self._mail.login(self._config['username'], self._config['password'])
self._mail.list()
def run(self):
while True:
# login to email and monitor
EDIT
I apologize for confusion, I'm bad at describing my thoughts. I'm using multi-processing, not threading. Here's a rough diagram
(x for account processing creation is x workers)