Skip to content
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

Peiyu/fix engine unpickling bug #3261

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/python/pants/engine/exp/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)

import cPickle as pickle
import functools
import logging
import multiprocessing
Expand All @@ -21,12 +22,6 @@
from pants.util.objects import datatype


try:
import cPickle as pickle
except ImportError:
import pickle


logger = logging.getLogger(__name__)


Expand Down
7 changes: 4 additions & 3 deletions src/python/pants/engine/exp/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
unicode_literals, with_statement)

import cPickle as pickle
import cStringIO as StringIO
import sys
from abc import abstractmethod
from binascii import hexlify
from collections import Counter
from contextlib import closing
from functools import total_ordering
from hashlib import sha1
from io import BytesIO
from StringIO import StringIO
from struct import Struct as StdlibStruct

import lmdb
Expand Down Expand Up @@ -166,7 +167,7 @@ def put(self, obj):
Longer term see https://github.com/pantsbuild/pants/issues/2969
"""
try:
with closing(StringIO.StringIO()) as buf:
with closing(BytesIO()) as buf:
pickler = pickle.Pickler(buf, protocol=self._protocol)
pickler.fast = 1
pickler.dump(obj)
Expand Down Expand Up @@ -493,7 +494,7 @@ def get(self, key):
with self._env.begin(db=self._db, buffers=True) as txn:
value = txn.get(key)
if value is not None:
return StringIO.StringIO(value)
return StringIO(value)
return None

def put(self, key, value):
Expand Down
2 changes: 0 additions & 2 deletions tests/python/pants_test/engine/exp/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def test_serial_engine_simple(self):
engine = LocalSerialEngine(self.scheduler, self.storage, self.cache)
self.assert_engine(engine)

@unittest.skip('https://github.com/pantsbuild/pants/issues/3149')
def test_multiprocess_engine_multi(self):
with self.multiprocessing_engine() as engine:
self.assert_engine(engine)
Expand All @@ -62,7 +61,6 @@ def test_multiprocess_unpickleable(self):
with self.assertRaises(SerializationError):
engine.execute(build_request)

@unittest.skip('https://github.com/pantsbuild/pants/issues/3149')
def test_rerun_with_cache(self):
with self.multiprocessing_engine() as engine:
self.assert_engine(engine)
Expand Down