-
-
Save pope/83917 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| import multiprocessing | |
| def _get_logger(): | |
| logger = multiprocessing.get_logger() | |
| logger.setLevel(logging.INFO) | |
| handler = logging.StreamHandler() | |
| handler.setLevel(logging.INFO) | |
| formatter = logging.Formatter('[%(levelname)s/%(processName)s] %(message)s') | |
| handler.setFormatter(formatter) | |
| logger.addHandler(handler) | |
| return logger | |
| logger = _get_logger() | |
| def double(x): | |
| value = x * 2 | |
| logger.info("%i doubled is %i" % (x, value)) | |
| return value | |
| def main(): | |
| p = multiprocessing.Pool(4) | |
| p.map(double, xrange(0, 200)) | |
| if __name__ == "__main__": | |
| main() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import mp | |
| import multiprocessing | |
| if __name__ == "__main__": | |
| multiprocessing.freeze_support() | |
| mp.main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from distutils.core import setup | |
| setup(name="mp", | |
| version="1.0", | |
| description="Testing multiprocessing on windows", | |
| packages=["mp"], | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment