[engine] bug fix: to pickle/unpickle within the proper context

Review Request #3761 — Created April 26, 2016 and submitted — Latest diff uploaded

3149, 3274
jsirois, kwlzn, patricklaw, stuhood

We have two places that pickle and unpickle functions are not used within
the proper context.

  • StringIO buffer for write, saving buffer to storage happens outside its context.
  • lmdb buffer for read, the invalid buffer was used outside transction context.

The earlier attemp is probably red herring: https://rbcommons.com/s/twitter/r/3751/.
Thanks Stu for catching!

These two behaviors are clearly documented, see [1] and [2].
[1] https://docs.python.org/2/library/stringio.html
[2] https://lmdb.readthedocs.org/en/release/

https://travis-ci.org/peiyuwang/pants/builds/125890340 passed.
https://travis-ci.org/peiyuwang/pants/builds/125941151 passed.