Commit 192980ea authored by Joren Vrancken's avatar Joren Vrancken

Merge branch 'completely-remove-threading' into 'master'

Remove threading completely from sync_mailinglists

See merge request !1401
parents 75ab2e87 4650c8a2
"""GSuite syncing helpers defined by the mailinglists package""" """GSuite syncing helpers defined by the mailinglists package"""
import logging import logging
from concurrent.futures import wait
from concurrent.futures.thread import ThreadPoolExecutor
from time import sleep from time import sleep
from typing import List from typing import List
...@@ -310,16 +308,11 @@ class GSuiteSyncService: ...@@ -310,16 +308,11 @@ class GSuiteSyncService:
remove_list = [x for x in existing_groups if x not in new_groups] remove_list = [x for x in existing_groups if x not in new_groups]
insert_list = [x for x in new_groups if x not in existing_groups] insert_list = [x for x in new_groups if x not in existing_groups]
executor = ThreadPoolExecutor(max_workers=4)
futures = []
for l in lists: for l in lists:
if l.name in insert_list and l.name not in archived_groups: if l.name in insert_list and l.name not in archived_groups:
futures.append(executor.submit(self.create_group, l)) self.create_group(l)
elif len(l.addresses) > 0: elif len(l.addresses) > 0:
futures.append(executor.submit(self.update_group, l.name, l)) self.update_group(l.name, l)
for l in remove_list: for l in remove_list:
futures.append(executor.submit(self.delete_group, l)) self.delete_group(l)
wait(futures)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment