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

ValueError: need at most 63 handles, got a sequence of length 65 #564

Closed
alexandrul opened this issue Oct 15, 2018 · 7 comments · Fixed by #838
Closed

ValueError: need at most 63 handles, got a sequence of length 65 #564

alexandrul opened this issue Oct 15, 2018 · 7 comments · Fixed by #838
Labels
C: packaging Installation and packaging of Black T: bug Something isn't working

Comments

@alexandrul
Copy link

Black runs just fine with a single file or a folder without subfolders.
However, when specifying a folder with subfolders I'm getting the errors below.

Since I don't have another server with the same Windows version, I can't exclude a Windows installation issue, even if other python scripts and tools are working fine.

Python 3.7

Exception in thread QueueManagerThread:
Traceback (most recent call last):
  File "c:\python37\lib\threading.py", line 917, in _bootstrap_inner
    self.run()
  File "c:\python37\lib\threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "c:\python37\lib\concurrent\futures\process.py", line 354, in _queue_management_worker
    ready = wait(readers + worker_sentinels)
  File "c:\python37\lib\multiprocessing\connection.py", line 868, in wait
    ready_handles = _exhaustive_wait(waithandle_to_obj.keys(), timeout)
  File "c:\python37\lib\multiprocessing\connection.py", line 800, in _exhaustive_wait
    res = _winapi.WaitForMultipleObjects(L, False, timeout)
ValueError: need at most 63 handles, got a sequence of length 65

Python 3.6

Exception in thread Thread-1:
Traceback (most recent call last):
  File "c:\python36\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "c:\python36\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "c:\python36\lib\concurrent\futures\process.py", line 270, in _queue_management_worker
    ready = wait([reader] + sentinels)
  File "c:\python36\lib\multiprocessing\connection.py", line 859, in wait
    ready_handles = _exhaustive_wait(waithandle_to_obj.keys(), timeout)
  File "c:\python36\lib\multiprocessing\connection.py", line 791, in _exhaustive_wait
    res = _winapi.WaitForMultipleObjects(L, False, timeout)
ValueError: need at most 63 handles, got a sequence of length 64

Operating system: Windows Server 2012 R2 (x64)
Python version: 3.6.6, 3.7.0, 3.7.1rc2 (x64)
Black version: 18.6b4, 18.9b0
Does also happen on master: Yes

@alexandrul
Copy link
Author

While running the tests I'm getting into a similar behavior: it seems to freeze after printing some differences from tests\data\string_quotes.py

For the record, there are 65 python processes with --multiprocessing-fork in their command line.

@gwdekker
Copy link

gwdekker commented Apr 2, 2019

A colleague of mine did some digging, and found that this seems to be related to an old open python issue here. Sounds like Black limiting itself to max 60 threads on Windows could be a solution? Could not find any option to set this from the user side when using black, any advice is appreciated.

@zsol
Copy link
Collaborator

zsol commented Apr 3, 2019

Sounds easy enough, anyone willing to put up a pr so we can test it out?

@rbtcollins
Copy link

rbtcollins commented Apr 17, 2019

Steve Dower has offered to review patches to Python itself to fix this; I'd be happy to argue for backporting them existing releases, if someone would like to fix this at source, rather than band-aiding it.

(edited, it was late is my only excuse). In short: multiprocessing is using a thread per process to track the processes, which is quite wasteful on both unix and windows where nonblocking primitives exist, but nevertheless, thats what it is doing. black would need to limit itself to 60 processes to avoid the limit in question as a result; which is probably fine - one would need a hecka lot of code to run out of patience at that concurrency, at least for now.

@JelleZijlstra JelleZijlstra added C: packaging Installation and packaging of Black T: bug Something isn't working labels May 5, 2019
@Jasha10
Copy link

Jasha10 commented Mar 1, 2020

Still running into the same problem:

(myenv) C:\Users\Jasha\git_repos\myenv_tick_scraper>black.exe .
Exception in thread QueueManagerThread:
Traceback (most recent call last):
  File "C:\Users\Jasha\.conda\envs\myenv\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\Jasha\.conda\envs\myenv\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Jasha\.conda\envs\myenv\lib\concurrent\futures\process.py", line 362, in _queue_management_worker
    ready = mp.connection.wait(readers + worker_sentinels)
  File "C:\Users\Jasha\.conda\envs\myenv\lib\multiprocessing\connection.py", line 878, in wait
    ready_handles = _exhaustive_wait(waithandle_to_obj.keys(), timeout)
  File "C:\Users\Jasha\.conda\envs\myenv\lib\multiprocessing\connection.py", line 810, in _exhaustive_wait
    res = _winapi.WaitForMultipleObjects(L, False, timeout)
ValueError: need at most 63 handles, got a sequence of length 63

This is black version 19.10b0 and python 3.8, installed using Anaconda.

@mitoihs
Copy link

mitoihs commented May 13, 2020

I'm also still encountering this issue with black==19.10b0 and Python 3.7.4 on Windows machine.

>python -m black --check --fast .
Exception in thread QueueManagerThread:
Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "C:\Program Files\Python37\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Program Files\Python37\lib\concurrent\futures\process.py", line 361, in _queue_management_worker
    ready = wait(readers + worker_sentinels)
  File "C:\Program Files\Python37\lib\multiprocessing\connection.py", line 868, in wait
    ready_handles = _exhaustive_wait(waithandle_to_obj.keys(), timeout)
  File "C:\Program Files\Python37\lib\multiprocessing\connection.py", line 800, in _exhaustive_wait
    res = _winapi.WaitForMultipleObjects(L, False, timeout)
ValueError: need at most 63 handles, got a sequence of length 63

@kevinkleinQC
Copy link

kevinkleinQC commented Jul 28, 2020

I'm encountering this issue with black 19.10b0 and python 3.8.3 on Windows Server 2012.

$ black dbcheck
Exception in thread QueueManagerThread:
Traceback (most recent call last):
  File "D:\Personal\Kevin_Klein\envs\dbcheck\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "D:\Personal\Kevin_Klein\envs\dbcheck\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Personal\Kevin_Klein\envs\dbcheck\lib\concurrent\futures\process.py", line 362, in _queue_management_worker
    ready = mp.connection.wait(readers + worker_sentinels)
  File "D:\Personal\Kevin_Klein\envs\dbcheck\lib\multiprocessing\connection.py", line 879, in wait
    ready_handles = _exhaustive_wait(waithandle_to_obj.keys(), timeout)
  File "D:\Personal\Kevin_Klein\envs\dbcheck\lib\multiprocessing\connection.py", line 811, in _exhaustive_wait
    res = _winapi.WaitForMultipleObjects(L, False, timeout)
ValueError: need at most 63 handles, got a sequence of length 63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: packaging Installation and packaging of Black T: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants