Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

"can't pickle _thread.lock" in ResumableDatasetLoop with SubprocessRunner in Python 3 #57

Open
TaiSakuma opened this issue Mar 17, 2019 · 1 comment

Comments

@TaiSakuma
Copy link
Member

at 8db62fc, a few commits after v0.24.2

Traceback (most recent call last):
  File "./bdphi-scripts/bdphiROC/twirl_mktbl_heppy.py", line 721, in <module>
    main()
  File "./bdphi-scripts/bdphiROC/twirl_mktbl_heppy.py", line 62, in main
    run(reader_collector_pairs)
  File "./bdphi-scripts/bdphiROC/twirl_mktbl_heppy.py", line 609, in run
    treeName='tree'
  File "./bdphi-scripts/external/atheppy/atheppy/fw.py", line 110, in run
    self._run(loop)
  File "./bdphi-scripts/external/atheppy/atheppy/fw.py", line 285, in _run
    loop()
  File "./bdphi-scripts/external/alphatwirl/alphatwirl/datasetloop/loop.py", line 60, in __call__
    pickle.dump(self.reader, f, protocol=pickle.HIGHEST_PROTOCOL)
TypeError: can't pickle _thread.lock objects

The error occures in ResumableDatasetLoop:

def __call__(self):
self.reader.begin()
for dataset in self.datasets:
self.reader.read(dataset)
path = os.path.join(self.workingarea.path, 'reader.p.gz')
with gzip.open(path, 'wb') as f:
pickle.dump(self.reader, f, protocol=pickle.HIGHEST_PROTOCOL)
return self.reader.end()

  • This happens only in Python 3, not in Python 2.7
  • This happens only in the parrallel mode subprocess, not in htcondor.

The proc in SubprocessRunner might not be picklable in Python 3:

proc = subprocess.Popen(
args,
stdout=subprocess.PIPE if self.pipe else None,
stderr=subprocess.PIPE if self.pipe else None,
cwd=taskdir
)
self.running_procs.append(proc)

  • can try to pickle before self.reader.read(dataset) or self.reader.begin()
@TaiSakuma
Copy link
Member Author

  • now pickle before start reading events 2eea376
  • this is not covered by unit tests

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant