nickva commented on a change in pull request #3361:
URL: https://github.com/apache/couchdb/pull/3361#discussion_r571067939
##########
File path: src/couch/src/couch_task_status.erl
##########
@@ -124,7 +124,7 @@ handle_call({add_task, TaskProps}, {From, _}, Server) ->
end;
handle_call(all, _, Server) ->
All = [
- [{pid, ?l2b(pid_to_list(Pid))} | TaskProps]
+ [{pid, ?l2b(pid_to_list(Pid))}, process_info(Pid, status) | TaskProps]
Review comment:
We should handle a process which just exited, then `process_info(Pid,
status)` would return `undefined` and it would break the json serializer. We
could use a `case ...` statement and turn undefined into `{status, dead}` or
similar, or even better maybe skip the process altogether since it's not
"active" anymore?
It might better to have the `status` key be a bit more descriptive to make
it clear it is the erlang process status. Otherwise, `status` might be
interpreted as being related to the overall task. Say, a replication task
status as `waiting` might be interpreted that it's waiting on a changes feed,
while it would actually be actively processing changes.
```
10> process_info(self(), status).
{status,running}
11> process_info(list_to_pid("<0.100.100>"), status).
undefined
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]