简体   繁体   English

如何将数组的一个元素传递给多处理中的进程

[英]how to pass one element of an array to a process in multiprocessing

I want to pass each element of an array to a process by multiprocessing in python.我想通过 python 中的多处理将数组的每个元素传递给进程。 How can I do it?我该怎么做? For example, I have a[i] as an array and want to send a[0] to core 1, a[1] to core 2,.... Is there any way to do it in python?例如,我将a[i]作为数组,并希望将a[0]发送到核心 1, a[1]发送到核心 2,.... 在 python 中有什么方法可以做到吗?

CPython (the standard python implementation) has something called the GIL (Global Interpreter Lock),as Gabriel Grant write in this answer Python threads all executing on a single core each time a request to make a new thread is made, the interpreter actually calls into the operating system's libraries and kernel to generate a new thread. CPython(标准 python 实现)有一个叫做 GIL(全局解释器锁)的东西,正如 Gabriel Grant 在这个答案中写的那样Python 线程在每次请求创建一个新线程时都在一个内核上执行,解释器实际上调用操作系统的库和 kernel 生成一个新线程。 so you can use multi-threading to use multitask at the same time but you can't force wich core will be executed所以你可以使用多线程同时使用多任务,但你不能强制执行哪个核心

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将队列字典传递给 multiprocessing.Process - How to pass a dictionary of Queues to multiprocessing.Process Asyncio和multiprocessing.Process-如何传递协程 - Asyncio and multiprocessing.Process- how to pass a coroutine? 如何使用多重处理将对象从主流程传递到子流程 - How to pass object from main process to child process using multiprocessing 如何在python进程中获取多处理数组 - How to get multiprocessing Array in python process 多处理:将文件句柄传递给进程 - Multiprocessing: Pass file handle to Process 如何将未腌制的对象作为参数传递给multiprocessing.Process? - How to pass unpickled object as argument in multiprocessing.Process? 如何使用多重处理创建套接字对象并将其传递回父进程 - How to create a socket object using multiprocessing and pass it back to the parent process 如何将lastpass Vault对象传递给多处理流程工作者 - How to pass a lastpass Vault object into multiprocessing process worker Python(多处理):如何将字典作为工作进程初始值设定项函数的参数传递? - Python (multiprocessing): How to pass a dictionary as the argument of a worker process initializer function? Python3 multiprocessing Process 如何传递变量? - How does Python3 multiprocessing Process pass variables?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM