|
6 | 6 | # See https://github.com/nexB/vulnerablecode for support or download. |
7 | 7 | # See https://aboutcode.org for more information about nexB OSS projects. |
8 | 8 | # |
9 | | -import threading |
10 | 9 | import traceback |
11 | 10 |
|
12 | 11 | from django.core.management.base import BaseCommand |
@@ -42,10 +41,6 @@ def handle(self, *args, **options): |
42 | 41 | self.import_data(IMPORTERS_REGISTRY.values()) |
43 | 42 | return |
44 | 43 |
|
45 | | - if options["all_in_parallel"]: |
46 | | - self.import_data_in_parallel(IMPORTERS_REGISTRY.values()) |
47 | | - return |
48 | | - |
49 | 44 | sources = options["sources"] |
50 | 45 | if not sources: |
51 | 46 | raise CommandError('Please provide at least one importer to run or use "--all".') |
@@ -85,36 +80,6 @@ def import_data(self, importers): |
85 | 80 | if failed_importers: |
86 | 81 | raise CommandError(f"{len(failed_importers)} failed!: {','.join(failed_importers)}") |
87 | 82 |
|
88 | | - def import_data_in_parallel(self, importers): |
89 | | - failed_importers = [] |
90 | | - thread_list = [] |
91 | | - for importer in importers: |
92 | | - self.stdout.write(f"Importing data using {importer.qualified_name}") |
93 | | - try: |
94 | | - thread = threading.Thread( |
95 | | - target=ImportRunner(importer).run(), name=importer.qualified_name |
96 | | - ) |
97 | | - thread.start() |
98 | | - thread_list.append(thread) |
99 | | - except Exception: |
100 | | - failed_importers.append(importer.qualified_name) |
101 | | - traceback.print_exc() |
102 | | - self.stdout.write( |
103 | | - self.style.ERROR( |
104 | | - f"Failed to run importer {importer.qualified_name}. Continuing..." |
105 | | - ) |
106 | | - ) |
107 | | - for thread in thread_list: |
108 | | - thread.join() |
109 | | - |
110 | | - success_list = {value for value in IMPORTERS_REGISTRY if value not in failed_importers} |
111 | | - if success_list: |
112 | | - self.stdout.write( |
113 | | - self.style.SUCCESS(f"Successfully imported data using {success_list} ") |
114 | | - ) |
115 | | - if failed_importers: |
116 | | - raise CommandError(f"{len(failed_importers)} failed!: {','.join(failed_importers)}") |
117 | | - |
118 | 83 |
|
119 | 84 | def validate_importers(sources): |
120 | 85 | importers = [] |
|
0 commit comments