???????????ж??????????????????????????????????????????????????????????????????????????????????????????????
????????3?? ????????
??????????????????????????python GIL?? ????????????Щ??????python GIL??????????????е??????????????????????????????????????????????????????????????????????д??????????????????????????????????CPU????????????????Linux?????top?????????us ????CPU??????sy????CPU????CPU???????????????????????????????????????????
import threading
class MultipleThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
while 1:
print "here"
for i in xrange(100):
multiple_thread=MultipleThread()
multiple_thread.start()
multiple_thread.join()
??????????GIL??????????????????????????????????Ч???????????????3-4??????????????????????????????2-3???????????????????????????????
???????????????????
?????????????????????????????????????????decode?? encode??????????????????????????????????????????????????????Queue???multiprocessing.Queue()??????????е?DiameterMsgParser(threading.Thread)???DiameterMsgParser(multiprocessing.Process)???и?????鷳????log???????python?????logging???????????д????????????????????????浥???????
import multiprocessing
import logging
class Worker(multiprocessing.Process):
def __init__(self??mp_name??input_queue):
multiprocessing.Process.__init__(self??name=mp_name)
self.input_queue=input_queue
def run(self):
for i in xrange(100):
self.input_queue.put_nowait(i)
logging.debug("test "+str(i))
??????????????????sunfire 4170 (16 core ?? 2.4G ) ????????5000 meesages (???)?? CPU????? 30-40%???????????python2.7???????solaris?????????pypy???????????????????в???pypy????????????????????2???linux?????????python?? pypy?????????????μ?Ч???pypy??Ч?????????д??????????????????? ??????CPU????????????????????