Skip to content

Commit 7b4750e

Browse files
committed
merge upstream changes
1 parent 91b7584 commit 7b4750e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

python/pyspark/serializers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,11 @@ def __reduce__(self):
302302

303303
def _hijack_namedtuple():
304304
""" Hack namedtuple() to make it picklable """
305-
global _old_namedtuple # or it will put in closure
305+
# hijack only one time
306+
if hasattr(collections.namedtuple, "__hijack"):
307+
return
306308

309+
global _old_namedtuple # or it will put in closure
307310
def _copy_func(f):
308311
return types.FunctionType(f.func_code, f.func_globals, f.func_name,
309312
f.func_defaults, f.func_closure)
@@ -318,6 +321,7 @@ def namedtuple(name, fields, verbose=False, rename=False):
318321
collections.namedtuple.func_globals["_old_namedtuple"] = _old_namedtuple
319322
collections.namedtuple.func_globals["_hack_namedtuple"] = _hack_namedtuple
320323
collections.namedtuple.func_code = namedtuple.func_code
324+
collections.namedtuple.__hijack = 1
321325

322326
# hack the cls already generated by namedtuple
323327
# those created in other module can be pickled as normal,

0 commit comments

Comments
 (0)