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

Multiprocessing cleanup broken upgrading to pyfakefs 3.4 #356

Closed
mjstevens777 opened this issue Mar 15, 2018 · 5 comments
Closed

Multiprocessing cleanup broken upgrading to pyfakefs 3.4 #356

mjstevens777 opened this issue Mar 15, 2018 · 5 comments
Labels

Comments

@mjstevens777
Copy link

My tests are failing with the error:

Traceback (most recent call last):
  File "/mycode.py", line 123, in myfunction
    myvar = multiprocessing.Value('I', 0)
  File "/pyenv/versions/3.6.1/lib/python3.6/multiprocessing/context.py", line 135, in Value
    ctx=self.get_context())
  File "/pyenv/versions/3.6.1/lib/python3.6/multiprocessing/sharedctypes.py", line 73, in Value
    obj = RawValue(typecode_or_type, *args)
  File "/pyenv/versions/3.6.1/lib/python3.6/multiprocessing/sharedctypes.py", line 48, in RawValue
    obj = _new_value(type_)
  File "/pyenv/versions/3.6.1/lib/python3.6/multiprocessing/sharedctypes.py", line 40, in _new_value
    wrapper = heap.BufferWrapper(size)
  File "/pyenv/versions/3.6.1/lib/python3.6/multiprocessing/heap.py", line 248, in __init__
    block = BufferWrapper._heap.malloc(size)
  File "/pyenv/versions/3.6.1/lib/python3.6/multiprocessing/heap.py", line 230, in malloc
    (arena, start, stop) = self._malloc(size)
  File "/pyenv/versions/3.6.1/lib/python3.6/multiprocessing/heap.py", line 128, in _malloc
    arena = Arena(length)
  File "/pyenv/versions/3.6.1/lib/python3.6/multiprocessing/heap.py", line 70, in __init__
    os.unlink(name)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pymp-5pu7zmg8/pym-935-mbldww9n'

The tests that are failing do not use the pyfakefs library. If I do pip install pyfakefs==3.3 my errors go away, so it looks like something about the upgrade to 3.4 broke my tests. Do you have any idea what the error might be or how to get more information?

I am running on python 3.6, ubuntu 16.04, inside a docker container. I am using the multiprocessing package from pytorch instead of the standard library, but it doesn't look like that's where the failure is coming from.

@mjstevens777
Copy link
Author

mjstevens777 commented Mar 15, 2018

I can recreate the issue with this:

import unittest
import multiprocessing
from pyfakefs.fake_filesystem_unittest import Patcher

class TestMultiprocessing(unittest.TestCase):

    def test_fakefs(self):
        with Patcher() as patcher:
            patcher.fs.CreateFile('/mytempfile', contents='abcd')

    def test_value(self):
        v = multiprocessing.Value('I', 0)
        self.assertEqual(v.value, 0)

if __name__ == '__main__':
    unittest.main()

@mrbean-bremen
Copy link
Member

Thanks for the report - I will have a look in the evening. Must be some side effect / missing cleanup in the dynamic patcher...

mrbean-bremen added a commit that referenced this issue Mar 15, 2018
- avoids them to still reference the fake file system
- see #356
@mrbean-bremen
Copy link
Member

Ok, found the problem - there was indeed a missing cleanup in the dynamic patcher for reloaded modules. @mjstevens777 - please check if your problem is fixed in master now.
As this is actually a severe regression, I think about making a bug fix release after waiting a few days, in case more problems with the release show up.

@mjstevens777
Copy link
Author

Thanks for the quick fix! The master branch is working for me now.

@mrbean-bremen
Copy link
Member

Thanks for the report! I will make a bug fix release in about a week, if nothing else comes up.

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

No branches or pull requests

2 participants