简体   繁体   English

如何在 concurrent.futures.ProcessPoolExecutor 期间将变量 output 存储在 function 中

[英]How to store the variables output inside a function during concurrent.futures.ProcessPoolExecutor from concurrent.futures

I am currently trying to store the output obtained in a function during multiprocessing by using concurrent.futures.ProcessPoolExecutor from concurrent.futures built a library of python3 storing the variable as a global variable.我目前正在尝试通过使用 concurrent.futures 中的 concurrent.futures.ProcessPoolExecutor 在多处理期间存储在 function 中获得的 output 构建了一个 python3 库,将变量存储为全局变量。 But the variable output gets deleted once the process is over.但是一旦过程结束,变量 output 就会被删除。 Does anyone has faced the same issue?有没有人遇到过同样的问题?

Reference:参考:

with concurrent.futures.ThreadPoolExecutor(max_workers=7) as executor:
    fxReturn = executor.submit(your_function)
    fxReturn.result()

fxReturn will store return value of your_function but to access it you need to use result() fxReturn 将存储your_function的返回值,但要访问它,您需要使用result()

暂无
暂无

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

相关问题 将带有对象的 function 传递到 concurrent.futures.ProcessPoolExecutor()? - Pass function with objects into concurrent.futures.ProcessPoolExecutor()? 如何从 concurrent.futures.ProcessPoolExecutor() 的结果生成数据帧? - How to generate a dataframe from the results of a concurrent.futures.ProcessPoolExecutor()? 如何将多个参数传递给由 concurrent.futures.ProcessPoolExecutor 中的 executor.map() 迭代的函数 - How to pass several parameters to a function which is iterated by executor.map() from concurrent.futures.ProcessPoolExecutor `concurrent.futures`中`with`的function - function of `with` in `concurrent.futures` concurrent.futures.ProcessPoolExecutor() 没有在 class 中调用方法 - concurrent.futures.ProcessPoolExecutor() not calling method inside class 当 function 是 lambda 或嵌套的 function 时,concurrent.futures.ProcessPoolExecutor 挂起 - concurrent.futures.ProcessPoolExecutor hangs when the function is a lambda or nested function concurrent.futures.ProcessPoolExecutor() 中的共享变量 python - Shared variable in concurrent.futures.ProcessPoolExecutor() python 使用初始化启动 concurrent.futures.ProcessPoolExecutor? - Launch concurrent.futures.ProcessPoolExecutor with initialization? 为什么 concurrent.futures.ProcessPoolExecutor() 跳过迭代? - Why is concurrent.futures.ProcessPoolExecutor() skipping iterations? 如何在 Python 中的 concurrent.futures.ProcessPoolExecutor 中传递“锁”? - How to pass the “lock” in my concurrent.futures.ProcessPoolExecutor in Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM