-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asyncio_task example fails on Jupyter Notebook #26
Comments
Can you send an example code? |
I just used the example from your website.
|
Thanks, I'll add a test for this and try to fix the issue. |
Seems to be working in import pypeln as pl
import asyncio
from random import random
async def slow_add1(x):
await asyncio.sleep(random()) # <= some slow computation
return x + 1
async def slow_gt3(x):
await asyncio.sleep(random()) # <= some slow computation
return x > 3
data = range(10) # [0, 1, 2, ..., 9]
stage = pl.task.map(slow_add1, data, workers=3, maxsize=4)
stage = pl.task.filter(slow_gt3, stage, workers=2)
data = list(stage) # e.g. [5, 6, 9, 4, 8, 10, 7] |
Thanks a lot, it works like a charm. Btw, the new API looks a lot cleaner now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe pypeln interferes with Jupyters own event loop, maybe I did something wrong. Do you have any idea?
RuntimeError: Task <Task pending coro=<_run_task() running at /opt/conda/lib/python3.7/site-packages/pypeln/asyncio_task.py:203> cb=[gather.<locals>._done_callback() at /opt/conda/lib/python3.7/asyncio/tasks.py:691]> got Future <Future pending> attached to a different loop
The text was updated successfully, but these errors were encountered: