multiprocessing-logging icon indicating copy to clipboard operation
multiprocessing-logging copied to clipboard

Not working in macOSX

Open rudaoshi opened this issue 4 years ago • 4 comments
trafficstars

cannot pass the test on macOSX 11.2.2

reporting: AttributeError: Can't pickle local object 'WhenMultipleProcessesLogRecords.test_then_records_should_not_be_garbled..worker'

rudaoshi avatar Mar 05 '21 13:03 rudaoshi

I have no idea what's that error. Only Linux is supported.

jruere avatar Mar 05 '21 14:03 jruere

Personally, I was able to get this working on OSX by changing the default multiprocessing behavior from spawn (OSX default as of Python 3.8 I think) to fork (Linux default). You can read more about it here.

The magic snippet is to make the first line of your program:

   multiprocessing.set_start_method('fork')  # Update default for OSX.

andrewdotcallahan avatar Mar 24 '21 00:03 andrewdotcallahan

Do note that the linked python docs state:

Changed in version 3.8: On macOS, the spawn start method is now the default. The fork start method should be considered unsafe as it can lead to crashes of the subprocess. See bpo-33725

So, change the method at your own risk.

andrewdotcallahan avatar Mar 24 '21 00:03 andrewdotcallahan

This approach seems problematic. Why not use the QueueHandler and corresponding listener directly?

jruere avatar Mar 26 '21 15:03 jruere

The OS is not supported. The approach of this module only work with "fork".

jruere avatar Dec 20 '22 06:12 jruere