本文整理匯總了Python中shadowsocks.shell.log_shadowsocks_version方法的典型用法代碼示例。如果您正苦於以下問題:Python shell.log_shadowsocks_version方法的具體用法?Python shell.log_shadowsocks_version怎麽用?Python shell.log_shadowsocks_version使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類shadowsocks.shell
的用法示例。
在下文中一共展示了shell.log_shadowsocks_version方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: thread_db
# 需要導入模塊: from shadowsocks import shell [as 別名]
# 或者: from shadowsocks.shell import log_shadowsocks_version [as 別名]
def thread_db(obj):
import socket
import time
global db_instance
timeout = 60
socket.setdefaulttimeout(timeout)
last_rows = []
db_instance = obj()
shell.log_shadowsocks_version()
try:
import resource
logging.info(
'current process RLIMIT_NOFILE resource: soft %d hard %d' %
resource.getrlimit(
resource.RLIMIT_NOFILE))
except:
pass
try:
while True:
load_config()
try:
db_instance.push_db_all_user()
rows = db_instance.pull_db_all_user()
db_instance.del_server_out_of_bound_safe(last_rows, rows)
db_instance.detect_text_ischanged = False
db_instance.detect_hex_ischanged = False
last_rows = rows
except Exception as e:
trace = traceback.format_exc()
logging.error(trace)
# logging.warn('db thread except:%s' % e)
if db_instance.event.wait(60) or not db_instance.is_all_thread_alive():
break
if db_instance.has_stopped:
break
except KeyboardInterrupt as e:
pass
db_instance.del_servers()
ServerPool.get_instance().stop()
db_instance = None
示例2: thread_db
# 需要導入模塊: from shadowsocks import shell [as 別名]
# 或者: from shadowsocks.shell import log_shadowsocks_version [as 別名]
def thread_db(obj):
import socket
import time
global db_instance
timeout = 60
socket.setdefaulttimeout(timeout)
last_rows = []
db_instance = obj()
ServerPool.get_instance()
shell.log_shadowsocks_version()
try:
import resource
logging.info('current process RLIMIT_NOFILE resource: soft %d hard %d' % resource.getrlimit(resource.RLIMIT_NOFILE))
except:
pass
try:
while True:
load_config()
db_instance.load_cfg()
try:
db_instance.push_db_all_user()
rows = db_instance.pull_db_all_user()
if rows:
db_instance.pull_ok = True
config = shell.get_config(False)
for port in config['additional_ports']:
val = config['additional_ports'][port]
val['port'] = int(port)
val['enable'] = 1
val['transfer_enable'] = 1024 ** 7
val['u'] = 0
val['d'] = 0
if "password" in val:
val["passwd"] = val["password"]
rows.append(val)
db_instance.del_server_out_of_bound_safe(last_rows, rows)
last_rows = rows
except Exception as e:
trace = traceback.format_exc()
logging.error(trace)
#logging.warn('db thread except:%s' % e)
if db_instance.event.wait(get_config().UPDATE_TIME) or not ServerPool.get_instance().thread.is_alive():
break
except KeyboardInterrupt as e:
pass
db_instance.del_servers()
ServerPool.get_instance().stop()
db_instance = None
示例3: thread_db
# 需要導入模塊: from shadowsocks import shell [as 別名]
# 或者: from shadowsocks.shell import log_shadowsocks_version [as 別名]
def thread_db(obj):
import socket
import time
import webapi_utils
global db_instance
global webapi
timeout = 60
socket.setdefaulttimeout(timeout)
last_rows = []
db_instance = obj()
webapi = webapi_utils.WebApi()
shell.log_shadowsocks_version()
try:
import resource
logging.info(
'current process RLIMIT_NOFILE resource: soft %d hard %d' %
resource.getrlimit(
resource.RLIMIT_NOFILE))
except:
pass
try:
while True:
load_config()
try:
ping = webapi.getApi('func/ping')
if ping is None:
logging.error(
'something wrong with your http api, please check your config and website status and try again later.')
else:
db_instance.push_db_all_user()
rows = db_instance.pull_db_all_user()
db_instance.del_server_out_of_bound_safe(
last_rows, rows)
last_rows = rows
except Exception as e:
trace = traceback.format_exc()
logging.error(trace)
# logging.warn('db thread except:%s' % e)
if db_instance.event.wait(60) or not db_instance.is_all_thread_alive():
break
if db_instance.has_stopped:
break
except KeyboardInterrupt as e:
pass
db_instance.del_servers()
ServerPool.get_instance().stop()
db_instance = None