Skip to content

Optionally propagate the exit code - #220

Merged
astrojuanlu merged 6 commits into
pythonprofilers:masterfrom
hnykda:master
Dec 13, 2018
Merged

astrojuanlu merged 6 commits into
pythonprofilers:masterfrom
hnykda:master

Conversation

@hnykda

@hnykda hnykda commented Dec 13, 2018

Copy link
Copy Markdown
Contributor

Hi,

I added an --exit-code option which tries to propagate the exit code of the underlying program execution. mprof is just silently eating it, causing some unexpected behavior when used in e.g. scripts, containers, ...

It is backward compatible in a way that you need to pass --exit-code|-E option in the run option.

One disruptive change is that I added logger from the standard logging library + added the basicConfig. This is not necessary but IMO is a very good standard in the python world. print are not respecting formatters etc., I consider their usage wrong.

@hnykda hnykda changed the title Optionally propagate an exit code Optionally propagate the exit code Dec 13, 2018

@astrojuanlu astrojuanlu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left only one comment. Before merging this though, I would like to know what specific use case do you have in mind, because measuring the memory of a script that fails does not make much sense to me.

Regarding prints: I think they are common practice when displaying help messages for CLI interfaces, but I did not check with other projects and I might be wrong. What about pip, twine, sphinx-quickstart?

Comment thread mprof.py Outdated
@fabianp

fabianp commented Dec 13, 2018

Copy link
Copy Markdown
Collaborator

thanks @hnykda for the contribution. Changes look good to me

@hnykda

hnykda commented Dec 13, 2018 •

Copy link
Copy Markdown
Contributor Author

@Juanlu001 We are using mprof for long-running processing job, where failures are common (e.g. dataset couldn't be processed or the dynamic data got from a 3rd party malformed). So it's part of a longer pipeline. We collect these log files and can historically compare if we are getting better or worse with memory consumption.

Wrt. prints - I didn't thought about that this way 🤔 . It probably make sense then. Should I remove the logger?

@fabianp

fabianp commented Dec 13, 2018

Copy link
Copy Markdown
Collaborator

Regarding printing vs logging, I think logging adds some flexibility. I don't have a use for it but also don't see any reason not to use it. Hence I'm fine with it.

@fabianp

fabianp commented Dec 13, 2018

Copy link
Copy Markdown
Collaborator

@Juanlu001 : are you OK with the changes in this PR?

@astrojuanlu

Copy link
Copy Markdown
Collaborator

LGTM!

@astrojuanlu
astrojuanlu merged commit 077d67b into pythonprofilers:master Dec 13, 2018
@hnykda

hnykda commented Dec 14, 2018

Copy link
Copy Markdown
Contributor Author

Thanks! Is there any planed release?

@fabianp

fabianp commented Dec 14, 2018 via email

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants