Closed asfaltboy closed 8 years ago
Sorry for the slow response. Super busy at work as of late. Looks pretty good. Few small comments inline.
No problemo. I added an exception, some documentation and updated tests. Unfortunately, the README.rst
does not render so well in GitHub, so feel free to style the doc to your liking.
Thanks.
Change Summary
functools.partial
instead of directly wrapping therequest
method, regardless of executor used - avoid code branchingfunctools.partial(Session.request, self)
instead ofsuper(FuturesSession, self).request
for pickling, again no code branchingNotes / Limitations
copy_reg
to add this support to Python 2.pickle
related issues fixed in 3.5.ProcessPoolExecutor
but only when the callback also modifies__attrs__
so it gets pickled and sent to parent process (see an example for that in the tests).background_callback
MUST be a top-level (or otherwise importable) object. Additionally, since an instance ofFuturesSession
is passed to the callback (asself
), it too must be importable, otherwisepickle
will complain.Conclusions
This relatively simple implementation fixes issue #11, however due to numerous caveats, I'd suggest we recommend it be used in Python 3.5 and above and explain the limitation of earlier versions. If earlier versions (like Python 2) are really required by someone they may need to implement a manual fix to the
pickle
implementation (e.g usingcopy_reg
).Personally, this PR solves my issue but I have yet to test it on production, hopefully, will do so in the near future.