mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
multiproc threads start now
This commit is contained in:
parent
d7f8dbd966
commit
b885c62bbb
@ -8,6 +8,7 @@ import time
|
|||||||
import shutil
|
import shutil
|
||||||
import threading
|
import threading
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
import time
|
||||||
import cPickle as pickle
|
import cPickle as pickle
|
||||||
# Import zeromq
|
# Import zeromq
|
||||||
import zmq
|
import zmq
|
||||||
@ -138,6 +139,7 @@ class ReqServer():
|
|||||||
m_worker.start()
|
m_worker.start()
|
||||||
|
|
||||||
out_socket = self.context.socket(zmq.REQ)
|
out_socket = self.context.socket(zmq.REQ)
|
||||||
|
out_socket.connect('tcp://127.0.0.1:' + str(work_port))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
package = in_socket.recv()
|
package = in_socket.recv()
|
||||||
@ -154,9 +156,10 @@ class ReqServer():
|
|||||||
|
|
||||||
self.workers.bind(self.w_uri)
|
self.workers.bind(self.w_uri)
|
||||||
|
|
||||||
for ind in range(int(self.num_threads)):
|
|
||||||
proc = threading.Thread(target=lambda: self.__worker(ind))
|
for ind in range(int(self.opts['worker_threads'])):
|
||||||
proc.start()
|
threading.Thread(target=lambda: self.__worker(ind)).start()
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
zmq.device(zmq.QUEUE, self.clients, self.workers)
|
zmq.device(zmq.QUEUE, self.clients, self.workers)
|
||||||
|
|
||||||
@ -188,7 +191,7 @@ class MWorker(multiprocessing.Process):
|
|||||||
'''
|
'''
|
||||||
context = zmq.Context(1)
|
context = zmq.Context(1)
|
||||||
socket = context.socket(zmq.REP)
|
socket = context.socket(zmq.REP)
|
||||||
socket.bind('tcp://localhost:' + self.port)
|
socket.bind('tcp://127.0.0.1:' + self.port)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
package = socket.recv()
|
package = socket.recv()
|
||||||
@ -409,4 +412,4 @@ class MWorker(multiprocessing.Process):
|
|||||||
'''
|
'''
|
||||||
Start a Master Worker
|
Start a Master Worker
|
||||||
'''
|
'''
|
||||||
pass
|
self.__bind()
|
||||||
|
Loading…
Reference in New Issue
Block a user