Attachment 'sockdebug.py'

Download

   1 import socket, traceback, sys
   2 
   3 _realrealsocket = socket._realsocket
   4 _realclosedsocket = socket._closedsocket
   5 
   6 _stream = sys.stderr
   7 #_stream = open('socket.log')
   8 
   9 def _socket(family, type, proto):
  10     _sock = _realrealsocket(family, type, proto)
  11     stack = traceback.format_stack()
  12     print >>_stream, "OPEN:", repr(_sock), stack
  13     return _sock
  14 
  15 def _close():
  16     stack = traceback.format_stack()
  17     print >>_stream, "CLOSE:", stack
  18     return _realclosedsocket()
  19 
  20 socket._realsocket = _socket
  21 socket._closedsocket = _close
  22     

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2005-07-30 13:29:06, 0.5 KB) [[attachment:sockdebug.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.