#!/usr/bin/env python3
import logging; logging.basicConfig(level=logging.INFO)
import asyncio, os, json, time
from datetime import datetime
from aiohttp import web
def index(request):
return web.Response(body=b'<h1>Awesome</h1>')
@asyncio.coroutine
def init(loop):
app = web.Application(loop=loop)
app.router.add_route('GET', '/', index)
srv = yield from loop.create_server(app.make_handler(), '127.0.0.1', 9000)
logging.info('server started at http://127.0.0.1:9000...')
return srv
loop = asyncio.get_event_loop()
loop.run_until_complete(init(loop))
loop.run_forever()
处理(28411)开始...... I(28411)刚刚创建了子进程(28412) . 我是子进程(28412),我的父进程是28411. Traceback(最近一次调用最后一次):文件“webApp.py”,第5行,导入asyncio,os,json,time文件“/Library/Frameworks/Python.framework /Versions/3.4/lib/python3.4/asyncio/init.py“,第21行,在Traceback中(最近一次调用最后一次):文件”webApp.py“,第5行,导入asyncio,os,json,time文件“/ Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/init.py”,第21行,来自.base_events import *文件“/Library/Frameworks/Python.framework/Versions/3.4 /lib/python3.4/asyncio/base_events.py“,第18行,来自.base_events import *文件”/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/base_events.py“ ,第18行,在import concurrent.futures文件“/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/concurrent/futures/init.py”,第17行,在import concurrent.futures文件中“/ Library / Frameworks / Python.framework / Versions / 3.4 / lib / python3.4 / concurrent / futures / init.py“,第17行,来自concurrent.f utures.process导入ProcessPoolExecutor文件“/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/concurrent/futures/process.py”,第54行,来自concurrent.futures.process import ProcessPoolExecutor File“/库/ Frameworks / Python.framework / Versions / 3.4 / lib / python3.4 / concurrent / futures / process.py“,第54行,来自多处理导入SimpleQueue来自多处理导入SimpleQueue ImportError:无法导入名称'SimpleQueue'ImportError:不能导入名称'SimpleQueue'
1 回答
simpleQueue的API似乎已经改变了 .
在python3.3中,它在
multiprocessing.SimpleQueue
中找到(参见doc 1)在python3.2中,它在
multiprocessing.queues.SimpleQueue
中找到(参见doc 2)您可能运行的是早于3.2的python版本,但代码是为较新版本(> = 3.3)编写的 . 您可以尝试修改库以使用旧的导入或升级您的python版本 .