2
votes
#!/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()

Process (28411) start... I (28411) just created a child process (28412). I am child process (28412) and my parent is 28411. Traceback (most recent call last): File "webApp.py", line 5, in import asyncio, os, json, time File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/init.py", line 21, in Traceback (most recent call last): File "webApp.py", line 5, in import asyncio, os, json, time File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/init.py", line 21, in from .base_events import * File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/base_events.py", line 18, in from .base_events import * File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/base_events.py", line 18, in import concurrent.futures File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/concurrent/futures/init.py", line 17, in import concurrent.futures File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/concurrent/futures/init.py", line 17, in from concurrent.futures.process import ProcessPoolExecutor File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/concurrent/futures/process.py", line 54, in from concurrent.futures.process import ProcessPoolExecutor File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/concurrent/futures/process.py", line 54, in from multiprocessing import SimpleQueue from multiprocessing import SimpleQueue ImportError: cannot import name 'SimpleQueue' ImportError: cannot import name 'SimpleQueue'

1
Can you import the multiprocessing library alone ? Can you run python3 -c "from multiprocessing import SimpleQueue" for instance ?Patrick
I can import the multiprocessing library alone, but I can't run python3 -c "from multiprocessing import SimpleQueue".thkkkkkkkk

1 Answers

2
votes

The API for simpleQueue seems to have changed.

In python3.3, it is found in multiprocessing.SimpleQueue (see the doc 1)

In python3.2, it is found in multiprocessing.queues.SimpleQueue (see the doc 2)

You probably run a version of python older than 3.2 but the code was written for a newer version (>= 3.3). You can try to modify the library to use the old import or upgrade your python version.