Commit f1a68758 authored by David Sikter's avatar David Sikter
Browse files

Fixed join condition

parent 1bb726da
Pipeline #117866 failed with stages
in 24 minutes and 6 seconds
......@@ -446,8 +446,8 @@ class Proc(Document):
Called on the parent Proc object to join (resume) the current process.
For the join to succeed, the following must be fullfilled:
* This Proc must have status `WAITING_FOR_RESULT`
* Every instance of the child class (defined by calling :func:`child_cls`)
linked to this Proc (if any) must be in status FAILURE or SUCCESS.
* No instance of the child class (defined by calling :func:`child_cls`)
linked to this Proc (if any) must be processing.
If the join succeeds, the `process_status` will be set to `RUNNING` and True
will be returned. Otherwise, the method just returns False. The method is written so
that the join should succeed once and only once.
......@@ -456,12 +456,12 @@ class Proc(Document):
if self.process_status != ProcessStatus.WAITING_FOR_RESULT:
self.get_logger().debug('trying to join: not waiting for result')
return False
children_pending_completion = self.child_cls().objects(**{
children_processing = self.child_cls().objects(**{
self.id_field: self.id,
'process_status__nin': (ProcessStatus.SUCCESS, ProcessStatus.FAILURE)}).count()
self.get_logger().debug('trying to join', children_pending_completion=children_pending_completion)
'process_status__in': ProcessStatus.STATUSES_PROCESSING}).count()
self.get_logger().debug('trying to join', children_processing=children_processing)
if not children_pending_completion:
if not children_processing:
# We may easily get here multiple times if multiple children finish at the same time
# To join, we need to read and update the mongo record as a single atomic operation
old_record = self._get_collection().find_one_and_update(
......
......@@ -605,8 +605,8 @@ def test_phonopy_data(proc_infra, test_user, no_warn):
upload = run_processing(('test_upload', 'tests/data/proc/examples_phonopy.zip'), test_user)
additional_keys = ['results.method.simulation.program_name']
assert upload.total_calcs == 1
assert len(upload.calcs) == 1
assert upload.total_calcs == 2
assert len(upload.calcs) == 2
with upload.entries_metadata() as entries:
assert_upload_files(upload.upload_id, entries, StagingUploadFiles, published=False)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment