Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Twisted what's the difference between processExited and processEnded?

Tags:

twisted

As the title says, what's the difference between those two functions on ProcessProtocol classes? Documentation is a bit sparse on when should one be used instead of another?

Preferably, I'm looking for some examples of use cases that demonstrate that.

like image 539
klozovin Avatar asked Apr 13 '12 13:04

klozovin


1 Answers

I guess the documentation is somewhat sparse on this point. If no such ticket exists, please feel free to file a ticket to improve the API docs.

processExited is invoked when a process has exited in the formal process-management sense, i.e. called exit() or returned from main().

However, this is not always what you want. Sometimes a process spawns a subprocess, hands off its stdin and stdout, delegates responsibility for producing the data that you (the spawning parent process, in this case) wants, and then exit()s because it's done setting things up.

processEnded is invoked when a process has both exited and finished doing all the I/O on its managed file descriptors (stdin, stdout, and childFDs) and they've been closed. If you're spawning something just to read its output, this is the notification you most likely care about.

like image 134
Glyph Avatar answered Nov 15 '22 22:11

Glyph