Skip to content

Commit 7d595fb

Browse files
committed
Inline _get_pending_jobs into populate()
Method only called from one place, no need for separate function.
1 parent d28fa7c commit 7d595fb

File tree

1 file changed

+6
-31
lines changed

1 file changed

+6
-31
lines changed

src/datajoint/autopopulate.py

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,12 @@ def handler(signum, frame):
236236
success_list = []
237237

238238
if reserve_jobs:
239-
# New Autopopulate 2.0 logic: use jobs table
240-
keys = self._get_pending_jobs(
241-
restrictions=restrictions,
242-
priority=priority,
243-
limit=limit,
244-
refresh=refresh,
245-
)
239+
# Use jobs table for coordinated processing
240+
keys = self.jobs.fetch_pending(limit=limit, priority=priority)
241+
if not keys and refresh:
242+
logger.debug("No pending jobs found, refreshing jobs queue")
243+
self.jobs.refresh(*restrictions)
244+
keys = self.jobs.fetch_pending(limit=limit, priority=priority)
246245
else:
247246
# Without job reservations: compute keys directly from key_source
248247
if keys is None:
@@ -307,30 +306,6 @@ def handler(signum, frame):
307306
"error_list": error_list,
308307
}
309308

310-
def _get_pending_jobs(self, restrictions, priority, limit, refresh):
311-
"""
312-
Get pending jobs from the jobs table.
313-
314-
If no pending jobs are found and refresh=True, refreshes the jobs queue
315-
and tries again.
316-
317-
:param restrictions: Restrictions to apply when refreshing
318-
:param priority: Only get jobs at this priority or more urgent
319-
:param limit: Maximum number of jobs to return
320-
:param refresh: Whether to refresh if no pending jobs found
321-
:return: List of key dicts
322-
"""
323-
# First, try to get pending jobs
324-
keys = self.jobs.fetch_pending(limit=limit, priority=priority)
325-
326-
# If no pending jobs and refresh is enabled, refresh and try again
327-
if not keys and refresh:
328-
logger.debug("No pending jobs found, refreshing jobs queue")
329-
self.jobs.refresh(*restrictions)
330-
keys = self.jobs.fetch_pending(limit=limit, priority=priority)
331-
332-
return keys
333-
334309
def _populate1(self, key, jobs, suppress_errors, return_exception_objects, make_kwargs=None):
335310
"""
336311
populates table for one source key, calling self.make inside a transaction.

0 commit comments

Comments
 (0)