multiprocessing - 将 hylang 与 python 多处理一起使用的示例
问题描述
我正在寻找一个将 python 多处理(即进程池/线程池、作业队列等)与 hylang 一起使用的示例。
解决方案
文档中的第一个示例multiprocessing
可以直译为 Hy,如下所示:
(import multiprocessing [Pool])
(defn f [x]
(* x x))
(when (= __name__ "__main__")
(with [p (Pool 5)]
(print (.map p f [1 2 3]))))
推荐阅读
- react-native - React Native TouchableOpacity onPress 不适用于 FlatList
- git - git:仅通过执行位应用权限:没有它可以完成吗?
- database - 尝试使用 Flutter 中的 Dart 从 Firestore 集合中的文档访问和打印数据时出现错误状态错误?
- c++ - 在 VSC IDE 中编译带有链接头文件的 C++ 文件
- swift - 在 XCode 中,是否可以为错误添加符号断点:Could not load the "" image referenced from a nib ....?
- google-play-games - 网页GPGS登录,然后后端服务器
- windows - 使用自定义构建步骤失败
- rotation - QGIS:如何应用与投影一致的旋转
- c# - 我可以将数组和变量作为参数传递给 C# 中的方法吗?
- c++ - 如何从我的源代码 cpp 中获取可执行代码?