Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix blocking worker queue when scheduling in parallel #3013

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions test/scheduler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
from multiprocessing import Process
from helpers import unittest

import luigi.scheduler
import luigi
import luigi.server
import luigi.configuration
from helpers import with_config
from helpers import with_config, RunOnceTask
from luigi.target import FileAlreadyExists


class PicklableTask(RunOnceTask):
i = luigi.IntParameter()


class SchedulerIoTest(unittest.TestCase):

def test_pretty_id_unicode(self):
Expand Down Expand Up @@ -286,6 +289,10 @@ class SchedulerWorkerTest(unittest.TestCase):
def get_pending_ids(self, worker, state):
return {task.id for task in worker.get_tasks(state, 'PENDING')}

def schedule_parallel(self, tasks):
return luigi.interface.build(tasks, local_scheduler=True, parallel_scheduling=True,
parallel_scheduling_processes=2)

def test_get_pending_tasks_with_many_done_tasks(self):
sch = luigi.scheduler.Scheduler()
sch.add_task(worker='NON_TRIVIAL', task_id='A', resources={'a': 1})
Expand All @@ -300,6 +307,17 @@ def test_get_pending_tasks_with_many_done_tasks(self):
non_trivial_worker = scheduler_state.get_worker('NON_TRIVIAL')
self.assertEqual({'A'}, self.get_pending_ids(non_trivial_worker, scheduler_state))

def test_parallel_scheduling_with_picklable_tasks(self):
tasks = [PicklableTask(i=i) for i in range(5)]
self.assertTrue(self.schedule_parallel(tasks))

def test_parallel_scheduling_with_unpicklable_tasks(self):
class UnpicklableTask(RunOnceTask):
i = luigi.IntParameter()

tasks = [UnpicklableTask(i=i) for i in range(5)]
self.assertFalse(self.schedule_parallel(tasks))
Copy link
Contributor Author

@riga riga Oct 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line never terminates as can be seen in the first build log.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 043b4c6.



class FailingOnDoubleRunTask(luigi.Task):
time_to_check_secs = 1
Expand Down