sockets,threads and interupts

Ramchandra Apte maniandram01 at gmail.com
Wed Sep 5 08:54:41 EDT 2012


On Wednesday, 5 September 2012 11:26:16 UTC+5:30, Dieter Maurer  wrote:
> loial <jldunn2000 at gmail.com> writes:
> 
> 
> 
> > I have threaded python script that uses sockets to monitor network ports.
> 
> >
> 
> > I want to ensure that the socket is closed cleanly in all circumstances. This includes if the script is killed or interupted in some other way.
> 
> 
> 
> The operating system should close all sockets automatically when
> 
> the process dies. Thus, if closing alone is sufficient...

At least on Linux, if you kill a process using sockets, it takes about 10 seconds for socket to be closed. A program should try to close all resources. OS'es may take a long time to close a unclosed socket automatically.



More information about the Python-list mailing list