⇤ ← Revision 1 as of 2008-08-24 12:14:17
Size: 3487
Comment:
|
Size: 3548
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 8: | Line 8: |
SEE:'''[KarriGell Karigell~最易用的Web应用框架!]''' = Karrigell 多线程增强 = |
|
Line 9: | Line 11: |
= Karrigell 多线程增强 = |
SEE:[KarriGell Karigell~最易用的Web应用框架!]
Karrigell 多线程增强
ccnusjy <[email protected]> reply-to [email protected] to karrigell <[email protected]> date Sat, Aug 23, 2008 at 18:14
subject [karrigell] [https://groups.google.com/group/karrigell/browse_thread/thread/c2c949b04e0f95cd Karrigell + PyProcessing,Very good and Strong!]
PyProcessing 本质增强
1 import os
2 import traceback
3 import sys
4
5 import KarrigellRequestHandler
6 import k_config, k_utils
7 import webservers.SimpleAsyncHTTPServer as Server
8 from processing import Process, currentProcess, freezeSupport
9 if sys.platform == 'win32':
10 import processing.reduction # make sockets pickable/inheritable
11
12 class
13 asyncRequestHandler(KarrigellRequestHandler.KarrigellRequestHandler,
14 Server.DialogManager):
15
16 def handle_data(self):
17
18 KarrigellRequestHandler.KarrigellRequestHandler.handle_data(self)
19
20 def send_error(self, code, message=None):
21
22 KarrigellRequestHandler.KarrigellRequestHandler.send_error(self,
23 code,message)
24
25 def handle_error(self):
26 traceback.print_exc(file=sys.stderr)
27
28 def kkk_serve(s):
29 #print k_config.silent
30 #if k_config.silent:
31 sys.stdout = k_utils.silent()
32 sys.stderr = k_utils.silent()
33 try:
34 s.loop()
35 except KeyboardInterrupt:
36 s.close_all()
37 k_utils.trace("Ctrl+C pressed. Shutting down.")
38
39 def main_start():
40 # Launch the server
41 port = 8086
42 process_num = 3
43
44 s = Server.Server(('localhost',port),asyncRequestHandler)
45
46 print "Karrigell %s running on port %s" %
47 (KarrigellRequestHandler.__version__,
48 port)
49 print "Press Ctrl+C to stop"
50
51 for i in range(process_num):
52 child = Process(target=kkk_serve, args=(s,))
53 child.setDaemon(True)
54 child.start()
55
56 kkk_serve(s)
57
58 if __name__ == '__main__':
59 if sys.platform == 'win32':
60 freezeSupport()
61 main_start()
增强使用说明
Hi, you can put the script above to a file called Karrgiell_multiprocess.py , and then double click it to run Karrigell Server with many process instances which are all running at the same tcp port. As we all know, Karrigell handle custom's request one by one, so one a long-running script is executing, other request seams to be blocked . Now, there is no problem about that with the power of pyprocessing > def main_start(): > # Launch the server > port = 8086 #~~~~~~~~~~~~~~ ,here is the port your server will listen to > process_num = 3 #~~~~~~~~~~~~~~, here is how many process instances to serve > > s = Server.Server(('localhost',port),asyncRequestHandler)
同类选择
Graham Dumpleton <[email protected]> reply-to [email protected] to karrigell <[email protected]> date Sun, Aug 24, 2008 at 14:07 subject [karrigell] Re: Karrigell + PyProcessing,Very good and Strong!
You are aware you can get multiprocess Karrigell by using mod_wsgi?
反馈
创建 by -- ZoomQuiet [DateTime(2008-08-24T12:14:17Z)]