Skip to content

Commit d681e3e

Browse files
committed
Fix process reference problem
1 parent ec76d77 commit d681e3e

File tree

4 files changed

+7
-16
lines changed

4 files changed

+7
-16
lines changed

nextflow/command.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import re
33
import time
4+
import weakref
45
import subprocess
56
from datetime import datetime
67
from nextflow.io import get_file_text, get_process_ids_to_paths, get_file_creation_time
@@ -98,8 +99,7 @@ def _run(
9899
)
99100
log_start += diff
100101
if execution and poll: yield execution
101-
process_finished = not submission.process or submission.process.poll() is not None
102-
if execution and execution.return_code and process_finished:
102+
if execution and execution.return_code and execution.finished:
103103
if not poll: yield execution
104104
break
105105

@@ -142,7 +142,7 @@ def submit_execution(
142142
:param str dag: the filename to use for the DAG report.
143143
:param str trace: the filename to use for the trace report.
144144
:rtype: ``nextflow.models.ExecutionSubmission``"""
145-
145+
146146
if not run_path and not io: run_path = os.path.abspath(".")
147147
if not run_path and io: run_path = io.abspath(".")
148148
if not output_path: output_path = run_path
@@ -153,14 +153,15 @@ def submit_execution(
153153
)
154154
start = datetime.now()
155155
if runner:
156-
process = None
157156
runner(nextflow_command)
158157
else:
159158
process = subprocess.Popen(
160159
nextflow_command, universal_newlines=True, shell=True
161160
)
161+
process._child_created = False # disables warning machinery
162+
weakref.finalize(process, lambda: None)
162163
submission = ExecutionSubmission(
163-
pipeline_path, run_path, output_path, log_path, nextflow_command, timezone, process
164+
pipeline_path, run_path, output_path, log_path, nextflow_command, timezone
164165
)
165166
if resume:
166167
wait_for_log_creation(submission.log_path, start, io)

nextflow/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class ExecutionSubmission:
1616
log_path: str
1717
nextflow_command: str
1818
timezone: str
19-
process: Any
2019

2120

2221

tests/unit/test_command.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ def test_can_run_with_custom_values(self, mock_ex, mock_sleep, mock_submit):
4747
@patch("nextflow.command.get_execution")
4848
def test_can_run_and_poll(self, mock_ex, mock_sleep, mock_submit):
4949
submission = Mock()
50-
submission.process.poll = MagicMock()
51-
submission.process.poll.side_effect = [None, None, 1]
5250
mock_submit.return_value = submission
5351
mock_executions = [Mock(finished=False), Mock(finished=True)]
5452
mock_ex.side_effect = [[None, 20], [mock_executions[0], 40], [mock_executions[1], 20]]
@@ -98,7 +96,6 @@ def test_can_submit_with_default_values(self, mock_run, mock_nc, mock_abs):
9896
self.assertEqual(submission.log_path, "/run")
9997
self.assertEqual(submission.nextflow_command, mock_nc.return_value)
10098
self.assertEqual(submission.timezone, None)
101-
self.assertEqual(submission.process, mock_run.return_value)
10299

103100

104101
@patch("nextflow.command.make_nextflow_command")
@@ -124,7 +121,6 @@ def test_can_submit_with_custom_values(self, mock_wait, mock_run, mock_nc):
124121
self.assertEqual(submission.log_path, "/log")
125122
self.assertEqual(submission.nextflow_command, mock_nc.return_value)
126123
self.assertEqual(submission.timezone, "UTC")
127-
self.assertEqual(submission.process, mock_run.return_value)
128124

129125

130126
@patch("nextflow.command.make_nextflow_command")
@@ -144,7 +140,6 @@ def test_can_submit_with_custom_io(self, mock_run, mock_nc):
144140
self.assertEqual(submission.log_path, io.abspath.return_value)
145141
self.assertEqual(submission.nextflow_command, mock_nc.return_value)
146142
self.assertEqual(submission.timezone, None)
147-
self.assertEqual(submission.process, mock_run.return_value)
148143

149144

150145
@patch("nextflow.command.make_nextflow_command")
@@ -159,7 +154,6 @@ def test_can_run_with_custom_runner(self, mock_nc):
159154
self.assertEqual(submission.log_path, os.path.abspath("."))
160155
self.assertEqual(submission.nextflow_command, mock_nc.return_value)
161156
self.assertEqual(submission.timezone, None)
162-
self.assertEqual(submission.process, None)
163157

164158

165159

tests/unit/test_submission.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@
55
class SubmissionreationTests(TestCase):
66

77
def test_can_create_execution_submission(self):
8-
process = Mock()
98
submission = ExecutionSubmission(
109
pipeline_path="/main.nf",
1110
run_path="/executions/123",
1211
output_path="/executions/123/out",
1312
log_path="/executions/123/out/nextflow.log",
1413
nextflow_command="nextflow run /main.nf",
1514
timezone="UTC",
16-
process=process
1715
)
1816
self.assertEqual(submission.pipeline_path, "/main.nf")
1917
self.assertEqual(submission.run_path, "/executions/123")
2018
self.assertEqual(submission.output_path, "/executions/123/out")
2119
self.assertEqual(submission.log_path, "/executions/123/out/nextflow.log")
2220
self.assertEqual(submission.nextflow_command, "nextflow run /main.nf")
23-
self.assertEqual(submission.timezone, "UTC")
24-
self.assertEqual(submission.process, process)
21+
self.assertEqual(submission.timezone, "UTC")

0 commit comments

Comments
 (0)