remove thread module
This commit is contained in:
parent
3e5cbb955e
commit
6f8fc5b77f
3 changed files with 21 additions and 5 deletions
12
server.py
12
server.py
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
import thread
|
import threading
|
||||||
import os
|
import os
|
||||||
os.chdir(os.path.split(os.path.realpath(__file__))[0])
|
os.chdir(os.path.split(os.path.realpath(__file__))[0])
|
||||||
|
|
||||||
|
@ -12,9 +12,17 @@ import db_transfer
|
||||||
# thread.start_new_thread(DbTransfer.thread_db, ())
|
# thread.start_new_thread(DbTransfer.thread_db, ())
|
||||||
# Api.web_server()
|
# Api.web_server()
|
||||||
|
|
||||||
|
class MainThread(threading.Thread):
|
||||||
|
def __init__(self):
|
||||||
|
threading.Thread.__init__(self)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
db_transfer.DbTransfer.thread_db()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
#server_pool.ServerPool.get_instance()
|
#server_pool.ServerPool.get_instance()
|
||||||
#server_pool.ServerPool.get_instance().new_server(2333, '2333')
|
#server_pool.ServerPool.get_instance().new_server(2333, '2333')
|
||||||
thread.start_new_thread(db_transfer.DbTransfer.thread_db, ())
|
thread = MainThread()
|
||||||
|
thread.start()
|
||||||
while True:
|
while True:
|
||||||
time.sleep(99999)
|
time.sleep(99999)
|
||||||
|
|
|
@ -29,13 +29,20 @@ from shadowsocks import eventloop
|
||||||
from shadowsocks import tcprelay
|
from shadowsocks import tcprelay
|
||||||
from shadowsocks import udprelay
|
from shadowsocks import udprelay
|
||||||
from shadowsocks import asyncdns
|
from shadowsocks import asyncdns
|
||||||
import thread
|
|
||||||
import threading
|
import threading
|
||||||
import sys
|
import sys
|
||||||
import asyncmgr
|
import asyncmgr
|
||||||
import Config
|
import Config
|
||||||
from socket import *
|
from socket import *
|
||||||
|
|
||||||
|
class MainThread(threading.Thread):
|
||||||
|
def __init__(self, params):
|
||||||
|
threading.Thread.__init__(self)
|
||||||
|
self.params = params
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
ServerPool._loop(*self.params)
|
||||||
|
|
||||||
class ServerPool(object):
|
class ServerPool(object):
|
||||||
|
|
||||||
instance = None
|
instance = None
|
||||||
|
@ -53,7 +60,8 @@ class ServerPool(object):
|
||||||
self.udp_ipv6_servers_pool = {}
|
self.udp_ipv6_servers_pool = {}
|
||||||
|
|
||||||
self.loop = eventloop.EventLoop()
|
self.loop = eventloop.EventLoop()
|
||||||
thread.start_new_thread(ServerPool._loop, (self.loop, self.dns_resolver, self.mgr))
|
thread = MainThread( (self.loop, self.dns_resolver, self.mgr) )
|
||||||
|
thread.start()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_instance():
|
def get_instance():
|
||||||
|
|
|
@ -74,7 +74,7 @@ def main():
|
||||||
(a_config['server'], int(port)))
|
(a_config['server'], int(port)))
|
||||||
tcp_servers.append(tcprelay.TCPRelay(a_config, dns_resolver, False))
|
tcp_servers.append(tcprelay.TCPRelay(a_config, dns_resolver, False))
|
||||||
udp_servers.append(udprelay.UDPRelay(a_config, dns_resolver, False))
|
udp_servers.append(udprelay.UDPRelay(a_config, dns_resolver, False))
|
||||||
if a_config['server_ipv6'] == "::":
|
if a_config['server_ipv6'] == b"::":
|
||||||
ipv6_ok = True
|
ipv6_ok = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
shell.print_exception(e)
|
shell.print_exception(e)
|
||||||
|
|
Loading…
Add table
Reference in a new issue