Skip to content

Conversation

@vstinner
Copy link
Member

@vstinnervstinner 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
MemberAuthor

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

@sobolevnsobolevn 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
Copy link
MemberAuthor

vstinner commented Apr 23, 2025

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

@vstinnervstinner merged commit b2e666f into python:mainApr 23, 2025
48 checks passed
@vstinnervstinner 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
MemberAuthor

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

@YvesDup
Copy link
Contributor

@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
MemberAuthor

I can rewrite these tests without self.value variable ?

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

@YvesDup
Copy link
Contributor

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

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

@vstinner
Copy link
MemberAuthor

vstinner commented Apr 23, 2025

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

@YvesDup
Copy link
Contributor

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
MemberAuthor

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

@vstinner
Copy link
MemberAuthor

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

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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip newstestsTests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@vstinner@YvesDup@sobolevn