Comments (4)
Are you aiming to reach any parallelism in here or is just for isolation purposes? In other words: is this a sequential operation ran in another process or do you need to split it into parallel computations?
from pebble.
from pebble.
I see what you mean and I think it's a pretty interesting feature. I am currently deep into another thing so I will start working on this a bit later (beginning of June?). Ofc pull requests are welcome.
In the meantime, you can use this code snippet as a reference for implementing such functionality in your application.
from pebble import concurrent
from multiprocessing import Queue
@concurrent.process(timeout=60)
def process_url(queue, url):
"""Processes a URL splitting the report in chunks and putting it in the given Queue."""
for chunk in process(url):
queue.put(chunk)
def process(url):
"""A function seemingly producing large data split in chunks."""
while True:
yield None
queue = Queue()
future = process_url(queue, "www.example.com")
while not future.done():
chunk = queue.get()
if future.exception() is not None:
print("Error while processing the URL")
from pebble.
Ah! I like the trick of using a queue!
The example code looks good and is a good inspiration for writing the PR. Depending on my client's needs, I might be writing the PR before June.
What about the interface? Do you think we should have two new methods in ProcessPool?
- schedule_generator()
- map_generator()
Both of them returning a tuple with future
and generator
? The generator would be a wrapper around the queue that people could use like this:
future, generator = pool.schedule_generator(function)
for result in generator:
print(result)
# Do some future error handling here
from pebble.
Related Issues (20)
- Pebble wheels pushed to PyPI are incorrectly tagged HOT 3
- The timeout argument of ProcessPool().submit() is inconsistent with ThreadPool().submit() HOT 3
- Bug: new `submit` function makes it impossible to call a function that has a `timeout` argument HOT 6
- Logging process name inside concurrent.process HOT 2
- How to handle errors when using pool.schedule HOT 1
- shutdown of main program HOT 2
- @concurrent.process returned future blocks/hangs on running(), cancelled(), done() calls HOT 2
- Get information about broken process HOT 4
- Documentation for Pebble indicates threads created with a ThreadPool are cancellable HOT 1
- Channel mutex timeout HOT 6
- How can I use a multiprocessing.manager alongside with pebble to avoid re-importing the function everytime? HOT 1
- Type hint error of wrapped function HOT 7
- ISSUE with with ProcessPool when scheduled function return exception (not raise it) HOT 1
- BUG with ProcessPool when scheduled function raise BaseException HOT 1
- issue with handling frozen exceptions in worker thread or process HOT 1
- Cannot create pebble.ProcessPool() multiple times within a single run, all task got stuck and time out HOT 3
- error while running @concurrent.process repetitively HOT 4
- using multiprocess context (for dill support) no longer working HOT 2
- Workers using 100% CPU not getting killed after timeout HOT 11
- Behavior of Process.map with chunksize > 1 and a timeout HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pebble.