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
android: test_concurrent_futures fails #71111
Comments
test_concurrent_futures fails on an android emulator running an x86 system image at API level 21. There are multiple ERRORs, all resulting in the same traceback: Traceback (most recent call last):
File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_concurrent_futures.py", line 68, in setU
p
self.executor = self.executor_type(max_workers=self.worker_count)
File "/sdcard/org.bitbucket.pyona/lib/python3.6/concurrent/futures/process.py", line 390, in __init__
EXTRA_QUEUED_CALLS)
File "/sdcard/org.bitbucket.pyona/lib/python3.6/multiprocessing/context.py", line 101, in Queue
return Queue(maxsize, ctx=self.get_context())
File "/sdcard/org.bitbucket.pyona/lib/python3.6/multiprocessing/queues.py", line 42, in __init__
self._rlock = ctx.Lock()
File "/sdcard/org.bitbucket.pyona/lib/python3.6/multiprocessing/context.py", line 66, in Lock
return Lock(ctx=self.get_context())
File "/sdcard/org.bitbucket.pyona/lib/python3.6/multiprocessing/synchronize.py", line 163, in __in
it__
SemLock.__init__(self, SEMAPHORE, 1, 1, ctx=ctx)
File "/sdcard/org.bitbucket.pyona/lib/python3.6/multiprocessing/synchronize.py", line 60, in __ini
t__
unlink_now)
OSError: [Errno 38] Function not implemented The ERRORs: test_duplicate_futures (test.test_concurrent_futures.ProcessPoolAsCompletedTests) ... ERROR |
On android: root@generic_x86:/data/local/tmp # python
Python 3.6.0a0 (default:811ccdee6f87+, May 4 2016, 10:31:14)
[GCC 4.9 20140827 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from _multiprocessing import sem_unlink
>>> sem_unlink('foo')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 38] Function not implemented
>>> |
It normally should raise an ImportError if sem_unlink is not available. Could you try the attached patch please? |
Patch tested, it does not fix the problem.
This is because in pyconfig.h:
/* Define to 1 if you have the `sem_unlink' function. */
#define HAVE_SEM_UNLINK 1 Android declares the function but does not implement it. This is not the only case, for example issue bpo-26857. |
Thanks for testing. Here is a new patch. |
Here is the result of the test: root@generic_x86:/data/local/tmp # python -m test -v test_concurrent_futures |
I meant, results with the new patch. |
New changeset 1030aa8357a7 by Berker Peksag in branch 'default': |
Thanks, Xavier. |
New changeset eee959fee5f5 by Berker Peksag in branch 'default': |
Xavier, could you try this alternative patch? |
Attached the results with sem_unlink_alt.diff. |
There is a typo in sem_unlink_alt.diff, not in the patch itself but in the neighbouring lines. In Modules/_multiprocessing/semaphore.c, it should be, I think, after one does 's/define sem_unlink(name)/define SEM_UNLINK(name)/': @@ -194,8 +194,8 @@
# define SEM_FAILED ((sem_t *)-1)
#endif
-#ifndef HAVE_SEM_UNLINK
-# define sem_unlink(name) 0
+#if !defined(HAVE_SEM_UNLINK) || defined(__ANDROID__)
+# define SEM_UNLINK(name) 0
#endif
#ifndef HAVE_SEM_TIMEDWAIT But applying this new patch, gives exactly the same results. Maybe it is not just sem_unlink() that is not implemented. I will run a gdb session to find out. |
sem_open() is not implemented as well. Here is a gdb session with a breakpoint set at semlock_new() (SEM_FAILED is NULL on android): Breakpoint 1, semlock_new (type=0xb6d070c0 <_PyMp_SemLockType>, This is run with sem_unlink_alt.diff modified to include the change to 'define SEM_UNLINK(name) 0' although I guess this does not change anything. Sorry for misleading you about sem_unlink(). |
Thanks! Perhaps we should not set HAVE_SEM_* to 1 if we are on Android in the configure step. |
Undefining the SEM_* macros in multiprocessing.h when __ANDROID__ is set, would allow for an easier update when those functions become implemented at a future API level. The __ANDROID_API__ macro can be used for that purpose. For example, if this happens at API 24, this could be a changed to: #if defined(__ANDROID__)
# include <android/api-level.h>
# if __ANDROID_API__ < 24
# undef sem_open
# ...
# endif
#endif |
I meant of course: # undef HAVE_SEM_OPEN |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: