-
Notifications
You must be signed in to change notification settings - Fork 30
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
Handle python's 120 exit code #340
Conversation
See https://docs.python.org/3/library/sys.html#sys.exit. This works around issue #339.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test for this exit code, similar to this one?
ecs-watchbot/test/worker.test.js
Lines 311 to 336 in c98f0c2
test('[worker] waitFor, exit 4', async (assert) => { | |
const logger = stubber(Logger).setup(); | |
logger.log.restore(); | |
logger.stream.restore(); | |
const message = sinon.createStubInstance(Message); | |
message.env = { Message: 'banana', SentTimestamp: '2019-02-09T21:57:55.000Z' }; | |
const options = { command: 'exit 4', volumes: ['/tmp'] }; | |
const worker = new Worker(message, options); | |
sinon.spy(child_process, 'spawn'); | |
try { | |
await worker.waitFor(); | |
} catch (err) { | |
assert.ifError(err, 'failed'); | |
} | |
const results = logger.workerSuccess.args[0][0]; | |
assert.equal(results.code, 4, 'logged worker success exit code'); | |
assert.ok(results.duration, 'logged worker success duration'); | |
assert.ok(results.response_duration, 'logged worker response duration'); | |
assert.equal(message.retry.callCount, 1, 'calls message.retry()'); | |
child_process.spawn.restore(); | |
logger.teardown(); | |
assert.end(); |
@rclark ok, test added. |
test/worker.test.js
Outdated
logger.log.restore(); | ||
logger.stream.restore(); | ||
const message = sinon.createStubInstance(Message); | ||
message.env = { Message: 'forty bananas', SentTimestamp: '2020-11-03T21:57:55.000Z' }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yummy
See https://docs.python.org/3/library/sys.html#sys.exit. 120 is the python interpreter's only special code.
This works around issue #339. There's a deeper problem to be solved, but even so this is a useful patch. We never want to retry in the case that the worker gets a 120 exit code from python.