Skip to content

Commit

Permalink
Update WorkerPlugin docstring about usage of TaskState objects (#5226)
Browse files Browse the repository at this point in the history
* Update WorkerPlugin docstring for usage of task exceptions

* Avoid usage of StateLegacyMapping in progress plugin
  • Loading branch information
fjetter authored Aug 18, 2021
1 parent 5467f9c commit 8c73a18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions distributed/diagnostics/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,12 @@ class WorkerPlugin:
...
... def transition(self, key, start, finish, *args, **kwargs):
... if finish == 'error':
... exc = self.worker.exceptions[key]
... self.logger.error("Task '%s' has failed with exception: %s" % (key, str(exc)))
... ts = self.worker.tasks[key]
... exc_info = (type(ts.exception), ts.exception, ts.traceback)
... self.logger.error(
... "Error during computation of '%s'.", key,
... exc_info=exc_info
... )
>>> plugin = ErrorLogger()
>>> client.register_worker_plugin(plugin) # doctest: +SKIP
Expand Down
4 changes: 3 additions & 1 deletion distributed/diagnostics/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def stop(self, exception=None, key=None):
self.scheduler.plugins.remove(self)
if exception:
self.status = "error"
self.extra.update({"exception": self.scheduler.exceptions[key], "key": key})
self.extra.update(
{"exception": self.scheduler.tasks[key].exception, "key": key}
)
else:
self.status = "finished"
logger.debug("Remove Progress plugin")
Expand Down

0 comments on commit 8c73a18

Please sign in to comment.