Opened 17 years ago

Last modified 17 years ago

#609 defect closed fixed (fixed)

twisted.internet.protocol.ProcessProtocol : process protocol not freed

Reported by: crigau Owned by:
Priority: highest Milestone:
Component: Keywords:
Cc: spiv, itamarst, crigau Branch:
Author:

Description


Change History (3)

comment:1 Changed 17 years ago by crigau

I'm using Twisted for a very dynamic network management system. I
encountered some free resources problems. Here is one:

The protocol object passed to spawnProcess is never freed (processEnded is
called). I'm using twisted on RedHat 7.3, Python is 2.3.3, twisted is 1.2.0

As I spawn a lot of processes, this is a problem for using Twisted.


Cyrille Rigault

--------------------------------------------------

from twisted.internet import reactor, protocol

class MyProcessProtocol( protocol.ProcessProtocol):

    def __init__( self):
        print 'MyProcessProtocol::constructor'

    def __del__( self):
        print 'MyProcessProtocol::destructor'

    def outReceived( self, data):
        print data

    def processEnded( self, status):
        print 'MyProcessProtocol ended'


if __name__ == '__main__':

    reactor.spawnProcess( MyProcessProtocol(), '/sbin/ls', ['/sbin/ls',
'/tmp'], env=None)
    reactor.run()

comment:2 Changed 17 years ago by itamarst

I would suggest not using __del__, since that can cause memory leaks in its own
right - weakrefs with callbacks may be better. But there was a bug, which I fixed.

comment:3 Changed 11 years ago by <automation>

Owner: itamarst deleted
Note: See TracTickets for help on using tickets.