Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

sephamorr
Copy link
Contributor

Python3.8 and above changed the behavior of the multiprocessing module on macOS, resulting in variable scoping being tighter than on other platforms or versions.

As a simplified case, this code crashes on such a machine:

import multiprocessing

def worker(local):
	print(v)

if __name__ == "__main__":
	v = "can i access this?"
	with multiprocessing.Pool() as p:
		devices = p.map(worker, [None])

This patch passes in the relevant variable into the worker in a different style to fix. I've tested this on linux and Mac platforms for regressions.

@github-actions
Copy link

Memory map comparison

@github-actions
Copy link

Memory map comparison

@github-actions
Copy link

Memory map comparison

@newAM newAM added the bug label Dec 16, 2021
Copy link
Member

@adamgreig adamgreig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good! Any reason it's still marked as a draft?

Only tiny comment is I like to stick to PEP8 which would complain about this missing space.

Co-authored-by: Adam Greig <[email protected]>
@sephamorr sephamorr marked this pull request as ready for review December 16, 2021 02:26
@github-actions
Copy link

Memory map comparison

@sephamorr
Copy link
Contributor Author

Fixed and marked for review at your convenience.

Copy link
Member

@adamgreig adamgreig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

bors merge

@bors bors bot merged commit 1ec9d48 into stm32-rs:master Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants