Differences between revisions 3 and 4
Revision 3 as of 2008-08-24 12:15:30
Size: 3553
Editor: ZoomQuiet
Comment:
Revision 4 as of 2008-08-24 14:14:47
Size: 4342
Editor: ZoomQuiet
Comment:
Deletions are marked like this. Additions are marked like this.
Line 110: Line 110:
=== 特别修订 ===
`modification of a Karrigell's file "core/k_config.py".`:
{{{
in line 44:

try:
   _opts, _args = getopt.getopt(sys.argv[1:], "hP:L:SR",['processing-
fork'])

#~~~~~~~~~~~~~ here
   print _opts,_args
except getopt.GetoptError:
   # print usage information and exit:
   usage()
   raise
}}}
 * I am not familiar with pyprocessing, I found that the child process
forked lost the arguments of their parent process, and they had their
own arguments in sys.argv ('processing-fork' and a process id).

 * However, it's an ugly way to solve the problem. If some one has better
idea, tell me please.
Line 111: Line 134:
{{{
ccnusjy <[email protected]>
reply-to [email protected]
to karrigell <[email protected]>
date Sun, Aug 24, 2008 at 22:08
}}}

TableOfContents

Include(ZPyUGnav)

SEE:[wiki:KarriGell Karigell~最易用的Web应用框架!]

Karrigell 多线程增强

ccnusjy <[email protected]>
reply-to        [email protected]
to      karrigell <[email protected]>
date    Sat, Aug 23, 2008 at 18:14

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)

特别修订

modification of a Karrigell's file "core/k_config.py".:

in line 44:

try:
   _opts, _args = getopt.getopt(sys.argv[1:], "hP:L:SR",['processing-
fork'])

#~~~~~~~~~~~~~ here
   print _opts,_args
except getopt.GetoptError:
   # print usage information and exit:
   usage()
   raise
  • I am not familiar with pyprocessing, I found that the child process

forked lost the arguments of their parent process, and they had their own arguments in sys.argv ('processing-fork' and a process id).

  • However, it's an ugly way to solve the problem. If some one has better

idea, tell me please.

同类选择

ccnusjy <[email protected]>
reply-to        [email protected]
to      karrigell <[email protected]>
date    Sun, Aug 24, 2008 at 22:08

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)]

PageComment2

[:/PageCommentData:PageCommentData]

KarrigellWithPyProcessingVeryGoodStrong (last edited 2009-12-25 07:11:09 by localhost)