- Copy previous task to prevent unnecessary pickling.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import multiprocessing
|
import multiprocessing
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from contextlib import ExitStack
|
from contextlib import ExitStack
|
||||||
|
from copy import copy
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from os import getpid
|
from os import getpid
|
||||||
from traceback import format_exc
|
from traceback import format_exc
|
||||||
@@ -254,11 +255,19 @@ class ParPool:
|
|||||||
new_handle = handle
|
new_handle = handle
|
||||||
if new_handle in self:
|
if new_handle in self:
|
||||||
raise ValueError(f'handle {new_handle} already present')
|
raise ValueError(f'handle {new_handle} already present')
|
||||||
self.last_task = Task(self.id, fun or self.last_task.fun, args or self.last_task.args,
|
new_task = copy(self.last_task)
|
||||||
kwargs or self.last_task.kwargs, new_handle, n)
|
if fun is not None:
|
||||||
self.tasks[new_handle] = self.last_task
|
new_task.fun = fun
|
||||||
|
if args is not None:
|
||||||
|
new_task.args = args
|
||||||
|
if kwargs is not None:
|
||||||
|
new_task.kwargs = kwargs
|
||||||
|
new_task.handle = new_handle
|
||||||
|
new_task.n = n
|
||||||
|
self.tasks[new_handle] = new_task
|
||||||
|
self.last_task = new_task
|
||||||
|
self.spool.add_task(new_task)
|
||||||
self.bar_lengths[new_handle] = barlength
|
self.bar_lengths[new_handle] = barlength
|
||||||
self.spool.add_task(self.last_task)
|
|
||||||
if handle is None:
|
if handle is None:
|
||||||
return new_handle
|
return new_handle
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "parfor"
|
name = "parfor"
|
||||||
version = "2023.8.3"
|
version = "2023.9.0"
|
||||||
description = "A package to mimic the use of parfor as done in Matlab."
|
description = "A package to mimic the use of parfor as done in Matlab."
|
||||||
authors = ["Wim Pomp <wimpomp@gmail.com>"]
|
authors = ["Wim Pomp <wimpomp@gmail.com>"]
|
||||||
license = "GPLv3"
|
license = "GPLv3"
|
||||||
|
|||||||
Reference in New Issue
Block a user