This is an archive of the discontinued LLVM Phabricator instance.

scan-build-py: fix multiprocessing error
ClosedPublic

Authored by lawrence_danna on Sep 2 2020, 12:16 PM.

Details

Summary

Recent versions of python3's multiprocessing module will blow up with
a Runtime error from this code, saying:

An attempt has been made to start a new process before the
current process has finished its bootstrapping phase

This is becuae the wrappers in bin/ are not using the __name__ == "__main__" idiom correctly.

Diff Detail

Event Timeline

lawrence_danna created this revision.Sep 2 2020, 12:16 PM
lawrence_danna requested review of this revision.Sep 2 2020, 12:16 PM
lawrence_danna edited the summary of this revision. (Show Details)Sep 2 2020, 12:17 PM
lawrence_danna edited the summary of this revision. (Show Details)
ldionne accepted this revision.Sep 2 2020, 3:15 PM

From the docs:

multiprocessing.freeze_support()
Add support for when a program which uses multiprocessing has been frozen to produce a Windows executable. (Has been tested with py2exe, PyInstaller and cx_Freeze.)

One needs to call this function straight after the if __name__ == '__main__' line of the main module. For example: [...]

So this looks right to me, but I'm not a Clang owner.

This revision is now accepted and ready to land.Sep 2 2020, 3:15 PM
This revision was automatically updated to reflect the committed changes.