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

Lean on pkgutil.resolve_name for importing apps #446

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kgaughan
Copy link
Member

With #445, it no longer makes sense not to use pkgutil.resolve_name to handle the importing of WSGI applications in the runner. There is one very minor behavioural change in that pkgutil.resolve_name allows a broader syntax for the imports, but supports the same syntax as the existing code being removed, so this is a minor concern.

It has the pleasant side effect of removing some legacy code only present for Python 2.6 that was missed when Python 2 support was removed.

With Pylons#445, it no longer makes sense not to use `pkgutil.resolve_name` to
handle the importing of WSGI applications in the runner. There is one
very minor behavioural change in that `pkgutil.resolve_name` allows a
broader syntax for the imports, but supports the same syntax as the
existing code being removed, so this is a minor concern.

It has the pleasant side effect of removing some legacy code only
present for Python 2.6 that was missed when Python 2 support was
removed.
@kgaughan
Copy link
Member Author

Very peculiar. Some of the test workflows randomly hung and had to be rerun. It looks like they failed just as test_function.py was being run. After a few attempts, I was able to reproduce similar behaviour locally:

platform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0
rootdir: .../projects/waitress
configfile: setup.cfg
testpaths: tests
plugins: cov-5.0.0
collected 796 items                                                                                                                                                                                                                                                                                                                                                                         

tests/test_adjustments.py .................................................                                                                                                                                                                                                                                                                                                           [  6%]
tests/test_buffers.py ....................................................                                                                                                                                                                                                                                                                                                            [ 12%]
tests/test_channel.py .........................................................................................................................                                                                                                                                                                                                                                       [ 27%]
tests/test_functional.py ...................................................................................^CTraceback (most recent call last):
  File ".../projects/waitress/src/waitress/server.py", line 325, in run
    self.asyncore.loop(
  File ".../projects/waitress/src/waitress/wasyncore.py", line 245, in loop
    poll_fun(timeout, map)
  File ".../projects/waitress/src/waitress/wasyncore.py", line 183, in poll
    read(obj)
  File ".../projects/waitress/src/waitress/wasyncore.py", line 104, in read
    obj.handle_read_event()
  File ".../projects/waitress/src/waitress/wasyncore.py", line 466, in handle_read_event
    self.handle_read()
  File ".../projects/waitress/src/waitress/channel.py", line 156, in handle_read
    data = self.recv(self.adj.recv_bytes)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../projects/waitress/src/waitress/wasyncore.py", line 409, in recv
    def recv(self, buffer_size):
    
  File ".../projects/waitress/.venv/lib/python3.12/site-packages/coverage/collector.py", line 252, in lock_data
    self.data_lock.acquire()
  File ".../projects/waitress/tests/test_functional.py", line 43, in sigterm
    sys.exit(0)
SystemExit: 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/lib/python3.12/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File ".../projects/waitress/tests/test_functional.py", line 33, in start_server
    svr(app, queue, **kwargs).run()
  File ".../projects/waitress/src/waitress/server.py", line 331, in run
    self.task_dispatcher.shutdown()
  File ".../projects/waitress/src/waitress/task.py", line 118, in shutdown
    def shutdown(self, cancel_pending=True, timeout=5):
    
  File ".../projects/waitress/.venv/lib/python3.12/site-packages/coverage/collector.py", line 252, in lock_data
    self.data_lock.acquire()
KeyboardInterrupt

At first glance, coverage looks like the culprit, but it might just be an innocent bystander. At the very least, there looks to be a race condition somewhere.

@kgaughan
Copy link
Member Author

I opened #449 to deal with the issue functional tests hanging.

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

Successfully merging this pull request may close these issues.

1 participant