Discussion:
[Twisted-Python] Trying to use adoptStreamConnection and Protocol isn't being disposed
Sirenfal
2016-01-09 21:56:00 UTC
Permalink
I'm trying to pass a TCP connection to a Twisted subprocess with
adoptStreamConnection, but I can't figure out how to get the Process
disposed in the main process after doing that.

My desired flow looks like this:

- Finish writing any data the Protocol transport has waiting
- When we know the write buffer is empty send the AMP message to
transfer the socket to the subprocess
- Dispose the Protocol instance in the main process
- I tried doing nothing, loseConnection, abortConnection, and monkey
patching _socketClose out and using loseConnection. See code here:
http://pastebin.com/nK0Huxuj

In all cases the Protocol object still exists in the main process after
the socket has been transferred, even if the main process isn't
listening to that socket anymore. How can I clean this up?

Thanks in advance.
Sirenfal
2016-01-09 22:03:18 UTC
Permalink
Sorry, I meant to say "get the Protocol disposed in the main process" in
the first sentence :)
Glyph Lefkowitz
2016-01-09 22:14:37 UTC
Permalink
I'm trying to pass a TCP connection to a Twisted subprocess with adoptStreamConnection, but I can't figure out how to get the Process disposed in the main process after doing that.
- Finish writing any data the Protocol transport has waiting
- When we know the write buffer is empty send the AMP message to transfer the socket to the subprocess
- Dispose the Protocol instance in the main process
- I tried doing nothing, loseConnection, abortConnection, and monkey patching _socketClose out and using loseConnection. See code here: http://pastebin.com/nK0Huxuj <http://pastebin.com/nK0Huxuj>
In all cases the Protocol object still exists in the main process after the socket has been transferred, even if the main process isn't listening to that socket anymore. How can I clean this up?
Since you also asked on Stack Overflow I answered there: http://stackoverflow.com/a/34699544/13564
Loading...