Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[][SVCS-683] Add timeouts for subprocess calls #332

Merged

Conversation

NyanHelsing
Copy link
Contributor

@NyanHelsing NyanHelsing commented Apr 16, 2018

Ticket

SVCS-683 Add timeouts for subprocess calls

Purpose

Make subprocess time out instead of hanging indefinitely.

Changes

Side effects

May make files that are particularly large time out if they take too long.

QA Notes

Deployment Notes

Adds a couple of ENV vars to configure the timeout if desired. Default set to 10s.

Copy link
Contributor

@cslzchen cslzchen left a comment

Choose a reason for hiding this comment

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

Here is a few minor issues and back to you 🔥 :

  • Rebase to the latest develop and fix travis.
  • Update style.
  • Since unoconv already have the fix, can you provide a link so we know if this is a similar one or not? Are the 10 seconds what we've agreed on or just a experimental number? Is this code eligible for test? It would be great if you can provide more information on the PR.

self.output_file_path,
# silence output from freecadcmd
], stdout=subprocess.DEVNULL)
subprocess.check_call(
Copy link
Contributor

Choose a reason for hiding this comment

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

How about the following style?

cmd = [FREECAD_BIN, FREECAD_CONVERT_SCRIPT, temp_source_file.name, self.output_file_path]
subprocess.check_call(cmd, stdout=subprocess.DEVNULL, timeout=settings.FREECAD_TIMEOUT)

FREECAD_CONVERT_SCRIPT,
temp_source_file.name,
self.output_file_path,
# silence output from freecadcmd
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this misplaced comments to the right place.

code=504,
process='freecad',
cmd=str(err.cmd),
returncode=52, # This is not re error code returned by the
Copy link
Contributor

Choose a reason for hiding this comment

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

This commenting style is far from Pythonic. You can move it to before the raise as a comment for the raise statement.

fp.name,
csv_file.name,
])
subprocess.check_call(
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar style update as mentioned before.

code=504,
process='pspp',
cmd=str(err.cmd),
returncode=52, # This is not re error code returned by the
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar style update as mentioned before.

@coveralls
Copy link

coveralls commented May 11, 2018

Coverage Status

Coverage decreased (-0.3%) to 70.77% when pulling 3f230c2 on birdbrained:ft/add-subproc-to into 7304d3b on CenterForOpenScience:develop.

@@ -0,0 +1,5 @@
from mfr.core.extension import BaseExporter

class DefaultExporter(BaseExporter):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

get rid of me

@NyanHelsing
Copy link
Contributor Author

Needs a rebase

All three of the current exporters use a subprocess call to perform the
export. To prevent the process from hanging, we add a condition to kill
th process after a specified period of time.
@felliott felliott merged commit 05408e9 into CenterForOpenScience:develop Oct 15, 2018
felliott added a commit that referenced this pull request Oct 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants