作者 陈俊学

增加change线程锁

@@ -4,5 +4,5 @@ SERVER: @@ -4,5 +4,5 @@ SERVER:
4 reconnect_interval: 3 4 reconnect_interval: 3
5 5
6 VERSION: 6 VERSION:
7 - code: 90  
8 - name: 2.0.0  
  7 + code: 91
  8 + name: 2.0.1
@@ -49,6 +49,7 @@ class Monitor(callback.CallBack): @@ -49,6 +49,7 @@ class Monitor(callback.CallBack):
49 self.executor = ThreadPoolExecutor(100, 'task_thread') 49 self.executor = ThreadPoolExecutor(100, 'task_thread')
50 self.init_config = {} 50 self.init_config = {}
51 self.queue = None 51 self.queue = None
  52 + self.changeLock = threading.Lock()
52 53
53 def bind(self): 54 def bind(self):
54 models.Config.set('host', Client.target_server) 55 models.Config.set('host', Client.target_server)
@@ -85,6 +86,8 @@ class Monitor(callback.CallBack): @@ -85,6 +86,8 @@ class Monitor(callback.CallBack):
85 return client.info() 86 return client.info()
86 else: 87 else:
87 try: 88 try:
  89 + self.onChangEnv(email, 'waiting', '排队中')
  90 + self.changeLock.acquire(timeout=120) # 设置超时释放时间为120秒
88 self.changeingIn(email) # 转环境的话清理缓存 91 self.changeingIn(email) # 转环境的话清理缓存
89 result, email, password, cookie, user_agent = self.selenium_login(email, password, cookie) 92 result, email, password, cookie, user_agent = self.selenium_login(email, password, cookie)
90 if result: 93 if result:
@@ -93,6 +96,8 @@ class Monitor(callback.CallBack): @@ -93,6 +96,8 @@ class Monitor(callback.CallBack):
93 except Exception as err: 96 except Exception as err:
94 self.onChangEnv(email, 'changeError', str(err)) 97 self.onChangEnv(email, 'changeError', str(err))
95 raise err 98 raise err
  99 + finally:
  100 + self.changeLock.release()
96 101
97 def login(self, email, password, cookie=None, user_agent=None, proxy=None): 102 def login(self, email, password, cookie=None, user_agent=None, proxy=None):
98 limit = 100 103 limit = 100
@@ -69,7 +69,7 @@ else @@ -69,7 +69,7 @@ else
69 echo "" >log/fbchat.log 69 echo "" >log/fbchat.log
70 70
71 python3 setup.py #安装依赖库 71 python3 setup.py #安装依赖库
72 - echo '安装Socket5代理' 72 +# echo '安装Socket5代理'
73 # wget --no-check-certificate https://raw.github.com/Lozy/danted/master/install.sh -O install_proxy.sh 73 # wget --no-check-certificate https://raw.github.com/Lozy/danted/master/install.sh -O install_proxy.sh
74 # bash install_proxy.sh --port=59395 --user=ntkj --passwd=nantian888 74 # bash install_proxy.sh --port=59395 --user=ntkj --passwd=nantian888
75 if [ ! -d /home/project/facebookchat/db/versions ]; then 75 if [ ! -d /home/project/facebookchat/db/versions ]; then