Commit 7ff120b
committed
Support platforms where multiprocessing does not work
Check if multiprocessing is supported and else set
multiprocessing=False. When later creating list of tasks to run we
then choose to either run pool.apply_async(function), or to just
eval(function).
Import test for multiprocessing is taken from
https://github.com/pipxproject/pipx/blob/4870ba6bd0164448c0f6b34dd663cba33b396287/src/pipx/commands/list_packages.py#L12.
The full error message from trying to run pythontex on android looks like:
```
This is PythonTeX 0.17
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.8/multiprocessing/synchronize.py", line 28, in <module>
from _multiprocessing import SemLock, sem_unlink
ImportError: cannot import name 'SemLock' from '_multiprocessing' (/data/data/com.termux/files/usr/lib/python3.8/lib-dynload/_multiprocessing.cpython-38.so)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/bin/texlive/pythontex", line 62, in <module>
pythontex.main()
File "/data/data/com.termux/files/usr/share/texlive/texmf-dist/scripts/pythontex/pythontex3.py", line 2811, in main
do_multiprocessing(data, temp_data, old_data, engine_dict)
File "/data/data/com.termux/files/usr/share/texlive/texmf-dist/scripts/pythontex/pythontex3.py", line 1269, in do_multiprocessing
pool = multiprocessing.Pool(jobs)
File "/data/data/com.termux/files/usr/lib/python3.8/multiprocessing/context.py", line 119, in Pool
return Pool(processes, initializer, initargs, maxtasksperchild,
File "/data/data/com.termux/files/usr/lib/python3.8/multiprocessing/pool.py", line 191, in __init__
self._setup_queues()
File "/data/data/com.termux/files/usr/lib/python3.8/multiprocessing/pool.py", line 343, in _setup_queues
self._inqueue = self._ctx.SimpleQueue()
File "/data/data/com.termux/files/usr/lib/python3.8/multiprocessing/context.py", line 113, in SimpleQueue
return SimpleQueue(ctx=self.get_context())
File "/data/data/com.termux/files/usr/lib/python3.8/multiprocessing/queues.py", line 336, in __init__
self._rlock = ctx.Lock()
File "/data/data/com.termux/files/usr/lib/python3.8/multiprocessing/context.py", line 67, in Lock
from .synchronize import Lock
File "/data/data/com.termux/files/usr/lib/python3.8/multiprocessing/synchronize.py", line 30, in <module>
raise ImportError("This platform lacks a functioning sem_open" +
ImportError: This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770.
```1 parent f6ca8c6 commit 7ff120b
1 file changed
+81
-55
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | 60 | | |
62 | 61 | | |
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
66 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
67 | 73 | | |
68 | 74 | | |
69 | 75 | | |
| |||
192 | 198 | | |
193 | 199 | | |
194 | 200 | | |
195 | | - | |
| 201 | + | |
196 | 202 | | |
| 203 | + | |
197 | 204 | | |
198 | 205 | | |
199 | 206 | | |
| |||
1145 | 1152 | | |
1146 | 1153 | | |
1147 | 1154 | | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
1148 | 1162 | | |
1149 | 1163 | | |
1150 | 1164 | | |
| |||
1269 | 1283 | | |
1270 | 1284 | | |
1271 | 1285 | | |
1272 | | - | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
1273 | 1294 | | |
1274 | 1295 | | |
1275 | 1296 | | |
| |||
1284 | 1305 | | |
1285 | 1306 | | |
1286 | 1307 | | |
1287 | | - | |
1288 | | - | |
1289 | | - | |
1290 | | - | |
1291 | | - | |
1292 | | - | |
1293 | | - | |
1294 | | - | |
1295 | | - | |
1296 | | - | |
1297 | | - | |
1298 | | - | |
1299 | | - | |
1300 | | - | |
1301 | | - | |
1302 | | - | |
1303 | | - | |
1304 | | - | |
1305 | | - | |
1306 | | - | |
1307 | | - | |
1308 | | - | |
1309 | | - | |
1310 | | - | |
1311 | | - | |
1312 | | - | |
1313 | | - | |
1314 | | - | |
1315 | | - | |
1316 | | - | |
1317 | | - | |
1318 | | - | |
1319 | | - | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
1320 | 1341 | | |
1321 | 1342 | | |
1322 | 1343 | | |
| |||
1331 | 1352 | | |
1332 | 1353 | | |
1333 | 1354 | | |
1334 | | - | |
1335 | | - | |
1336 | | - | |
1337 | | - | |
1338 | | - | |
1339 | | - | |
1340 | | - | |
1341 | | - | |
1342 | | - | |
1343 | | - | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
1344 | 1365 | | |
1345 | 1366 | | |
1346 | 1367 | | |
| |||
1353 | 1374 | | |
1354 | 1375 | | |
1355 | 1376 | | |
1356 | | - | |
1357 | | - | |
1358 | | - | |
1359 | | - | |
1360 | | - | |
1361 | | - | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
1362 | 1383 | | |
1363 | 1384 | | |
1364 | 1385 | | |
1365 | 1386 | | |
1366 | | - | |
1367 | | - | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
1368 | 1390 | | |
1369 | 1391 | | |
1370 | 1392 | | |
| |||
1375 | 1397 | | |
1376 | 1398 | | |
1377 | 1399 | | |
1378 | | - | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
1379 | 1405 | | |
1380 | 1406 | | |
1381 | 1407 | | |
| |||
0 commit comments