Skip to content

Commit 8af0416

Browse files
authored
Merge pull request #113 from githole/fix/githole/issue-106-threaded-scanning-queue
fix: resolve #106 by avoiding shared mutable queues in ThreadedScanning
2 parents 040fbbe + a9cd10f commit 8af0416

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: src/scanoss/threadedscanning.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
"""
2424

2525
import os
26+
import queue
2627
import sys
2728
import threading
28-
import queue
2929
import time
30-
31-
from typing import Dict, List
3230
from dataclasses import dataclass
31+
from typing import Dict, List
32+
3333
from progress.bar import Bar
3434

3535
from .scanossapi import ScanossApi
@@ -49,8 +49,6 @@ class ThreadedScanning(ScanossBase):
4949
Multiple threads pull messages off this queue, process the request and put the results into an output queue
5050
"""
5151

52-
inputs: queue.Queue = queue.Queue()
53-
output: queue.Queue = queue.Queue()
5452
bar: Bar = None
5553

5654
def __init__(
@@ -65,6 +63,8 @@ def __init__(
6563
:param nb_threads: Number of thread to run (default 5)
6664
"""
6765
super().__init__(debug, trace, quiet)
66+
self.inputs = queue.Queue()
67+
self.output = queue.Queue()
6868
self.scanapi = scanapi
6969
self.nb_threads = nb_threads
7070
self._isatty = sys.stderr.isatty()
@@ -134,7 +134,7 @@ def queue_add(self, wfp: str) -> None:
134134
:param wfp: WFP to add to queue
135135
"""
136136
if wfp is None or wfp == '':
137-
self.print_stderr(f'Warning: empty WFP. Skipping from scan...')
137+
self.print_stderr('Warning: empty WFP. Skipping from scan...')
138138
else:
139139
self.inputs.put(wfp)
140140

0 commit comments

Comments
 (0)