Infinite loop with (python +poetry)
- Dominant language
- Emacs Lisp
- Stars
- 22.7k
- Forks
- 3.1k
- Avg merge
- 10h 46m
- Merged PRs (30d)
- 4
Description
### What did you expect to happen?
When I load a python file, it opens without issue
### What actually happened?
There is an infinite loop and poetry mode is not loaded properly, here is the messages and the debugging backtrace (the part that was repeating)

```
poetry-get-project-name()
poetry-message("Waiting for %s operation%s to finish..." 1 "")
poetry-call(config ("virtualenvs.in-project") nil nil t)
poetry-get-configuration("virtualenvs.in-project")
poetry-get-virtualenv()
poetry-track-virtualenv()
#f(compiled-function (func &rest args) #)(# #)
apply(#f(compiled-function (func &rest args) #) # #)
kill-buffer(#)
#f(compiled-function (proc event) #)(# "finished\n")
apply(#f(compiled-function (proc event) #) (# "finished\n"))
explain-pause--wrap-callback(#s(explain-pause-command-record :command process-sentinel :native nil :parent #s(explain-pause-command-record :command "git-gutter" :native nil :parent #s(explain-pause-command-record :command #f(compiled-function (proc event) #) :native nil :parent #s(explain-pause-command-record :command process-sentinel :native nil :parent #s(explain-pause-command-record :command "git-gutter" :native nil :parent #s(explain-pause-command-record :command #f(compiled-function (arg1 arg2) #) :native nil :parent #s(explain-pause-command-record :command process-sentinel :native nil :parent ... :executing-time 0 :entry-snap nil :too-slow nil :is-profiled nil :under-profile nil :profile nil :depth 85) :executing-time 1035 :entry-snap (25183 45212 112218 574000) :too-slow nil :is-profiled nil :under-profile nil :profile nil :depth 86) :executing-time 0 :entry-snap nil :too-slow nil :is-profiled nil :under-profile nil :profile nil :depth 87) :executing-time 0 :entry-snap nil :too-slow nil :is-profiled nil :under-profile nil :profile nil :depth 88) :executing-time 1069 :entry-snap (25183 45213 190742 745000) :too-slow nil :is-profiled nil :under-profile nil :profile nil :depth 89) :executing-time 0 :entry-snap nil :too-slow nil :is-profiled nil :under-profile nil :profile nil :depth 90) :executing-time 0 :entry-snap nil :too-slow nil :is-profiled nil :under-profile nil :profile nil :depth 91) #f(compiled-function (proc event) #) # "finished\n")
apply(explain-pause--wrap-callback #s(explain-pause-command-record :command process-sentinel :native nil :parent #s(explain-pause-command-record :command "git-gutter" :native nil :parent #s(explain-pause-command-record :command #f(compiled-function (proc event) #) :native nil :parent #s(explain-pause-command-record :command process-sentinel :native nil :parent #s(explain-pause-command-record :command "git-gutter" :native nil :parent #s(explain-pause-command-record :command #f(compiled-function (arg1 arg2) #) :native nil :parent #s(explain-pause-command-record :command process-sentinel :native nil :parent ... :executing-time 0 :entry-snap nil :too-slow nil :is-profiled nil :under-profile nil :profile nil :depth 85) :executing-time 1035 :entry-snap (25183 45212 112218 574000) :too-slow nil :is-profiled nil :under-profile nil :profile nil :depth 86) :executing-time 0 :entry-snap nil :too-slow nil :is-profiled nil :under-profile nil :profile nil :depth 87) :executing-time 0 :entry-snap nil :too-slow nil :is-profiled nil :under-profile nil :profile nil :depth 88) :executing-time 1069 :entry-snap (25183 45213 190742 745000) :too-slow nil :is-profiled nil :under-profile nil :profile nil :depth 89) :executing-time 0 :entry-snap nil :too-slow nil :is-profiled nil :under-profile nil :profile nil :depth 90) :executing-time 0 :entry-snap nil :too-slow nil :is-profiled nil :under-profile nil :profile nil :depth 91) #f(compiled-function (proc event) #) (# "finished\n"))
#f(compiled-function (&rest callback-args) #)(# "finished\n")
sleep-for(0.1)
poetry-do-call(config ("virtualenvs.in-project") nil nil t)
poetry-call(config ("virtualenvs.in-project") nil nil t)
poetry-get-configuration("virtualenvs.in-project")
poetry-get-virtualenv()
poetry-track-virtualenv()
#f(compiled-function (func &rest args) #)(# #)
apply(#f(compiled-function (func &rest args) #) # #)
kill-buffer(#)
```
### Describe your attempts to resolve the issue
I tried to set the `poetry-tracking-mode` variable to `nil` but that was ignored.
I asked in the Discord server about the issue and I was pointed to the idea that the `poetry-tracking-mode`, as a global mode, should not be called in the hooks : https://github.com/hlissner/doom-emacs/blob/f51a2cdd3a3c580dfc701761c2b2024a8a9a92a5/modules/lang/python/config.el#L294
After removing that line in my local copy the bug was gone, but there might be more to it
### Steps to reproduce
1. Open emacs
2. We should have `(python +poetry)` in the configuration
3. I have found that this part of my private config was necessary to reproduce, I don't know if it's the hook itself the problem:
```elisp
(use-package lsp-mode
:hook
((python-mode . lsp)
(lsp-mode . lsp-enable-which-key-integration)))
```
4. Open a Python file from a project with a Poetry configuration
### System Information
https://pastebin.com/enUf8Mii
Contributor guide
Research direction
Start with modules/lang/python/config.el around the referenced hook and inspect how poetry-tracking-mode interacts with the lsp-mode and Python hooks. Reproduce by opening a Python file in a Poetry project with the supplied lsp-mode configuration, then trace the reported poetry-get-virtualenv loop. Done means the file opens without an infinite loop and Poetry mode loads correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- emacs-lisp, python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100