Skip to content

Commit

Permalink
1 less indent
Browse files Browse the repository at this point in the history
  • Loading branch information
crusaderky committed Mar 11, 2024
1 parent 2e8aab8 commit ad3e016
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions distributed/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2986,35 +2986,35 @@ def apply_function_simple(
# m.stop - m.start
# Difference in wall time before and after function call, without subtracting
# anything. This is used in scheduler heuristics, e.g. task stealing.
with context_meter.meter("thread-noncpu", func=time) as m:
with context_meter.meter("thread-cpu", func=thread_time):
try:
result = function(*args, **kwargs)
except (SystemExit, KeyboardInterrupt):
# Special-case these, just like asyncio does all over the place. They
# will pass through `fail_hard` and `_handle_stimulus_from_task`, and
# eventually be caught by special-case logic in asyncio:
# https://github.com/python/cpython/blob/v3.9.4/Lib/asyncio/events.py#L81-L82
# Any other `BaseException` types would ultimately be ignored by asyncio
# if raised here, after messing up the worker state machine along their
# way.
raise
except BaseException as e:
# Users _shouldn't_ use `BaseException`s, but if they do, we can assume
# they aren't a reason to shut down the whole system (since we allow the
# system-shutting-down `SystemExit` and `KeyboardInterrupt` to pass
# through)
msg = error_message(e)
msg["op"] = "task-erred"
msg["actual-exception"] = e
else:
msg = {
"op": "task-finished",
"status": "OK",
"result": result,
"nbytes": sizeof(result),
"type": type(result) if result is not None else None,
}
with (
context_meter.meter("thread-noncpu", func=time) as m,
context_meter.meter("thread-cpu", func=thread_time),
):
try:
result = function(*args, **kwargs)
except (SystemExit, KeyboardInterrupt):
# Special-case these, just like asyncio does all over the place. They will
# pass through `fail_hard` and `_handle_stimulus_from_task`, and eventually
# be caught by special-case logic in asyncio:
# https://github.com/python/cpython/blob/v3.9.4/Lib/asyncio/events.py#L81-L82
# Any other `BaseException` types would ultimately be ignored by asyncio if
# raised here, after messing up the worker state machine along their way.
raise

Check warning on line 3002 in distributed/worker.py

View check run for this annotation

Codecov / codecov/patch

distributed/worker.py#L3002

Added line #L3002 was not covered by tests
except BaseException as e:
# Users _shouldn't_ use `BaseException`s, but if they do, we can assume they
# aren't a reason to shut down the whole system (since we allow the
# system-shutting-down `SystemExit` and `KeyboardInterrupt` to pass through)
msg = error_message(e)
msg["op"] = "task-erred"
msg["actual-exception"] = e
else:
msg = {
"op": "task-finished",
"status": "OK",
"result": result,
"nbytes": sizeof(result),
"type": type(result) if result is not None else None,
}

msg["start"] = m.start + time_delay
msg["stop"] = m.stop + time_delay
Expand Down

0 comments on commit ad3e016

Please sign in to comment.