19
19
20
20
def _initialize_populate (table , jobs , populate_kwargs ):
21
21
"""
22
- Initialize the process for mulitprocessing .
22
+ Initialize the process for multiprocessing .
23
23
Saves the unpickled copy of the table to the current process and reconnects.
24
24
"""
25
25
process = mp .current_process ()
@@ -126,14 +126,17 @@ def _jobs_to_do(self, restrictions):
126
126
pass
127
127
return (todo & AndList (restrictions )).proj ()
128
128
129
- def populate (self , * restrictions , suppress_errors = False , return_exception_objects = False ,
129
+ def populate (self , * restrictions , keys = None , suppress_errors = False ,
130
+ return_exception_objects = False ,
130
131
reserve_jobs = False , order = "original" , limit = None , max_calls = None ,
131
132
display_progress = False , processes = 1 ):
132
133
"""
133
134
table.populate() calls table.make(key) for every primary key in self.key_source
134
135
for which there is not already a tuple in table.
135
136
:param restrictions: a list of restrictions each restrict
136
137
(table.key_source - target.proj())
138
+ :param keys: The list of dicts to populate. When None (default),
139
+ uses self.key_source to query keys to populate.
137
140
:param suppress_errors: if True, do not terminate execution.
138
141
:param return_exception_objects: return error objects instead of just error messages
139
142
:param reserve_jobs: if True, reserve jobs to populate in asynchronous fashion
@@ -159,7 +162,8 @@ def handler(signum, frame):
159
162
raise SystemExit ('SIGTERM received' )
160
163
old_handler = signal .signal (signal .SIGTERM , handler )
161
164
162
- keys = (self ._jobs_to_do (restrictions ) - self .target ).fetch ("KEY" , limit = limit )
165
+ keys = keys if keys is not None else \
166
+ (self ._jobs_to_do (restrictions ) - self .target ).fetch ("KEY" , limit = limit )
163
167
if order == "reverse" :
164
168
keys .reverse ()
165
169
elif order == "random" :
@@ -216,6 +220,7 @@ def _populate1(self, key, jobs, suppress_errors, return_exception_objects):
216
220
:param return_exception_objects: if True, errors must be returned as objects
217
221
:return: (key, error) when suppress_errors=True, otherwise None
218
222
"""
223
+ # use the legacy `_make_tuples` callback.
219
224
make = self ._make_tuples if hasattr (self , '_make_tuples' ) else self .make
220
225
221
226
if jobs is None or jobs .reserve (self .target .table_name , self ._job_key (key )):
0 commit comments