This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: asyncio should not depend on concurrent.futures, it is not always available
Type: Stage:
Components: Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, sbt, vstinner
Priority: normal Keywords: patch

Created on 2013-11-17 22:53 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
skipit.patch gvanrossum, 2013-11-18 00:37 review
Messages (8)
msg203222 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-11-17 22:53
On old FreeBSD versions, concurrent.futures cannot be used. I don't remember why, it's probably related to semaphores (something like a low hardcoded limit). See for example first lines of Lib/test/test_concurrent_futures.py:
---
# Skip tests if _multiprocessing wasn't built.            
test.support.import_module('_multiprocessing')   
# Skip tests if sem_open implementation is broken.                        
test.support.import_module('multiprocessing.synchronize')
# import threading after _multiprocessing to raise a more revelant error  
# message: "No module named _multiprocessing". _multiprocessing is not compiled
# without thread support.
test.support.import_module('threading')
---

The problem is that asyncio always try to import concurrent.futures. Example: 

http://buildbot.python.org/all/builders/x86%20FreeBSD%206.4%203.x/builds/4213/steps/test/logs/stdio

test test_asyncio crashed -- Traceback (most recent call last):
  File "/usr/home/db3l/buildarea/3.x.bolen-freebsd/build/Lib/test/regrtest.py", line 1276, in runtest_inner
    test_runner()
  File "/usr/home/db3l/buildarea/3.x.bolen-freebsd/build/Lib/test/test_asyncio/__init__.py", line 31, in test_main
    run_unittest(suite())
  File "/usr/home/db3l/buildarea/3.x.bolen-freebsd/build/Lib/test/test_asyncio/__init__.py", line 21, in suite
    __import__(mod_name)
  File "/usr/home/db3l/buildarea/3.x.bolen-freebsd/build/Lib/test/test_asyncio/test_base_events.py", line 11, in <module>
    from asyncio import base_events
  File "/usr/home/db3l/buildarea/3.x.bolen-freebsd/build/Lib/asyncio/__init__.py", line 21, in <module>
    from .futures import *
  File "/usr/home/db3l/buildarea/3.x.bolen-freebsd/build/Lib/asyncio/futures.py", line 21, in <module>
    Error = concurrent.futures._base.Error
AttributeError: 'module' object has no attribute 'futures'
msg203233 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2013-11-17 23:58
I don't think it's worth complicating the code for this (except perhaps by making the tests fail more gracefully).

The tasks and futures modules import various things from concurrent.futures (some exceptions, and some constants for wait()).

If a platform doesn't have threads, asyncio is not very useful anyway -- you can't create network connections or servers because of the way getaddrinfo() is called.

I recall that this was reported before and I decided I just didn't care.

Who would be using such an old FreeBSD version anyway (while wanting to use a bleeding edge Python version and the bleeding edge asyncio package)?
msg203234 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-11-18 00:00
> Who would be using such an old FreeBSD version anyway (while wanting to use a bleeding edge Python version and the bleeding edge asyncio package)?

If we want to drop support of old FreeBSD versions, something can be done using the PEP 11. We have FreeBSD 6.4 and 7.2 buildbots. I'm trying to fix all buildbots.
msg203235 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2013-11-18 00:12
Well, what would be the incantation to just skip the tests if concurrent.futures can't be imported?

(Although it seems that there's a problem with concurrent.futures if the whole thing refuses to import just because multiprocessing isn't supported -- couldn't the threadpool executor still work?  Asyncio doesn't use any of the multiprocessing stuff.)
msg203236 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2013-11-18 00:37
Can you try this patch? It tweaks the test to skip everything if it can't import concurrent.futures.
msg203237 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-11-18 00:57
> Can you try this patch?

I don't have access to the buildbot. You may try the custom buildbot if you don't want to commit directly:
http://buildbot.python.org/all/builders/x86%20FreeBSD%206.4%20custom
msg203238 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2013-11-18 00:59
I'll just commit it and pray.
msg205991 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-12-12 23:50
@Guido: If you write "issue #xxx" in your commit message, the changeset will be mentionned in the related issue.

---
changeset:   87237:0031ac40806a
user:        Guido van Rossum <guido@dropbox.com>
date:        Sun Nov 17 17:00:21 2013 -0800
files:       Lib/test/test_asyncio/__init__.py
description:
Skip test_asyncio if concurrent.futures can't be imported. Hopeful fix for issue 19645.
---

The changeset fixed the issue: the test is now skipped on "x86 FreeBSD 6.4 3.x" buildbot.
History
Date User Action Args
2022-04-11 14:57:53adminsetgithub: 63834
2013-12-12 23:50:53vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg205991
2013-11-18 00:59:25gvanrossumsetmessages: + msg203238
2013-11-18 00:57:38vstinnersetmessages: + msg203237
2013-11-18 00:37:51gvanrossumsetfiles: + skipit.patch
keywords: + patch
messages: + msg203236
2013-11-18 00:14:00vstinnersetnosy: + sbt
2013-11-18 00:12:02gvanrossumsetmessages: + msg203235
2013-11-18 00:00:30vstinnersetmessages: + msg203234
2013-11-17 23:58:16gvanrossumsetmessages: + msg203233
2013-11-17 22:53:22vstinnercreate