Обработка таймаута при закрытии потока.
[vpproxy.git] / plugins / debug_plugin.py
1 __author__ = 'rvb'
2 '''
3 Local Playlist Plugin
4 (based on ytv plugin by ValdikSS)
5
6 plsylist index
7
8 http://ip:port/index
9
10 m3u playlists
11
12 http://ip:port/m3u
13 http://ip:port/m3u/
14 http://ip:port/m3u/list-name
15
16 plain-tet channel names
17
18 http://ip:port/list
19 http://ip:port/list/
20 http://ip:port/list/list-name
21
22 forward to player
23
24 http://ip:port/play/channel-name
25 http://ip:port/play/list-name/channel-name
26 http://ip:port/play/{list-name}/(get|mp4|webm)/channel-name
27
28 '''
29 import logging
30 import gc
31 from modules.PluginInterface import VPProxyPlugin
32 import os
33 from guppy import hpy
34 h = hpy()
35
36 class Debug(VPProxyPlugin):
37
38     handlers = ('debug',)
39
40     logger = logging.getLogger('mem_debug')
41
42     def handle(self, connection):
43
44         connection.send_response(200)
45         connection.send_header('Content-Type', 'text/plain')
46         connection.end_headers()
47         
48         gc.set_debug(gc.DEBUG_LEAK)
49
50         connection.wfile.write('{} objects collected\n'.format(gc.collect()))
51
52         connection.wfile.write(h.heap())
53
54     def getparam(self, key):
55         if key in self.params:
56             return self.params[key][0]
57         else:    
58             return None
59                                             
60