Skip to content

gh-132719: Skip multiprocessing test if missing ctypes #132842

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

Merged
merged 1 commit into from
Apr 23, 2025

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Apr 23, 2025

Skip test_lock_locked_2processes() if multiprocessing.sharedctypes is missing (need ctypes).

Skip test_lock_locked_2processes() if multiprocessing.sharedctypes is
missing (need ctypes).
@vstinner
Copy link
Member Author

Example of error: https://buildbot.python.org/#/builders/1232/builds/5434

ERROR: test_rlock_locked_2processes (test.test_multiprocessing_forkserver.test_processes.WithProcessesTestLock.test_rlock_locked_2processes)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.opsec-fbsd14/build/Lib/test/_test_multiprocessing.py", line 1609, in test_rlock_locked_2processes
    res = self.Value('b', 0)
  File "/home/buildbot/buildarea/3.x.opsec-fbsd14/build/Lib/multiprocessing/context.py", line 134, in Value
    from .sharedctypes import Value
  File "/home/buildbot/buildarea/3.x.opsec-fbsd14/build/Lib/multiprocessing/sharedctypes.py", line 10, in <module>
    import ctypes
  File "/home/buildbot/buildarea/3.x.opsec-fbsd14/build/Lib/ctypes/__init__.py", line 8, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@vstinner vstinner enabled auto-merge (squash) April 23, 2025 14:25
@vstinner
Copy link
Member Author

vstinner commented Apr 23, 2025

I also contacted the FreeBSD buildbot owner to ask him if he can install libffi (ctypes dependency).

@vstinner vstinner merged commit b2e666f into python:main Apr 23, 2025
48 checks passed
@vstinner vstinner deleted the sharedctypes branch April 23, 2025 14:36
vstinner added a commit to vstinner/cpython that referenced this pull request Apr 23, 2025
…132842)

Skip test_rlock_locked_2processes() if multiprocessing.sharedctypes
is missing (need ctypes).
@vstinner
Copy link
Member Author

Oh no, I missed the rlock test: I wrote #132846 to skip also the rlock test.

@YvesDup
Copy link
Contributor

YvesDup commented Apr 23, 2025

@unittest.skipUnless(HAS_SHAREDCTYPES, 'needs sharedctypes') should also apply to test_rlock_locked_2processes

I can rewrite these tests without self.value variable ?

@vstinner
Copy link
Member Author

I can rewrite these tests without self.value variable ?

It seems safer to always use self.Value, no?

@YvesDup
Copy link
Contributor

YvesDup commented Apr 23, 2025

It seems safer to always use self.Value, no?

I can use a multiprocessing.Manager().list() to avoid ctypes.

@vstinner
Copy link
Member Author

vstinner commented Apr 23, 2025

Ah, I understood that you asked to choice between Value and self.Value.

@YvesDup
Copy link
Contributor

YvesDup commented Apr 23, 2025

I understand that there are 2 problems when HAS_SHAREDCTYPES is False.

  1. You can't use Value but only self.Value.
  2. you can't use ctypes as the first argument of [self.]Value.

That's why I suggest using a list from multiprocessing.Manager.

@vstinner
Copy link
Member Author

It's ok to skip tests when ctypes is missing. Ctypes should be available most of the time.

@vstinner
Copy link
Member Author

I merged my PR to skip rlock test to repair FreeBSD buildbots, but feel free to propose a PR if you want to avoid ctypes in the tests.

@YvesDup
Copy link
Contributor

YvesDup commented Apr 23, 2025

I merged my PR to skip rlock test to repair FreeBSD buildbots, but feel free to propose a PR if you want to avoid ctypes in the tests.

It is okay for to skip these test. Thank for the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants