Skip to content

Commit 2b8167e

Browse files
committed
{AH} fixes for gevent 1.5
1 parent 11f894b commit 2b8167e

File tree

5 files changed

+43
-18
lines changed

5 files changed

+43
-18
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ ruffus_development.*
1212
*~
1313
*.swp
1414

15+
*.time

ruffus/file_name_parameters.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,17 @@ def yield_io_params_per_job(input_params,
11131113
else:
11141114
input_param = orig_input_param
11151115

1116-
# extras
1116+
# extras - this statement applies transformations on the
1117+
# extra parameters. It traverses nested data
1118+
# structures. The transformation forces a copy of each
1119+
# parameter which causes memory duplication. The memory use
1120+
# can be significant if extras is large.
1121+
#
1122+
# For example, if extras contains a list of 10000 files,
1123+
# there will be one copy for each input parameter. If
1124+
# there are 1000 input files, this means there will be
1125+
# 1000 * 100000 filenames (instead of 1000 references to
1126+
# the same list containing 10000 strings).
11171127
extra_params = tuple(file_names_transform.substitute(
11181128
filenames, p) for p in extra_specs)
11191129

ruffus/ruffus_utility.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,20 +878,29 @@ def __call__(self, p):
878878
#
879879

880880

881-
def regex_replace(filename, regex_str, compiled_regex, substitution_patterns, regex_or_suffix=REGEX_SUBSTITUTE):
882-
return apply_func_to_sequence(substitution_patterns, t_regex_replace(filename, regex_str, compiled_regex, regex_or_suffix))
881+
def regex_replace(filename, regex_str, compiled_regex, substitution_patterns,
882+
regex_or_suffix=REGEX_SUBSTITUTE):
883+
return apply_func_to_sequence(
884+
substitution_patterns,
885+
t_regex_replace(filename, regex_str, compiled_regex, regex_or_suffix))
883886

884887

885888
def formatter_replace(filenames, regex_str, compiled_regex, substitution_patterns):
886-
return apply_func_to_sequence(substitution_patterns, t_formatter_replace(filenames, regex_str, compiled_regex))
889+
return apply_func_to_sequence(
890+
substitution_patterns,
891+
t_formatter_replace(filenames, regex_str, compiled_regex))
887892

888893

889894
def nested_formatter_replace(filenames, regex_strings, compiled_regexes, substitution_patterns):
890-
return apply_func_to_sequence(substitution_patterns, t_nested_formatter_replace(filenames, regex_strings, compiled_regexes))
895+
return apply_func_to_sequence(
896+
substitution_patterns,
897+
t_nested_formatter_replace(filenames, regex_strings, compiled_regexes))
891898

892899

893900
def nested_string_replace(prev_str, new_str, substitution_patterns):
894-
return apply_func_to_sequence(substitution_patterns, t_nested_string_replace(prev_str, new_str))
901+
return apply_func_to_sequence(
902+
substitution_patterns,
903+
t_nested_string_replace(prev_str, new_str))
895904

896905

897906
# _________________________________________________________________________________________

ruffus/task.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,8 @@ def generic_job_descriptor(unglobbed_params, verbose_abbreviated_path, runtime_d
456456

457457

458458
def io_files_job_descriptor(unglobbed_params, verbose_abbreviated_path, runtime_data):
459-
extra_param = ", " + shorten_filenames_encoder(unglobbed_params[2:], verbose_abbreviated_path)[1:-1] \
459+
extra_param = ", " + shorten_filenames_encoder(map(str, unglobbed_params[2:]),
460+
verbose_abbreviated_path)[1:-1] \
460461
if len(unglobbed_params) > 2 else ""
461462
out_param = shorten_filenames_encoder(unglobbed_params[1], verbose_abbreviated_path) \
462463
if len(unglobbed_params) > 1 else "??"
@@ -873,10 +874,11 @@ def _create_task(self, task_func, task_name=None):
873874
if task_name not in self.task_names:
874875
break
875876
else:
876-
raise ruffus_exceptions.error_duplicate_task_name("The task string '%s' is ambiguous for "
877-
"Pipeline '%s'. You must disambiguate "
878-
"explicitly with different task names "
879-
% (task_str, self.name))
877+
raise ruffus_exceptions.error_duplicate_task_name(
878+
"The task string '{}' is ambiguous for "
879+
"Pipeline '{}'. You must disambiguate "
880+
"explicitly with different task names ".format(
881+
task_str, self.name))
880882
return Task(task_func, task_name, self)
881883

882884
#
@@ -2342,7 +2344,7 @@ def _is_up_to_date(self, verbose_logger_job_history):
23422344
#
23432345
# rethrow exception after adding task name
23442346
#
2345-
if exceptionType == error_task:
2347+
if exceptionType == ruffus_exceptions.error_task:
23462348
exceptionValue.specify
23472349
inst.specify_task(self, "Exceptions in dependency checking")
23482350
raise
@@ -5028,7 +5030,10 @@ def pipeline_run(target_tasks=[],
50285030
import gevent.event
50295031
import gevent.queue
50305032
import gevent.pool
5031-
import gevent.signal
5033+
try:
5034+
from gevent.signal import signal as gevent_signal
5035+
except:
5036+
import gevent.signal as gevent_signal
50325037
try:
50335038
import gevent.lock as gevent_lock
50345039
except:
@@ -5038,9 +5043,9 @@ def pipeline_run(target_tasks=[],
50385043
pool_t = gevent.pool.Pool
50395044
pool = pool_t(parallelism)
50405045
queue_t = gevent.queue.Queue
5041-
gevent.signal(signal.SIGINT, functools.partial(handle_sigint, pool=pool, pipeline=pipeline))
5042-
gevent.signal(signal.SIGUSR1, functools.partial(handle_sigusr1, pool=pool, pipeline=pipeline))
5043-
gevent.signal(signal.SIGUSR2, functools.partial(handle_sigusr2, pool=pool, pipeline=pipeline))
5046+
gevent_signal(signal.SIGINT, functools.partial(handle_sigint, pool=pool, pipeline=pipeline))
5047+
gevent_signal(signal.SIGUSR1, functools.partial(handle_sigusr1, pool=pool, pipeline=pipeline))
5048+
gevent_signal(signal.SIGUSR2, functools.partial(handle_sigusr2, pool=pool, pipeline=pipeline))
50445049
else:
50455050
raise ValueError("unknown pool manager '{}'".format(pool_manager))
50465051

ruffus/test/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ NOTEST_RUN=$(NOTEST:%.py=%.run)
1717
all: $(PYTEST_RUN) $(NOTEST_RUN)
1818

1919
%.pytest: %.py
20-
pytest $(PYTEST_OPTIONS) $<
20+
/usr/bin/time --output=$*.time -v pytest $(PYTEST_OPTIONS) $<
2121

2222
%.run: %.py
23-
python $<
23+
/usr/bin/time --output=$*.time -v python $<

0 commit comments

Comments
 (0)