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

Add dispose support #487

Merged
merged 1 commit into from Aug 1, 2016
Merged

Add dispose support #487

merged 1 commit into from Aug 1, 2016

Conversation

dlwr
Copy link
Contributor

@dlwr dlwr commented Jan 6, 2016

This pull request adds a dispose option to the gm instance.
The disposer consists of an EventEmitter and events. We can add multiple disposers.
e.g.

gm(dir + '/photo.JPG').options({
  disposers: [
    {
      emitter: emitter1,
      events: ['start']
    },
    {
      emitter: emitter2,
      events: ['end', 'error']
    }
  ]
});

or we can add after instanciation.
e.g

gm.addDisposer(emitter3, ['close', 'aborted']);

after this PR, for example, we can dispose immediately when node connection is aborted or closed.

before:
b29b418e-b2fc-11e5-9973-02eaa3cf08ea
there are many convert processes after aborting requests.

after:
cccdc5a4-b2fc-11e5-9c2d-7f94f23bb9dd
there are no convert processes left.

Best regards.

@@ -228,15 +229,18 @@ module.exports = function (proto) {

if (timeout) {
timeoutId = setTimeout(function(){
err = new Error('gm() resulted in a timeout.');
cb(err);
if (proc.connected) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this check was useless because child_process.connected is always false without forked process or not using ipc.
( please look arround here https://github.com/nodejs/node/blob/master/lib/internal/child_process.js#L337)
So, I change this line to check proc.exitCode at https://github.com/aheckmann/gm/pull/487/files#diff-b26080cc6f2472dce354dbedffc64d57R329

@aheckmann aheckmann merged commit f70800b into aheckmann:master Aug 1, 2016
@aheckmann
Copy link
Owner

thanks!

@dlwr dlwr deleted the dispose-support branch November 6, 2018 10:27
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.

None yet

2 participants