Skip to content

fix: resolve #106 by avoiding shared mutable queues in ThreadedScanning #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/scanoss/threadedscanning.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
"""

import os
import queue
import sys
import threading
import queue
import time

from typing import Dict, List
from dataclasses import dataclass
from typing import Dict, List

from progress.bar import Bar

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

inputs: queue.Queue = queue.Queue()
output: queue.Queue = queue.Queue()
bar: Bar = None

def __init__(
Expand All @@ -65,6 +63,8 @@ def __init__(
:param nb_threads: Number of thread to run (default 5)
"""
super().__init__(debug, trace, quiet)
self.inputs = queue.Queue()
self.output = queue.Queue()
self.scanapi = scanapi
self.nb_threads = nb_threads
self._isatty = sys.stderr.isatty()
Expand Down Expand Up @@ -134,7 +134,7 @@ def queue_add(self, wfp: str) -> None:
:param wfp: WFP to add to queue
"""
if wfp is None or wfp == '':
self.print_stderr(f'Warning: empty WFP. Skipping from scan...')
self.print_stderr('Warning: empty WFP. Skipping from scan...')
else:
self.inputs.put(wfp)

Expand Down