fork download
  1. import asyncio
  2.  
  3.  
  4. async def worker(request, result):
  5.  
  6. while True:
  7.  
  8. data = await request.get()
  9. print("worker", data)
  10. await asyncio.sleep(0.1)
  11. await result.put(str.upper(data))
  12.  
  13.  
  14. async def yoba():
  15.  
  16. request = asyncio.Queue()
  17. result = asyncio.Queue()
  18.  
  19. workers = [loop.create_task(worker(request, result)) for _ in range(5)]
  20.  
  21. for i in range(15):
  22.  
  23. await request.put(str.format("yoba {}", i))
  24.  
  25. while True:
  26.  
  27. data = await result.get()
  28. print("yoba", data)
  29.  
  30.  
  31. if __name__ == "__main__":
  32.  
  33. loop = asyncio.get_event_loop()
  34. loop.run_until_complete(yoba())
  35.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "/usr/lib/python3.4/py_compile.py", line 124, in compile
    _optimize=optimize)
  File "<frozen importlib._bootstrap>", line 1532, in source_to_code
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "./prog.py", line 4
    async def worker(request, result):
            ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.4/py_compile.py", line 128, in compile
    raise py_exc
py_compile.PyCompileError:   File "./prog.py", line 4
    async def worker(request, result):
            ^
SyntaxError: invalid syntax

stdout
Standard output is empty