Mar-06-2022, 02:09 PM
Hi
I run my own project with gunicorn (multi worker) and I wanted to share objects between processes. I used BaseManager from the multiprocessing python package. my project is Django and this is part of code:
I run my own project with gunicorn (multi worker) and I wanted to share objects between processes. I used BaseManager from the multiprocessing python package. my project is Django and this is part of code:
def get_bloom_filter_shared_state(): manager = BaseManager( ('127.0.0.1', '8004'), b'blabla' ) m_bloom_filter = BloomFilter() a_bloom_filter = BloomFilter() # n_share_state: memory sharing already exists or new. n_share_state = False # register in manager manager.register('m_bloom_filter', lambda: m_bloom_filter) manager.register('a_bloom_filter', lambda: a_bloom_filter) try: manager.get_server() manager.start() n_share_state = True except OSError: # Address already in use manager.connect() return manager.m_bloom_filter(), manager.a_bloom_filter(), n_share_stateIs the performance of the network low in many requests? What is the performance of this host (127.0.0.1)?