Coder Social home page Coder Social logo

Comments (3)

ross avatar ross commented on August 19, 2024

cool. i'll take a look at this when i get a chance now that support is there.

from requests-futures.

ross avatar ross commented on August 19, 2024

after looking at this the Response object isn't the only problem. the instance method on the session object (Session.request) cannot be pickled and sent across to the ProcessPoolExecutor nor can the wrapper if a background_callback was provided.

it would be nice to be able to support it, but it looks like the Request object fix just kicked the problem down the road a bit.

i'm not familar enough with ProcessPoolExector & pickling to know what's required to solve the problem and won't have the time in the near future to look in to it. happy to accept patches, but otherwise this is likely to sit for a whlie.

from requests-futures.

asfaltboy avatar asfaltboy commented on August 19, 2024

Rant

Hello guys, personally would find it very useful to opt for a ProcessPoolExecutor. I have a project where I'm executing many requests that return very big JSON responses.

In my use case, the way memory allocation in python works makes those big JSON strings eat up a huge amount of system memory, which does not get released to OS even if I periodically shutdown the executor and force garbage collection. Using processes here would make the solution trivial since we would cycle processes instead of threads, releasing memory when each process finishes.

Solution for pickling

It seems session.request "pickles" just fine today, and as for the callback function, it seems using functools.partial would do the trick. The only requirement for pickling the "partial" callback, is to make it an importable (i.e top level) function. Here is a working POC: https://gist.github.com/asfaltboy/ba33885f7fe08012d79b

P.s: I've added a PR (with tests 🎉) #31. Further discussion on that implementation is there.

from requests-futures.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.