mirror of
				https://github.com/jumpserver/jumpserver.git
				synced 2025-11-03 23:47:27 +00:00 
			
		
		
		
	fix: 修复数据库连接没有关闭的问题
This commit is contained in:
		@@ -2,6 +2,7 @@ import threading
 | 
				
			|||||||
import json
 | 
					import json
 | 
				
			||||||
from redis.exceptions import ConnectionError
 | 
					from redis.exceptions import ConnectionError
 | 
				
			||||||
from channels.generic.websocket import JsonWebsocketConsumer
 | 
					from channels.generic.websocket import JsonWebsocketConsumer
 | 
				
			||||||
 | 
					from django.db import close_old_connections
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from common.utils import get_logger
 | 
					from common.utils import get_logger
 | 
				
			||||||
from .site_msg import SiteMessageUtil
 | 
					from .site_msg import SiteMessageUtil
 | 
				
			||||||
@@ -65,8 +66,11 @@ class SiteMsgWebsocket(JsonWebsocketConsumer):
 | 
				
			|||||||
                    logger.debug('Decode json error: ', e)
 | 
					                    logger.debug('Decode json error: ', e)
 | 
				
			||||||
        except ConnectionError:
 | 
					        except ConnectionError:
 | 
				
			||||||
            logger.debug('Redis chan closed')
 | 
					            logger.debug('Redis chan closed')
 | 
				
			||||||
 | 
					        finally:
 | 
				
			||||||
 | 
					            close_old_connections()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def disconnect(self, close_code):
 | 
					    def disconnect(self, close_code):
 | 
				
			||||||
        if self.chan is not None:
 | 
					        if self.chan is not None:
 | 
				
			||||||
            self.chan.close()
 | 
					            self.chan.close()
 | 
				
			||||||
        self.close()
 | 
					        self.close()
 | 
				
			||||||
 | 
					        close_old_connections()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user