- 论坛徽章:
- 1
|
打算每来一个请求,运行一个新开一个进程处理。我简化了一下程序
不知为什么错误,错误莫名其妙的。
- def fun(num):
- print "OK!!!\n"+num
- HOST = '' #允许任何ip访问此服务器
- PORT = 21888 #运行服务程序的端口
- BUFSIZ = 1024
- ADDR = (HOST,PORT)
- tcpSerSock = socket(AF_INET,SOCK_DGRAM)
- tcpSerSock.bind(ADDR)
- while True:
- print 'waiting for client connection...\n'
- data,addr = tcpSerSock.recvfrom(BUFSIZ)
- process = multiprocessing.Process(target=fun,args=(1,))//这行错误
- process.start()
-
-
复制代码 但是这么一个 程序是正确的,不知道是为什么:- import multiprocessing
- import time
- def clock(interval):
- while True:
- print("The time is {0}".format(time.ctime()))
- time.sleep(interval)
- p = multiprocessing.Process(target=clock, args=(15,))
- p.start()
复制代码 |
|