cheroot icon indicating copy to clipboard operation
cheroot copied to clipboard

Tests hang after test_bind_addr_inet[::] on macOS

Open jaraco opened this issue 6 years ago • 5 comments

Running the tests at master (97af36eb) on my local workstation with Python 2.7.16, the tests hang after test_bind_addr_inet:

 cheroot/test/test_errors.py::test_plat_specific_errors[err_names1-err_nums1] ✓                                                                                  55% █████▌    
 cheroot/test/test_server.py::test_prepare_makes_server_ready ✓                                                                                                  56% █████▋    
 cheroot/test/test_server.py::test_stop_interrupts_serve ✓                                                                                                       57% █████▊    
 cheroot/test/test_server.py::test_bind_addr_inet[0.0.0.0] ✓                                                                                                     58% █████▊    
 cheroot/test/test_server.py::test_bind_addr_inet[::] ✓                                                                                                          59% █████▉    ^CERROR: KEYBOARDINTERRUPT

I'm forced to kill the server. Not sure what's going on.

jaraco avatar Mar 27 '19 16:03 jaraco

Running with tox -e py27 -- -k test_server, I'm able to replicate the behavior.

On Python 3, the tests complete without a hitch.

jaraco avatar Mar 27 '19 16:03 jaraco

When I run the tests with -s, I see this traceback before things hang:

Exception in thread Thread-44:
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/Users/jaraco/code/public/cherrypy/cheroot/cheroot/server.py", line 1705, in safe_start
    self.start()
  File "/Users/jaraco/code/public/cherrypy/cheroot/cheroot/server.py", line 1814, in start
    self.prepare()
  File "/Users/jaraco/code/public/cherrypy/cheroot/cheroot/server.py", line 1737, in prepare
    self.bind_unix_socket(self.bind_addr)
  File "/Users/jaraco/code/public/cherrypy/cheroot/cheroot/server.py", line 1893, in bind_unix_socket
    os.chmod(bind_addr, fs_permissions, follow_symlinks=False)
TypeError: chmod() takes no keyword arguments

jaraco avatar Mar 27 '19 16:03 jaraco

Oh... This part needs to be shimmed properly. I don't use macOS personally so may be unable to spot this.

Interestingly, it doesn't happen in Travis CI: https://travis-ci.org/cherrypy/cheroot/jobs/511837737 under Python 2.7.13.

os functions in that place in the code have OS-specific differences so we may expect a difference in supported arguments and even function existence under *BSD (macOS?), Windows and GNU/Linux...

I think I've spotted some envs where follow_symlinks feature is missing.

webknjaz avatar Mar 27 '19 16:03 webknjaz

Nice, Python 3.3+ has this set of functions supporting follow_symlinks: https://docs.python.org/3/library/os.html#os.supports_follow_symlinks

Python 2.7 implementation doesn't have this arg... https://docs.python.org/2.7/library/os.html#os.chmod

Under such envs, we need to use https://docs.python.org/2.7/library/os.html#os.lchmod

webknjaz avatar Mar 27 '19 16:03 webknjaz

It seems BSD-like OSs don't have os.lchmod() which triggers os.chmod(bind_addr, fs_permissions, follow_symlinks=False) code path with arg which is missing under Python 2...

webknjaz avatar Mar 27 '19 16:03 webknjaz