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

OSError #20

Merged
merged 1 commit into from
Dec 6, 2016
Merged

OSError #20

merged 1 commit into from
Dec 6, 2016

Conversation

thisiswei
Copy link

@thisiswei thisiswei commented Dec 6, 2016

One of my cron command was failing but it was not caught by cron-sentry

Issue #3

try:
exit_status = call(self.command, stdout=stdout, stderr=stderr)
except OSError:
exit_status = 1

last_lines_stdout = self._get_last_lines(stdout)
Copy link

Choose a reason for hiding this comment

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

I think this will be a problem when you have OSError.

Copy link
Author

Choose a reason for hiding this comment

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

Sorry I don't follow, what scenarios are you thinking?

try:
exit_status = call(self.command, stdout=stdout, stderr=stderr)
except OSError:
exit_status = 1
Copy link

Choose a reason for hiding this comment

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

Maybe it's a better idea to report the exception to Sentry right here.

@thisiswei
Copy link
Author

try using following code but the result were the same:

    def run(self):
        start = time()

        with TemporaryFile() as stdout:
            with TemporaryFile() as stderr:
                try:
                    exit_status = call(self.command, stdout=stdout, stderr=stderr)
                except OSError as exc:
                    exit_status = 1
                    elapsed = int((time() - start) * 1000)
                    self.report_fail(1, '', unicode(exc), elapsed)
                    return exit_status

                last_lines_stdout = self._get_last_lines(stdout)
                last_lines_stderr = self._get_last_lines(stderr)

                if exit_status > 0:
                    elapsed = int((time() - start) * 1000)
                    self.report_fail(exit_status, last_lines_stdout, last_lines_stderr, elapsed)

                if not self.quiet:
                    sys.stdout.write(last_lines_stdout)
                    sys.stderr.write(last_lines_stderr)

                return exit_status

this is after lines added: https://sentry.io/yipitcom/tests/issues/190856199/
this was before: https://sentry.io/yipitcom/tests/issues/190853717/

@hltbra hltbra merged commit 499ed82 into master Dec 6, 2016
@hltbra hltbra deleted the fix/fix-oserrors branch December 6, 2016 22:00
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.

2 participants