Skip to content
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

stop tqdm module from creating daemon threads when instantiated with disable = False #410

Closed
mike-hunhoff opened this issue Feb 1, 2021 · 2 comments
Assignees

Comments

@mike-hunhoff
Copy link
Collaborator

The following code snippets create daemon threads, which results in unnecessary, long running threads when calling this code from the IDA Pro plugin:

https://github.com/fireeye/capa/blob/bb7001f5f2ec02a28ed706435aea1d7e71291e8f/capa/main.py#L369

and

https://github.com/fireeye/capa/blob/bb7001f5f2ec02a28ed706435aea1d7e71291e8f/capa/main.py#L118

tqdm when instantiated creates a new daemon thread and unfortunately setting disable to False does not prevent this thread from being created, as one would expect.

For now we can manually set monitor_interval to 0 for the instantiated tqdm object when the intention is to disable tqdm progress altogether e.g.

https://github.com/fireeye/capa/blob/bb7001f5f2ec02a28ed706435aea1d7e71291e8f/capa/ida/plugin/form.py#L531-L533

@williballenthin
Copy link
Collaborator

williballenthin commented Feb 1, 2021

yikes, that's annoying!

what if we assign tqdm.tqdm to a local variable pbar, and if the progress bar is disabled, overwrite pbar with a fake constructor, like:

pbar = tqdm.tqdm
if disable_progress:
    pbar = lambda s, *args, **kwargs: s

for f in pbar(list(extractor.get_functions()), desc="matching", unit=" functions"):
    ...

@mike-hunhoff
Copy link
Collaborator Author

that works for me!

@mike-hunhoff mike-hunhoff self-assigned this Feb 1, 2021
mike-hunhoff added a commit that referenced this issue Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants