Skip to content
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

#9 is not fixed on PyPy #316

Closed
skirpichev opened this issue Jul 25, 2018 · 10 comments
Closed

#9 is not fixed on PyPy #316

skirpichev opened this issue Jul 25, 2018 · 10 comments

Comments

@skirpichev
Copy link
Contributor

See commit skirpichev/diofant@cfe8a53, which return -n auto and failing CI build: https://travis-ci.org/diofant/diofant/jobs/407725598

CC @greut

@greut
Copy link
Contributor

greut commented Jul 25, 2018

os.sched_getaffinity seems to be Python3 only and restricted to some platforms..., so it won't fix it for anything Python2-ish, or as it seems PyPy(3).

@skirpichev
Copy link
Contributor Author

@greut, above build was on

$ python --version
Python 3.5.3 (3f6eaa010fce, Jan 11 2018, 04:44:35)
[PyPy 5.10.1 with GCC 6.2.0 20160901]

It's Python3-compatible version of PyPy.

@greut
Copy link
Contributor

greut commented Jul 25, 2018

% pypy3
Python 3.5.3 (fdd60ed87e941677e8ea11acf9f1819466521bf2, Jun 22 2018, 02:39:05)
[PyPy 6.0.0 with GCC 8.1.1 20180531] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>> import os
>>>> os.sched_getaffinity(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'os' has no attribute 'sched_getaffinity'

% python3 
Python 3.6.6 (default, Jun 27 2018, 13:11:40) 
[GCC 8.1.1 20180531] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.sched_getaffinity(0)
{0, 1, 2, 3}

@skirpichev
Copy link
Contributor Author

CPython docs says "New in version 3.3", so, IIUIC it must be in PyPy3. Sounds like PyPy3 bug.

psutils seems to be working, as it was suggested in related issue travis-ci/travis-ci#4696 (comment):

In [1]: import psutil

In [2]: psutil.Process().cpu_affinity()
Out[2]: [0, 1]

In [3]: import sys

In [4]: sys.version
Out[4]: '3.5.3 (fdd60ed87e94, Apr 24 2018, 06:10:04)\n[PyPy 6.0.0 with GCC 6.2.0 20160901]'

Not sure if it worth adding additional deps. You may want implement instead a hack for travis-ci, suggested in #9.

@nicoddemus
Copy link
Member

nicoddemus commented Jul 25, 2018

I don't mind adding:

if os.environ.get('TRAVIS') == 'true':
    return 2

To our function that discovers the number of cpus when auto is given. It is a hack, but it is just 2 lines of code and will solve a real problem users have right now.

What do you think @RonnyPfannschmidt?

@RonnyPfannschmidt
Copy link
Member

sounds okish as a hack

can we factor the cpu number finding into a function and add a few unit/integration tests while we are on it

@nicoddemus
Copy link
Member

Sure, sounds good.

Anybody would like to take this on? Seems like a quick contribution. I would be happy to review/merge this.

@skirpichev
Copy link
Contributor Author

skirpichev commented Jul 25, 2018 via email

@greut
Copy link
Contributor

greut commented Jul 25, 2018

@nicoddemus
Copy link
Member

Can you release a minor version after merge?

Sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants